Skip to contentSkip to conversation

mm: swap prefetch fix lowmem reserve calc

PATCH In review Con Kolivas 2 participants 3 messages May 18, 2006 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: swap prefetch fix lowmem reserve calc

When examining the free limits in swap_prefetch we should ensure the largest lowmem_reserve for each zone is free.

---
 mm/swap_prefetch.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletion(-)
mm/swap_prefetch.c +13 -1
Index: linux-2.6.17-rc4-mm1/mm/swap_prefetch.c
===================================================================
@@ -258,6 +258,18 @@ static void clear_current_prefetch_free(
 	}
 }
 
+static inline unsigned long largest_lowmem_reserve(struct zone *z)
+{
+	unsigned long ret = 0;
+	unsigned int idx = zone_idx(z);
+
+	while (!is_highmem_idx(idx)) {
+		idx++;
+		ret = max(ret, z->lowmem_reserve[idx]);
+	}
+	return ret;
+}
+
 /*
  * This updates the high and low watermarks of amount of free ram in each
  * node used to start and stop prefetching. We prefetch from pages_high * 4
@@ -276,7 +288,7 @@ static void examine_free_limits(void)
 
 		ns = &sp_stat.node[z->zone_pgdat->node_id];
 		idx = zone_idx(z);
-		ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[idx];
+		ns->lowfree[idx] = z->pages_high * 3 + largest_lowmem_reserve(z);
 		ns->highfree[idx] = ns->lowfree[idx] + z->pages_high;
 
 		if (z->free_pages > ns->highfree[idx]) {
Signature · 1 line
-ck
#1 lore raw
Quoted 33 lines · Con Kolivas

When examining the free limits in swap_prefetch we should ensure the largest lowmem_reserve for each zone is free.

---
 mm/swap_prefetch.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletion(-)

Index: linux-2.6.17-rc4-mm1/mm/swap_prefetch.c
===================================================================

mm/swap_prefetch.c +12 -0
@@ -258,6 +258,18 @@ static void clear_current_prefetch_free(
 	}
 }
 
+static inline unsigned long largest_lowmem_reserve(struct zone *z)
+{
+	unsigned long ret = 0;
+	unsigned int idx = zone_idx(z);
+
+	while (!is_highmem_idx(idx)) {
+		idx++;
+		ret = max(ret, z->lowmem_reserve[idx]);
+	}
+	return ret;
+}
+
 /*
  * This updates the high and low watermarks of amount of free ram in each
  * node used to start and stop prefetching. We prefetch from pages_high * 4

mm/swap_prefetch.c static void examine_free_limits(void) · line 292

Quoted 6 lines
mm/swap_prefetch.c +1 -1
@@ -276,7 +288,7 @@ static void examine_free_limits(void)
 
 		ns = &sp_stat.node[z->zone_pgdat->node_id];
 		idx = zone_idx(z);
-		ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[idx];
+		ns->lowfree[idx] = z->pages_high * 3 + largest_lowmem_reserve(z);
 		ns->highfree[idx] = ns->lowfree[idx] + z->pages_high;

Anonymous memory is GFP_HIGHUSER, yeah? Anything wrong with

- ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[idx];
+ ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[ZONE_HIGHMEM];

Signature · 2 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 
#2 lore raw

PATCH 1/1 mm: swap prefetch fix lowmem reserve calc

Review

Quoted 4 lines · Nick Piggin

Anonymous memory is GFP_HIGHUSER, yeah? Anything wrong with

(quoted diff) +1 -1
-		ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[idx];
+		ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[ZONE_HIGHMEM];

I guess not, thanks!
---

Correct the effect lowmem_reserve has on calculation of free limits in swap_prefetch.

---
 mm/swap_prefetch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
mm/swap_prefetch.c +2 -1
Index: linux-2.6.17-rc4-mm1/mm/swap_prefetch.c
===================================================================
@@ -276,7 +276,8 @@ static void examine_free_limits(void)
 
 		ns = &sp_stat.node[z->zone_pgdat->node_id];
 		idx = zone_idx(z);
-		ns->lowfree[idx] = z->pages_high * 3 + z->lowmem_reserve[idx];
+		ns->lowfree[idx] = z->pages_high * 3 +
+			z->lowmem_reserve[ZONE_HIGHMEM];
 		ns->highfree[idx] = ns->lowfree[idx] + z->pages_high;
 
 		if (z->free_pages > ns->highfree[idx]) {
Signature · 1 line
-ck