提交 0db2cb8d 编写于 作者: M Michal Hocko 提交者: Linus Torvalds

mm, vmscan: make zone_reclaimable_pages more precise

zone_reclaimable_pages() is used in should_reclaim_retry() which uses it
to calculate the target for the watermark check.  This means that
precise numbers are important for the correct decision.
zone_reclaimable_pages uses zone_page_state which can contain stale data
with per-cpu diffs not synced yet (the last vmstat_update might have run
1s in the past).

Use zone_page_state_snapshot() in zone_reclaimable_pages() instead.
None of the current callers is in a hot path where getting the precise
value (which involves per-cpu iteration) would cause an unreasonable
overhead.
Signed-off-by: NMichal Hocko <mhocko@suse.com>
Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Suggested-by: NDavid Rientjes <rientjes@google.com>
Acked-by: NDavid Rientjes <rientjes@google.com>
Acked-by: NHillf Danton <hillf.zj@alibaba-inc.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d7206a70
...@@ -195,21 +195,21 @@ static unsigned long zone_reclaimable_pages(struct zone *zone) ...@@ -195,21 +195,21 @@ static unsigned long zone_reclaimable_pages(struct zone *zone)
{ {
unsigned long nr; unsigned long nr;
nr = zone_page_state(zone, NR_ACTIVE_FILE) + nr = zone_page_state_snapshot(zone, NR_ACTIVE_FILE) +
zone_page_state(zone, NR_INACTIVE_FILE) + zone_page_state_snapshot(zone, NR_INACTIVE_FILE) +
zone_page_state(zone, NR_ISOLATED_FILE); zone_page_state_snapshot(zone, NR_ISOLATED_FILE);
if (get_nr_swap_pages() > 0) if (get_nr_swap_pages() > 0)
nr += zone_page_state(zone, NR_ACTIVE_ANON) + nr += zone_page_state_snapshot(zone, NR_ACTIVE_ANON) +
zone_page_state(zone, NR_INACTIVE_ANON) + zone_page_state_snapshot(zone, NR_INACTIVE_ANON) +
zone_page_state(zone, NR_ISOLATED_ANON); zone_page_state_snapshot(zone, NR_ISOLATED_ANON);
return nr; return nr;
} }
bool zone_reclaimable(struct zone *zone) bool zone_reclaimable(struct zone *zone)
{ {
return zone_page_state(zone, NR_PAGES_SCANNED) < return zone_page_state_snapshot(zone, NR_PAGES_SCANNED) <
zone_reclaimable_pages(zone) * 6; zone_reclaimable_pages(zone) * 6;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册