Skip to contentSkip to conversation

vmscan: avoid set zone congested if no page dirty

PATCH In review Shaohua Li 5 participants 6 messages Nov 4, 2010 – Nov 11, 2010

Subsystems (3)
lore
Share & tools
lore

Shaohua Li

author
#0 lore raw

PATCH 1/1 vmscan: avoid set zone congested if no page dirty

nr_dirty and nr_congested are increased only when page is dirty. So if all pages are clean, both them will be zero. In this case, we should not mark the zone congested.

mm/vmscan.c +1 -1
index b8a6fdc..d31d7ce 100644
@@ -913,7 +913,7 @@ keep_lumpy:
 	 * back off and wait for congestion to clear because further reclaim
 	 * will encounter the same problem
 	 */
-	if (nr_dirty == nr_congested)
+	if (nr_dirty == nr_congested && nr_dirty != 0)
 		zone_set_flag(zone, ZONE_CONGESTED);
 
 	free_page_list(&free_pages);

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Shaohua Li

nr_dirty and nr_congested are increased only when page is dirty. So if all pages are clean, both them will be zero. In this case, we should not mark the zone congested.

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Reviewed-by on v1 1/1
#2 lore raw
In reply to Shaohua Li
Quoted 5 lines · Shaohua Li

nr_dirty and nr_congested are increased only when page is dirty. So if all pages are clean, both them will be zero. In this case, we should not mark the zone congested.

Signature · 9 lines
Kind regards,
Minchan Kim

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/1
#3 lore raw
In reply to Shaohua Li
Quoted 5 lines · Shaohua Li

nr_dirty and nr_congested are increased only when page is dirty. So if all pages are clean, both them will be zero. In this case, we should not mark the zone congested.

Quoted 16 lines
mm/vmscan.c +1 -1
index b8a6fdc..d31d7ce 100644
@@ -913,7 +913,7 @@ keep_lumpy:
 	 * back off and wait for congestion to clear because further reclaim
 	 * will encounter the same problem
 	 */
-	if (nr_dirty == nr_congested)
+	if (nr_dirty == nr_congested && nr_dirty != 0)
 		zone_set_flag(zone, ZONE_CONGESTED);
 
 	free_page_list(&free_pages);
Signature · 10 lines
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#4 lore raw
In reply to Shaohua Li
Quoted 11 lines · On Thu, 04 Nov 2010 08:50:58 +0800 Shaohua Li <[email protected]> wrote:

nr_dirty and nr_congested are increased only when page is dirty. So if all pages are clean, both them will be zero. In this case, we should not mark the zone congested.

mm/vmscan.c +0 -0
index b8a6fdc..d31d7ce 100644

mm/vmscan.c keep_lumpy: · line 919

Quoted 8 lines
mm/vmscan.c +1 -1
@@ -913,7 +913,7 @@ keep_lumpy:
 	 * back off and wait for congestion to clear because further reclaim
 	 * will encounter the same problem
 	 */
-	if (nr_dirty == nr_congested)
+	if (nr_dirty == nr_congested && nr_dirty != 0)
 		zone_set_flag(zone, ZONE_CONGESTED);
 
 	free_page_list(&free_pages);

In a way, this was a really big bug. Reclaim will set the zone as congested a *lot* - when reclaiming simple, clean pagecache. It does appear that kswapd will unset it a lot too, so the net effect isn't obvious.

However most of the time, the atomic_read(&nr_bdi_congested[sync]) in wait_iff_congested() will prevent this bug from causing harm.

btw, it's irritating that we have this asymmetry:

setter: zone_set_flag(zone, ZONE_CONGESTED)
getter: zone_is_reclaim_congested(zone)

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 21 lines · Andrew Morton
Quoted 18 lines · On Thu, 04 Nov 2010 08:50:58 +0800 Shaohua Li <[email protected]> wrote:

nr_dirty and nr_congested are increased only when page is dirty. So if all pages are clean, both them will be zero. In this case, we should not mark the zone congested.

mm/vmscan.c +1 -1
index b8a6fdc..d31d7ce 100644
@@ -913,7 +913,7 @@ keep_lumpy:
 	 * back off and wait for congestion to clear because further reclaim
 	 * will encounter the same problem
 	 */
-	if (nr_dirty == nr_congested)
+	if (nr_dirty == nr_congested && nr_dirty != 0)
 		zone_set_flag(zone, ZONE_CONGESTED);
 
Quoted 4 lines

mm/vmscan.c keep_lumpy: · line 919

Quoted 1 line
mm/vmscan.c +0 -0
 	free_page_list(&free_pages);

In a way, this was a really big bug. Reclaim will set the zone as congested a *lot* - when reclaiming simple, clean pagecache.

This is true and you're right, it was a bad mistake on my part. My test machines are tied up at the moment but I intend to run this patch through the same tests as were used to introduce wait_iff_congested to ensure nothing bad has happened.

Quoted 4 lines

It does
appear that kswapd will unset it a lot too, so the net effect isn't obvious.

The unset log is more straight-forward. The flag is cleared when the watermark is met. Granted, there might be still congestion in there but not congestion that a called of alloc_pages() should use congestion_wait() for.

Quoted 3 lines

However most of the time, the atomic_read(&nr_bdi_congested[sync]) in wait_iff_congested() will prevent this bug from causing harm.

Bit of a happy coincidence though. You'd think that if the congestion settting/clearing logic was perfect that nr_bdi_congested[] might become unnecessary.

Quoted 5 lines

btw, it's irritating that we have this asymmetry:

setter: zone_set_flag(zone, ZONE_CONGESTED)
getter: zone_is_reclaim_congested(zone)

I struggled with this. Early versions used a simple getter but I eventually decided to match functions like zone_is_reclaim_locked() and zone_is_oom_locked().

Signature · 10 lines
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>