linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC] start_aggressive_readahead
@ 2002-07-25 16:10 Christoph Hellwig
  2002-07-25 16:44 ` Rik van Riel
  2002-07-26  6:53 ` Daniel Phillips
  0 siblings, 2 replies; 23+ messages in thread
From: Christoph Hellwig @ 2002-07-25 16:10 UTC (permalink / raw)
  To: torvalds; +Cc: linux-mm

Another patch from the XFS tree, I'd be happy to get some comments on
this one again.

This function (start_aggressive_readahead()) checks whether all zones
of the given gfp mask have lots of free pages.  XFS needs this for it's
own readahead code (used only deep in the directory code, normal file
readahead is handled by the generic pagecache code).  We perform the
readahead only is it returns 1 for enough free pages.

We could rip it out of XFS entirely without funcionality-loss, but it
would cost directory handling performance.

I'm also open for a better name (I think the current one is very bad,
but don't have a better idea :)).  I'd also be ineterested in comments
how to avoid the new function and use existing functionality for it,
but I've tried to find it for a long time and didn't find something
suiteable.

-- 
The US Army issues lap-top computers now to squad-leaders on up. [...]
Believe me, there is nothing more lethal than a Power Point briefing
given by an Army person.	-- Leon A. Goldstein

--- linux/include/linux/mm.h Wed, 29 May 2002 14:00:22
+++ linux/include/linux/mm.h Mon, 22 Jul 2002 12:06:09
@@ -460,6 +460,8 @@ extern void FASTCALL(free_pages(unsigned
 #define __free_page(page) __free_pages((page), 0)
 #define free_page(addr) free_pages((addr),0)
 
+extern int start_aggressive_readahead(int);
+
 extern void show_free_areas(void);
 extern void show_free_areas_node(pg_data_t *pgdat);
 
--- linux/kernel/ksyms.c Wed, 17 Jul 2002 12:08:06
+++ linux/kernel/ksyms.c Mon, 22 Jul 2002 12:06:09
@@ -90,6 +90,7 @@ EXPORT_SYMBOL(exit_fs);
 EXPORT_SYMBOL(exit_sighand);
 
 /* internal kernel memory management */
+EXPORT_SYMBOL(start_aggressive_readahead);
 EXPORT_SYMBOL(_alloc_pages);
 EXPORT_SYMBOL(__alloc_pages);
 EXPORT_SYMBOL(alloc_pages_node);
--- linux/mm/page_alloc.c Tue, 25 Jun 2002 10:15:12 
+++ linux/mm/page_alloc.c Mon, 22 Jul 2002 12:06:09
@@ -512,6 +512,37 @@ unsigned int nr_free_highpages (void)
 #define K(x) ((x) << (PAGE_SHIFT-10))
 
 /*
+ * If it returns non zero it means there's lots of ram "free"
+ * (note: not in cache!) so any caller will know that
+ * he can allocate some memory to do some more aggressive
+ * (possibly wasteful) readahead. The state of the memory
+ * should be rechecked after every few pages allocated for
+ * doing this aggressive readahead.
+ *
+ * NOTE: caller passes in gfp_mask of zones to check
+ */
+int start_aggressive_readahead(int gfp_mask)
+{
+	pg_data_t *pgdat = pgdat_list;
+	zonelist_t *zonelist;
+	zone_t **zonep, *zone;
+	int ret = 0;
+
+	do {
+		zonelist = pgdat->node_zonelists + (gfp_mask & GFP_ZONEMASK);
+		zonep = zonelist->zones;
+
+		for (zone = *zonep++; zone; zone = *zonep++)
+			if (zone->free_pages > zone->pages_high * 2)
+				ret = 1;
+
+		pgdat = pgdat->node_next;
+	} while (pgdat);
+
+	return ret;
+}
+
+/*
  * Show free area list (used inside shift_scroll-lock stuff)
  * We also calculate the percentage fragmentation. We do this by counting the
  * memory on each free list with the exception of the first item on the list.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2002-08-05 18:54 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25 16:10 [RFC] start_aggressive_readahead Christoph Hellwig
2002-07-25 16:44 ` Rik van Riel
2002-07-25 19:40   ` Andrew Morton
2002-07-26 16:50     ` Scott Kaplan
2002-07-26 19:38       ` Andrew Morton
2002-07-28 23:32         ` Scott Kaplan
2002-07-29  0:19           ` Rik van Riel
2002-07-29  2:12             ` Scott Kaplan
2002-07-29  3:05               ` Rik van Riel
2002-07-29 15:24                 ` Scott Kaplan
2002-07-29  7:34           ` Andrew Morton
2002-07-29  7:37             ` Vladimir Dergachev
2002-07-29  7:53               ` Andrew Morton
2002-07-29  8:04             ` Rik van Riel
2002-07-30 16:11             ` Scott Kaplan
2002-07-30 16:21               ` Martin J. Bligh
2002-07-30 16:38                 ` Scott Kaplan
2002-07-30 16:52                   ` Martin J. Bligh
2002-08-05 18:54                     ` Scott Kaplan
2002-07-30 17:13                 ` William Lee Irwin III
2002-07-26 20:14     ` Stephen Lord
2002-07-26 20:29       ` Andrew Morton
2002-07-26  6:53 ` Daniel Phillips

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox