Skip to contentSkip to conversation

test5-1 vmfix-3.0

PATCH In review Roger Larsson 2 participants 3 messages Jul 19, 2000 – Jul 21, 2000

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test5-1 vmfix-3.0

Hi,

Another attempt.

With this patch I get noticeable improvements in streaming write +16%! (streaming write throughput is close to streaming read :-)

dbench results are mixed - slightly worse than plain test5-1... It now survives mmap002, as opposed to vmfix-2.x :-) there were bugs of cause.

* Basic idea in this patch is to keep free pages of zones in the range [pages_high ... pages_low]. Kswapd will only run until one zone gets pages_high. In this situation pages from all zones are free able.
* In addition kswapd will run if any zone has less than pages_low.

* Actually implemented by using three values in zone_wake_kswapd 0 = zone initially above pages_high, allocs allowed until zone gets < pages_low
1 = zone < pages_low
-1 = additional alloc done after zone become < pages_low Most of the time there will only be one zone to with zone_wake_kswapd zero. This zone will get the allocs until it also gets < pages_low, then kswapd starts and runs until any zone gets > pages_high - it will probably be another zone. Now that one gets the allocs, ...

* There are some additional stuff that needs cleaning / further investigations.

/RogerL

--
Home page:
http://www.norran.net/nra02596/

mm/vmscan.c renamed from mm/vmscan.c.orig +30 -25
@@ -419,7 +419,7 @@ out:
 }
 
 /*
- * Check if there is any memory pressure (free_pages < pages_low)
+ * Check if there is any memory pressure (zone_wake_kswapd < 0)
  */
 static inline int memory_pressure(void)
 {
@@ -430,7 +430,7 @@ static inline int memory_pressure(void)
 		for(i = 0; i < MAX_NR_ZONES; i++) {
 			zone_t *zone = pgdat->node_zones+ i;
 			if (zone->size &&
-			    zone->free_pages < zone->pages_low)
+			    zone->zone_wake_kswapd < 0)
 				return 1;
 		}
 		pgdat = pgdat->node_next;
@@ -440,24 +440,31 @@ static inline int memory_pressure(void)
 }
 
 /*
- * Check if there recently has been memory pressure (zone_wake_kswapd)
+ * Check if any zone have recently been critical (low_on_memory)
+ * any zone with current memory pressure (zone_wake_kswapd < 0)
+ * all zones have recently had memory_pressure (zone_wake_kswapd)
  */
 static inline int keep_kswapd_awake(void)
 {
+	int all_recent = 1;
 	pg_data_t *pgdat = pgdat_list;
 
 	do {
 		int i;
 		for(i = 0; i < MAX_NR_ZONES; i++) {
 			zone_t *zone = pgdat->node_zones+ i;
-			if (zone->size &&
-			    zone->zone_wake_kswapd)
-				return 1;
+			if (zone->size) {
+				if (zone->zone_wake_kswapd < 0 ||
+				    zone->low_on_memory)
+					return 1;
+				if (!zone->zone_wake_kswapd)
+					all_recent = 0;
+			}
 		}
 		pgdat = pgdat->node_next;
 	} while (pgdat);
 
-	return 0;
+	return all_recent;
 }
 
 /*
@@ -484,7 +491,7 @@ static int do_try_to_free_pages(unsigned
 
 	priority = 64;
 	do {
-		if (current->need_resched) {
+		if ((gfp_mask & __GFP_IO) && current->need_resched) {
 			schedule();
 			/* time has passed - pressure too? */
 			if (!memory_pressure())
@@ -496,9 +503,6 @@ static int do_try_to_free_pages(unsigned
 				goto done;
 		}
 
-		/* not (been) low on memory - it is
-		 * pointless to try to swap out.
-		 */
 		if (!keep_kswapd_awake())
 			goto done;
 
