linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH NG] alloc_pages_limit & pages_min
@ 2001-08-22 23:46 Roger Larsson
  2001-08-23  0:40 ` Rik van Riel
  0 siblings, 1 reply; 9+ messages in thread
From: Roger Larsson @ 2001-08-22 23:46 UTC (permalink / raw)
  To: linux-mm

Hi,

[Note: not tested yet... but it might be hard to trigger]

After discussions with Riel and some additions...

* The original code had a little bug in those cases when
- kreclaimd were not allowed to run for a LONG time...
Lots of kernel activity, RT tasks, or code running
around for a long time allocating memory.
- there were lots of inactive clean pages
- pages were allocated without direct_reclaim (higher order)
(networking might be one candidate)
it could result in using up ALL free pages!

This patch tries to prevent this situation in several ways:
1) Do not allow to alloc a free page when they are critically low.
   [last line of patch]

2) If direct reclaims are allowed do some additional work.
 reclaim & free until pages_min,
 alloc one page,
 reclaim and free until pages_low

Q) Nothing is done to force execution of kreclaimd, if no process
    that can direct_reclaim allocs a page - what will happen then?
    [unlikely but...]

/RogerL

-- 
Roger Larsson
Skelleftea
Sweden


*******************************************
Patch prepared by: roger.larsson@norran.net with comments from Riel

--- linux/mm/page_alloc.c.orig	Wed Aug 22 13:36:57 2001
+++ linux/mm/page_alloc.c	Thu Aug 23 01:15:17 2001
@@ -253,11 +253,35 @@
 
 		if (z->free_pages + z->inactive_clean_pages >= water_mark) {
 			struct page *page = NULL;
-			/* If possible, reclaim a page directly. */
-			if (direct_reclaim)
+
+			/*
+			 * Reclaim a page from the inactive_clean list.
+			 * If needed, refill the free list up to the
+			 * low water mark.
+			 */
+			if (direct_reclaim) {
 				page = reclaim_page(z);
-			/* If that fails, fall back to rmqueue. */
-			if (!page)
+
+				while (page && z->free_pages < z->pages_min) {
+					__free_page(page);
+					page = reclaim_page(z);
+				}
+
+				if (page) {
+					while (z->free_pages < z->pages_low) {
+						struct page *extra = reclaim_page(z);
+						if (!extra)
+							break;
+						__free_page(extra);
+					}
+				}
+
+				/* let kreclaimd handle up to pages_high */
+			}
+			/* If that fails, fall back to rmqueue, but never let
+			*  free_pages go below pages_min...
+			*/
+			if (!page && z->free_pages >= z->pages_min)
 				page = rmqueue(z, order);
 			if (page)
 				return page;
--
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] 9+ messages in thread

end of thread, other threads:[~2001-08-23 19:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-22 23:46 [PATCH NG] alloc_pages_limit & pages_min Roger Larsson
2001-08-23  0:40 ` Rik van Riel
2001-08-23 18:36   ` Roger Larsson
2001-08-23 18:44     ` Rik van Riel
2001-08-23 18:52       ` Roger Larsson
2001-08-23 19:03         ` Rik van Riel
2001-08-23 19:28           ` Upd: " Roger Larsson
2001-08-23 18:45   ` Roger Larsson
2001-08-23 18:55     ` Rik van Riel

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