Skip to contentSkip to conversation

Follow-up fixes to node-lru series v1

PATCH In review Mel Gorman 4 participants 12 messages Jul 13, 2016 – Jul 14, 2016

Subsystems (6)
lore
Share & tools
lore

Mel Gorman

author
#0 lore raw

cover Follow-up fixes to node-lru series v1

These are some follow-up fixes to the node-lru series based on feedback from Johannes and Minchan.

 include/linux/vm_event_item.h |  2 +-
 mm/page-writeback.c           | 16 ++++++++++------
 mm/vmscan.c                   | 15 ++++++++-------
 mm/vmstat.c                   |  2 +-
 4 files changed, 20 insertions(+), 15 deletions(-)
Signature · 7 lines
2.6.4

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#1 lore raw

PATCH 1/4 mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit -fix

Johannes reported that the comment about buffer_heads_over_limit in balance_pgdat only made sense in the context of the patch. This patch clarifies the reasoning and how it applies to 32 and 64 bit systems.

This is a fix to the mmotm patch mm-vmscan-have-kswapd-reclaim-from-all-zones-if-reclaiming-and-buffer_heads_over_limit.patch

---
 mm/vmscan.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
mm/vmscan.c +7 -6
index d079210d46ee..21eae17ee730 100644
@@ -3131,12 +3131,13 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
 
 		/*
 		 * If the number of buffer_heads exceeds the maximum allowed
-		 * then consider reclaiming from all zones. This is not
-		 * specific to highmem which may not exist but it is it is
-		 * expected that buffer_heads are stripped in writeback.
-		 * Reclaim may still not go ahead if all eligible zones
-		 * for the original allocation request are balanced to
-		 * avoid excessive reclaim from kswapd.
+		 * then consider reclaiming from all zones. This has a dual
+		 * purpose -- on 64-bit systems it is expected that
+		 * buffer_heads are stripped during active rotation. On 32-bit
+		 * systems, highmem pages can pin lowmem memory and shrinking
+		 * buffers can relieve lowmem pressure. Reclaim may still not
+		 * go ahead if all eligible zones for the original allocation
+		 * request are balanced to avoid excessive reclaim from kswapd.
 		 */
 		if (buffer_heads_over_limit) {
 			for (i = MAX_NR_ZONES - 1; i >= 0; i--) {
Signature · 7 lines
2.6.4

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#4 lore raw

PATCH 2/4 mm: vmstat: account per-zone stalls and pages skipped during reclaim -fix

In reply to Mel Gorman

As pointed out by Johannes -- the PG prefix seems to stand for page, and all stat names that contain it represent some per-page event. PGSTALL is not a page event. This patch renames it.

This is a fix for the mmotm patch mm-vmstat-account-per-zone-stalls-and-pages-skipped-during-reclaim.patch

---
 include/linux/vm_event_item.h | 2 +-
 mm/vmscan.c                   | 2 +-
 mm/vmstat.c                   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/vm_event_item.h +1 -1
index 6d47f66f0e9c..4d6ec58a8d45 100644
@@ -23,7 +23,7 @@
 
 enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		FOR_ALL_ZONES(PGALLOC),
-		FOR_ALL_ZONES(PGSTALL),
+		FOR_ALL_ZONES(ALLOCSTALL),
 		FOR_ALL_ZONES(PGSCAN_SKIP),
 		PGFREE, PGACTIVATE, PGDEACTIVATE,
 		PGFAULT, PGMAJFAULT,
mm/vmscan.c +1 -1
index 21eae17ee730..429bf3a9c06c 100644
@@ -2674,7 +2674,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
 	delayacct_freepages_start();
 
 	if (global_reclaim(sc))
-		__count_zid_vm_events(PGSTALL, sc->reclaim_idx, 1);
+		__count_zid_vm_events(ALLOCSTALL, sc->reclaim_idx, 1);
 
 	do {
 		vmpressure_prio(sc->gfp_mask, sc->target_mem_cgroup,
mm/vmstat.c +1 -1
index 7415775faf08..91ecca96dcae 100644
@@ -980,7 +980,7 @@ const char * const vmstat_text[] = {
 	"pswpout",
 
 	TEXTS_FOR_ZONES("pgalloc")
-	TEXTS_FOR_ZONES("pgstall")
+	TEXTS_FOR_ZONES("allocstall")
 	TEXTS_FOR_ZONES("pgskip")
 
 	"pgfree",
Signature · 7 lines
2.6.4

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#7 lore raw

PATCH 3/4 mm, page_alloc: fix dirtyable highmem calculation

In reply to Mel Gorman

From: Minchan Kim <[email protected]>

Note from Mel: This may optionally be considered a fix to the mmotm patch
mm-page_alloc-consider-dirtyable-memory-in-terms-of-nodes.patch but if so, please preserve credit for Minchan.

When I tested vmscale in mmtest in 32bit, I found the benchmark was slow down 0.5 times.

base node
1 global-1
User 12.98 16.04
System 147.61 166.42
Elapsed 26.48 38.08

With vmstat, I found IO wait avg is much increased compared to base.

The reason was highmem_dirtyable_memory accumulates free pages and highmem_file_pages from HIGHMEM to MOVABLE zones which was wrong. With that, dirth_thresh in throtlle_vm_write is always 0 so that it calls congestion_wait frequently if writeback starts.

With this patch, it is much recovered.

base node fi
1 global-1 fix
User 12.98 16.04 13.78
System 147.61 166.42 143.92
Elapsed 26.48 38.08 29.64

---
 mm/page-writeback.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
mm/page-writeback.c +10 -6
index 0bca2376bd42..7b41d1290783 100644
@@ -307,27 +307,31 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
 {
 #ifdef CONFIG_HIGHMEM
 	int node;
-	unsigned long x = 0;
+	unsigned long x;
 	int i;
-	unsigned long dirtyable = atomic_read(&highmem_file_pages);
+	unsigned long dirtyable = 0;
 
 	for_each_node_state(node, N_HIGH_MEMORY) {
 		for (i = ZONE_NORMAL + 1; i < MAX_NR_ZONES; i++) {
 			struct zone *z;
+			unsigned long nr_pages;
 
 			if (!is_highmem_idx(i))
 				continue;
 
 			z = &NODE_DATA(node)->node_zones[i];
-			dirtyable += zone_page_state(z, NR_FREE_PAGES);
+			if (!populated_zone(z))
+				continue;
 
+			nr_pages = zone_page_state(z, NR_FREE_PAGES);
 			/* watch for underflows */
-			dirtyable -= min(dirtyable, high_wmark_pages(z));
-
-			x += dirtyable;
+			nr_pages -= min(nr_pages, high_wmark_pages(z));
+			dirtyable += nr_pages;
 		}
 	}
 
+	x = dirtyable + atomic_read(&highmem_file_pages);
+
 	/*
 	 * Unreclaimable memory (kernel memory or anonymous memory
 	 * without swap) can bring down the dirtyable pages below
Signature · 7 lines
2.6.4

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#10 lore raw

PATCH 4/4 mm: move most file-based accounting to the node -fix

In reply to Mel Gorman

As noted by Johannes Weiner, NR_ZONE_WRITE_PENDING gets decremented twice during migration instead of a dec(old) -> inc(new) cycle as intended.

This is a fix to mmotm patch mm-move-most-file-based-accounting-to-the-node.patch

Note that it'll cause a conflict with mm-vmstat-remove-zone-and-node-double-accounting-by-approximating-retries.patch but that the resolution is trivial.

---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
index c77997dc6ed7..ed0268268e93 100644
@@ -515,7 +515,7 @@ int migrate_page_move_mapping(struct address_space *mapping,
 			__dec_node_state(oldzone->zone_pgdat, NR_FILE_DIRTY);
 			__dec_zone_state(oldzone, NR_ZONE_WRITE_PENDING);
 			__inc_node_state(newzone->zone_pgdat, NR_FILE_DIRTY);
-			__dec_zone_state(newzone, NR_ZONE_WRITE_PENDING);
+			__inc_zone_state(newzone, NR_ZONE_WRITE_PENDING);
 		}
 	}
 	local_irq_enable();
Signature · 7 lines
2.6.4

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit -fix

In reply to Mel Gorman
Quoted 9 lines · Mel Gorman

Johannes reported that the comment about buffer_heads_over_limit in balance_pgdat only made sense in the context of the patch. This patch clarifies the reasoning and how it applies to 32 and 64 bit systems.

This is a fix to the mmotm patch mm-vmscan-have-kswapd-reclaim-from-all-zones-if-reclaiming-and-buffer_heads_over_limit.patch

This is a great comment now, thank you.

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer Acked-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] mm: vmstat: account per-zone stalls and pages skipped during reclaim -fix

In reply to Mel Gorman
Quoted 8 lines · Mel Gorman

As pointed out by Johannes -- the PG prefix seems to stand for page, and all stat names that contain it represent some per-page event. PGSTALL is not a page event. This patch renames it.

This is a fix for the mmotm patch mm-vmstat-account-per-zone-stalls-and-pages-skipped-during-reclaim.patch

Thanks

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer Acked-by on v1 3/4
#8 lore raw

Re: [PATCH 3/4] mm, page_alloc: fix dirtyable highmem calculation

In reply to Mel Gorman
Quoted 24 lines · Mel Gorman

From: Minchan Kim <[email protected]>

Note from Mel: This may optionally be considered a fix to the mmotm patch
mm-page_alloc-consider-dirtyable-memory-in-terms-of-nodes.patch but if so, please preserve credit for Minchan.

When I tested vmscale in mmtest in 32bit, I found the benchmark was slow down 0.5 times.

base node
1 global-1
User 12.98 16.04
System 147.61 166.42
Elapsed 26.48 38.08

With vmstat, I found IO wait avg is much increased compared to base.

The reason was highmem_dirtyable_memory accumulates free pages and highmem_file_pages from HIGHMEM to MOVABLE zones which was wrong. With that, dirth_thresh in throtlle_vm_write is always 0 so that it calls congestion_wait frequently if writeback starts.

With this patch, it is much recovered.

Quoted 8 lines

base node fi
1 global-1 fix
User 12.98 16.04 13.78
System 147.61 166.42 143.92
Elapsed 26.48 38.08 29.64

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer Acked-by on v1 4/4
#11 lore raw

Re: [PATCH 4/4] mm: move most file-based accounting to the node -fix

In reply to Mel Gorman
Quoted 11 lines · Mel Gorman

As noted by Johannes Weiner, NR_ZONE_WRITE_PENDING gets decremented twice during migration instead of a dec(old) -> inc(new) cycle as intended.

This is a fix to mmotm patch mm-move-most-file-based-accounting-to-the-node.patch

Note that it'll cause a conflict with mm-vmstat-remove-zone-and-node-double-accounting-by-approximating-retries.patch but that the resolution is trivial.

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

Re: [PATCH 1/4] mm, vmscan: Have kswapd reclaim from all zones if reclaiming and buffer_heads_over_limit -fix

In reply to Mel Gorman
Quoted 22 lines · Mel Gorman

Johannes reported that the comment about buffer_heads_over_limit in balance_pgdat only made sense in the context of the patch. This patch clarifies the reasoning and how it applies to 32 and 64 bit systems.

This is a fix to the mmotm patch mm-vmscan-have-kswapd-reclaim-from-all-zones-if-reclaiming-and-buffer_heads_over_limit.patch

---
 mm/vmscan.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
mm/vmscan.c +0 -1
index d079210d46ee..21eae17ee730 100644
@@ -3131,12 +3131,13 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
 
 		/*
 		 * If the number of buffer_heads exceeds the maximum allowed
-		 * then consider reclaiming from all zones. This is not

mm/vmscan.c static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx) · line 3138

Quoted 10 lines
mm/vmscan.c +5 -5
-		 * specific to highmem which may not exist but it is it is
-		 * expected that buffer_heads are stripped in writeback.
-		 * Reclaim may still not go ahead if all eligible zones
-		 * for the original allocation request are balanced to
-		 * avoid excessive reclaim from kswapd.
+		 * then consider reclaiming from all zones. This has a dual
+		 * purpose -- on 64-bit systems it is expected that
+		 * buffer_heads are stripped during active rotation. On 32-bit
+		 * systems, highmem pages can pin lowmem memory and shrinking
+		 * buffers can relieve lowmem pressure. Reclaim may still not

It's good but I hope we can make it more clear.

On 32-bit systems, highmem pages can pin lowmem pages storing buffer_heads so shrinking highmem pages can relieve lowmem pressure.

If you don't think it's much readable compared to yours, feel free to drop.

Thanks.

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 2/4
#6 lore raw

Re: [PATCH 2/4] mm: vmstat: account per-zone stalls and pages skipped during reclaim -fix

In reply to Mel Gorman
Quoted 8 lines · Mel Gorman

As pointed out by Johannes -- the PG prefix seems to stand for page, and all stat names that contain it represent some per-page event. PGSTALL is not a page event. This patch renames it.

This is a fix for the mmotm patch mm-vmstat-account-per-zone-stalls-and-pages-skipped-during-reclaim.patch

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 3/4
#9 lore raw

Re: [PATCH 3/4] mm, page_alloc: fix dirtyable highmem calculation

In reply to Mel Gorman
Quoted 24 lines · Mel Gorman

From: Minchan Kim <[email protected]>

Note from Mel: This may optionally be considered a fix to the mmotm patch
mm-page_alloc-consider-dirtyable-memory-in-terms-of-nodes.patch but if so, please preserve credit for Minchan.

When I tested vmscale in mmtest in 32bit, I found the benchmark was slow down 0.5 times.

base node
1 global-1
User 12.98 16.04
System 147.61 166.42
Elapsed 26.48 38.08

With vmstat, I found IO wait avg is much increased compared to base.

The reason was highmem_dirtyable_memory accumulates free pages and highmem_file_pages from HIGHMEM to MOVABLE zones which was wrong. With that, dirth_thresh in throtlle_vm_write is always 0 so that it calls congestion_wait frequently if writeback starts.

With this patch, it is much recovered.

Quoted 8 lines

base node fi
1 global-1 fix
User 12.98 16.04 13.78
System 147.61 166.42 143.92
Elapsed 26.48 38.08 29.64

Just some nitpicks:

Quoted 9 lines
---
 mm/page-writeback.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
mm/page-writeback.c +0 -0
index 0bca2376bd42..7b41d1290783 100644

mm/page-writeback.c static unsigned long highmem_dirtyable_memory(unsigned long total) · line 312

Quoted 8 lines
mm/page-writeback.c +2 -2
@@ -307,27 +307,31 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
 {
 #ifdef CONFIG_HIGHMEM
 	int node;
-	unsigned long x = 0;
+	unsigned long x;
 	int i;
-	unsigned long dirtyable = atomic_read(&highmem_file_pages);
+	unsigned long dirtyable = 0;

This wasn't necessary?

Quoted 15 lines
mm/page-writeback.c +4 -1
 	for_each_node_state(node, N_HIGH_MEMORY) {
 		for (i = ZONE_NORMAL + 1; i < MAX_NR_ZONES; i++) {
 			struct zone *z;
+			unsigned long nr_pages;
 
 			if (!is_highmem_idx(i))
 				continue;
 
 			z = &NODE_DATA(node)->node_zones[i];
-			dirtyable += zone_page_state(z, NR_FREE_PAGES);
+			if (!populated_zone(z))
+				continue;
 
+			nr_pages = zone_page_state(z, NR_FREE_PAGES);

mm/page-writeback.c static unsigned long highmem_dirtyable_memory(unsigned long total) · line 333

Quoted 10 lines
mm/page-writeback.c +3 -3
 			/* watch for underflows */
-			dirtyable -= min(dirtyable, high_wmark_pages(z));
-
-			x += dirtyable;
+			nr_pages -= min(nr_pages, high_wmark_pages(z));
+			dirtyable += nr_pages;
 		}
 	}
 
+	x = dirtyable + atomic_read(&highmem_file_pages);

And then this addition wouldn't be necessary. BTW I think we could also ditch the "x" variable and just use the "dirtyable" for the rest of the function.

mm/page-writeback.c static unsigned long highmem_dirtyable_memory(unsigned long total)

Quoted 5 lines
mm/page-writeback.c +1 -0
+
 	/*
 	 * Unreclaimable memory (kernel memory or anonymous memory
 	 * without swap) can bring down the dirtyable pages below
 

--
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-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>