@@ -516,12 +520,10 @@ static int do_try_to_free_pages(unsigned
 			 * In the inner funtions there is a comment:
 			 * "To help debugging, a zero exit status indicates
 			 *  all slabs were released." (-arca?)
-			 * lets handle it in a primitive but working way...
+			 * remove it... to visualize the problem.
 			 *	if (count <= 0)
 			 *		goto done;
 			 */
-			if (!keep_kswapd_awake())
-				goto done;
 
 			while (shm_swap(priority, gfp_mask)) {
 				if (!--count)
@@ -596,10 +598,7 @@ int kswapd(void *unused)
 
 	for (;;) {
 		if (!keep_kswapd_awake()) {
-			/* wake up regulary to do an early attempt too free
-			 * pages - pages will not actually be freed.
-			 */
-			interruptible_sleep_on_timeout(&kswapd_wait, HZ);
+			interruptible_sleep_on(&kswapd_wait);
 		}
 
 		do_try_to_free_pages(GFP_KSWAPD);
@@ -628,24 +627,30 @@ int try_to_free_pages(unsigned int gfp_m
 	if (gfp_mask & __GFP_WAIT) {
 		current->state = TASK_RUNNING;
 		current->flags |= PF_MEMALLOC;
-		retval = do_try_to_free_pages(gfp_mask);
+		do {
+			retval = do_try_to_free_pages(gfp_mask);
+		} while (!retval);
 		current->flags &= ~PF_MEMALLOC;
 	}
-	else {
-		/* make sure kswapd runs */
-		if (waitqueue_active(&kswapd_wait))
-			wake_up_interruptible(&kswapd_wait);
-	}
+
+	/* someone needed memory that kswapd had not provided
+	 * make sure kswapd runs, should not happen often */
+	if (waitqueue_active(&kswapd_wait))
+		wake_up_interruptible(&kswapd_wait);
 
 	return retval;
 }
 
 static int __init kswapd_init(void)
 {
-	printk("Starting kswapd v1.6\n");
+	printk("Starting kswapd v1.7\n");
 	swap_setup();
 	kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
 	return 0;
 }
 
 module_init(kswapd_init)
+
+
+
+
mm/page_alloc.c renamed from mm/page_alloc.c.orig +50 -23

128 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · Roger Larsson

Hi,

Another attempt.

Not much difference for make -j test.

For reference, I reran ac22clas [record holder] on the same tree.

test4+test5-1vmscan_oneliner+vmfix-3.0

real    10m16.038s (~mobile, one run went 12.5)
user    6m26.130s  (solid)
sys     0m33.070s  (solid)

ac22-clas:

real    7m35.950s  (solid)
user    6m27.630s  (solid)
sys     0m29.570s  (solid)

-Mike

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

#2 lore raw
In reply to Roger Larsson

Hi again,

Reread what I had written.
One documentation error.

Quoted 8 lines · Roger Larsson

Hi,

Another attempt.

With this patch I get noticeable improvements in streaming write +16%! (streaming write throughput is close to streaming read :-)

Quoted 6 lines

dbench results are mixed - slightly worse than plain test5-1... It now survives mmap002, as opposed to vmfix-2.x :-) there were bugs of cause.

* Basic idea in this patch is to keep free pages of zones in the range [pages_high ... pages_low].

This part:

Quoted 3 lines

Kswapd will only run until
one zone gets pages_high. In this situation pages from all zones are free able.

Should read:

Kswapd will start when all zones have zone_wake_kswapd (free_pages < pages_low). In this situation pages from all zones are freeable. Kswapd will run until one zone drops zone_wake_kswapd (free_pages > pages_high).

Quoted 18 lines

* In addition kswapd will run if any zone has less than pages_low.

* Actually implemented by using three values in zone_wake_kswapd 0 = zone initially above pages_high, allocs allowed until zone gets < pages_low
1 = zone < pages_low
-1 = additional alloc done after zone become < pages_low Most of the time there will only be one zone to with zone_wake_kswapd zero. This zone will get the allocs until it also gets < pages_low, then kswapd starts and runs until any zone gets > pages_high - it will probably be another zone. Now that one gets the allocs, ...

* There are some additional stuff that needs cleaning / further investigations.

/RogerL

Quoted 8 lines

--
Home page:
http://www.norran.net/nra02596/

------------------------------------------------------------------------

                                   Name: patch-2.4.0-test5-1-vmfix.30

patch-2.4.0-test5-1-vmfix.30 Type: Plain Text (text/plain)
Encoding: 7bit

--
Home page:
http://www.norran.net/nra02596/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/