Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228AbbKXGWO (ORCPT ); Tue, 24 Nov 2015 01:22:14 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:35421 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093AbbKXGWM (ORCPT ); Tue, 24 Nov 2015 01:22:12 -0500 From: Joonsoo Kim X-Google-Original-From: Joonsoo Kim To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Christoph Lameter , linux-mm@kvack.org, Joonsoo Kim Subject: [PATCH] mm/vmstat: retrieve more accurate vmstat value Date: Tue, 24 Nov 2015 15:22:03 +0900 Message-Id: <1448346123-2699-1-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1877 Lines: 47 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 --- 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/