Skip to contentSkip to conversation

code clean up of kswapd

PATCH New Roger Larsson 1 participant 1 message Jun 5, 2000 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 code clean up of kswapd

Hi all,

This is only a code clean up of kswapd - It should do almost the same.

I do not claim improved performance :-( But improved readability :-)

Basically done to be able to add other stuff more easily later...

[Not tried against ac8, but ac7+riel.3
should be almost the same]

Comments?

/RogerL

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

vmscan.c renamed from vmscan.c.riel +20 -5
@@ -551,24 +551,39 @@
 	for (;;) {
 		pg_data_t *pgdat;
 		int something_to_do = 0;
+		int more_to_do = 0;
 
 		pgdat = pgdat_list;
 		do {
 			int i;
+
 			for(i = 0; i < MAX_NR_ZONES; i++) {
 				zone_t *zone = pgdat->node_zones+ i;
-				if (tsk->need_resched)
-					schedule();
 				if (!zone->size || !zone->zone_wake_kswapd)
 					continue;
+				something_to_do = 1;
 				if (zone->free_pages < zone->pages_low)
-					something_to_do = 1;
-				do_try_to_free_pages(GFP_KSWAPD);
+				        more_to_do = 1;
 			}
 			pgdat = pgdat->node_next;
+
 		} while (pgdat);
 
-		if (!something_to_do) {
+		/* Need to free pages?
+		 * Will actually run fewer times than previous version!
+		 * (It did run once per zone with waken kswapd)
+		 */
+		if (something_to_do) { 
+		  do_try_to_free_pages(GFP_KSWAPD);
+		}
+
+		/* In a hurry? */
+		if (more_to_do) {
+		        if (tsk->need_resched) {
+		           schedule();
+			}
+		}
+		else {
 			tsk->state = TASK_INTERRUPTIBLE;
 			interruptible_sleep_on(&kswapd_wait);
 		}