linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmstat: retrieve more accurate vmstat value
@ 2015-11-24  6:22 Joonsoo Kim
  2015-11-24 15:36 ` Christoph Lameter
  2015-11-25 12:00 ` Michal Hocko
  0 siblings, 2 replies; 16+ messages in thread
From: Joonsoo Kim @ 2015-11-24  6:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Christoph Lameter, linux-mm, Joonsoo Kim

When I tested compaction in low memory condition, I found that
my benchmark is stuck in congestion_wait() at shrink_inactive_list().
This stuck last for 1 sec and after then it can escape. More investigation
shows that it is due to stale vmstat value. vmstat is updated every 1 sec
so it is stuck for 1 sec.

I guess that it is caused by updating NR_ISOLATED_XXX. In direct
reclaim/compaction, it would isolate some pages. After some processing,
they are returned to lru or freed and NR_ISOLATED_XXX is adjusted so
it should be recover to zero. But, it would be possible that some
updatings are appiled to global but some are applied only to per cpu
variable. In this case, zone_page_state() would return stale value so
it can be stuck.

This problem can be solved by adjusting zone_page_state() with this
cpu's vmstat value. It's sub-optimal because the other task in other cpu
can be stuck due to stale vmstat value but, at least, it can solve
some usecases without adding much overhead so I think that it is worth
to doing it. With this change, I can't find any stuck in my test.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 include/linux/vmstat.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 62af0f8..7c84896 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -133,6 +133,9 @@ static inline unsigned long zone_page_state(struct zone *zone,
 {
 	long x = atomic_long_read(&zone->vm_stat[item]);
 #ifdef CONFIG_SMP
+	long diff = this_cpu_read(zone->pageset->vm_stat_diff[item]);
+
+	x += diff;
 	if (x < 0)
 		x = 0;
 #endif
-- 
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-01-28  5:08 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-24  6:22 [PATCH] mm/vmstat: retrieve more accurate vmstat value Joonsoo Kim
2015-11-24 15:36 ` Christoph Lameter
2015-11-25  2:57   ` Joonsoo Kim
2015-11-25 16:04     ` Christoph Lameter
2015-11-25 18:03       ` Michal Hocko
2015-11-25 18:26         ` Christoph Lameter
2015-11-26  1:52       ` Joonsoo Kim
2015-12-03  4:14         ` Joonsoo Kim
2016-01-27 23:13         ` David Rientjes
2016-01-28  5:08           ` Joonsoo Kim
2015-11-25 12:00 ` Michal Hocko
2015-11-25 13:43   ` Vlastimil Babka
2015-11-25 13:47     ` Michal Hocko
2015-11-26  1:56   ` Joonsoo Kim
2015-11-26  5:03     ` vinayak menon
2015-11-26 15:03     ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox