Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4601415ybv; Mon, 10 Feb 2020 23:26:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyBcNsdAcf2O4QRpYGVdZRvfOx48Nf0RRl7CtnB3sUamWnrLgR3amGlj42vM7nYvyYkf2Np X-Received: by 2002:a05:6830:610:: with SMTP id w16mr4247847oti.239.1581406004141; Mon, 10 Feb 2020 23:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581406004; cv=none; d=google.com; s=arc-20160816; b=jTQyF4htvjm8WnaAE2ZFRAoSNcdtMtMb9MfCPJv5uGI4l8vrMEHOHzrZ5hG30o6KYn RrmyVMmhpvq6SDcGavIxBPS1bUBMfkbeeKoVe/PhGgUjsT+VDL1SUGFCid7GAOV5wjl2 vNo8NGllY0tLwkVWJ2tanLWnfcXzUr9Ena9IViRsCQvcJRE/s3vg30cT0TiYbQxgyUqC RZnMjp0cn5as94aBd3NP3rmF4vPTBT3HtEM0/mkUsUNNBtDHWGTWJRuVpsM5KxAy4kBa F01PwjhHjhqb/chWvWQFGN2L93Pe9zTWEUb47q8wWnbbpiKW8ALwLTjmZpSRQzuhq5qb 0qEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=460wxLtmI3ryLyEB72gt4NohfkSkdpIrWM1CKB3DHkA=; b=fVRFcc8sizAoLGnBT8KmyVJyOZYG3Hbt7oed3C1SxJyvFy+hkwTvDoDwYz3GAQ9pxS Ch16+DS1GVVUNE8Bd3Z0AO5I7ovtMsh1QYVn2eFJ+mdInzYUsj28+ZyeyDKkyQI1oV5w /f8VRWgZS3cPP7tMcXKNnB8PfNa8Q8avRtS/aNPkdfFu7GrDusFv/okk+LjDXe6bg7mq Yd4mqBPE8iOi6+OQDJ7N0ysBs+4K1ICCn+eqkWjsattn9wZ1bwB/Xg3OypKbChn1v4TE W6KQ7o60rYbHqMAmozkW3UMQYzWBiKRKTrrIks2ny6yWO9Q5caqUutIImtXG8j6787Ja 27OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DSS0geKj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si1451458oif.92.2020.02.10.23.26.32; Mon, 10 Feb 2020 23:26:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DSS0geKj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbgBKGU3 (ORCPT + 99 others); Tue, 11 Feb 2020 01:20:29 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42605 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728290AbgBKGU1 (ORCPT ); Tue, 11 Feb 2020 01:20:27 -0500 Received: by mail-pf1-f194.google.com with SMTP id 4so4949928pfz.9 for ; Mon, 10 Feb 2020 22:20:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=460wxLtmI3ryLyEB72gt4NohfkSkdpIrWM1CKB3DHkA=; b=DSS0geKjBvmmPD4/kQwA8is8vXGeoq3qm8aAQKoYT340gjoRm+GbH0B6oaUzmWq0Tl zdAQjI0Sfa4yclVNnvBJolDNAlcpXIYuXFBJYYbcoYvndL5gmmoZjak8fzn2iOdnAiZJ D9FtGyOfilb7hubOaxzyMmpOVe1zuiIudY55+dR0WmxfX0dqilmw1zhmRqCQUxW5/4xo /xGGFzwCA3dq/IvGC2c0i/Ahqg7sJNNyX+keJjR3Q4/hVuBsgt9UEZj6xBRmZAgXE4Lj ebbyjtfbft3xxZ8lFaiXZLybmgSAB4aliromL7TwYm9Q3zD0109vDdqpx80O7X7PAc8G oN3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=460wxLtmI3ryLyEB72gt4NohfkSkdpIrWM1CKB3DHkA=; b=IxQJJHAZxPW33xsgQlXZKJk4wdVhX2JwyUwK1PR+wCK15qbzMUL+Yak/KuvFL/7er6 FffzBmOqMzCWTVsyBiWg0JC8vW7ojXlUrOLoB/jAuh6OZSELWHa4OIQGSu+ftQuNftCq BfEMWD9pfwNIrNRgiv0XI9jCo9xKSu4db6nM3+IOTJY1paXKJ14grDb/6PlQj84Bqr7H JUI2N7UaBsHXtHnLUlysewkcNPhIKMWOg/SBvyioPaWue1nHZm85ztxZpzZrgAMepmuK Xq7ZHxggePLTztdnwSIMqofli4ixcm/Ir6lAgMRrVWNaR5Bs6BSYVNM1r3RnVqsVUVcD QSwg== X-Gm-Message-State: APjAAAUwQR83z0e5+feT/sDmd/G0KmamzOO5rTVAceXZfX+KJN5YX5Fd Cw/y3ypn/kpyLVzTYYF/fBY= X-Received: by 2002:a63:7457:: with SMTP id e23mr5451770pgn.386.1581402025451; Mon, 10 Feb 2020 22:20:25 -0800 (PST) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id x197sm2578696pfc.1.2020.02.10.22.20.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Feb 2020 22:20:25 -0800 (PST) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Hugh Dickins , Minchan Kim , Vlastimil Babka , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Subject: [PATCH 5/9] mm/workingset: use the node counter if memcg is the root memcg Date: Tue, 11 Feb 2020 15:19:49 +0900 Message-Id: <1581401993-20041-6-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1581401993-20041-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1581401993-20041-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonsoo Kim In the following patch, workingset detection is implemented for the swap cache. Swap cache's node is usually allocated by kswapd and it isn't charged by kmemcg since it is from the kernel thread. So the swap cache's shadow node is managed by the node list of the list_lru rather than the memcg specific one. If counting the shadow node on the root memcg happens to reclaim the slab object, the shadow node count returns the number of the shadow node on the node list of the list_lru since root memcg has the kmem_cache_id, -1. However, the size of pages on the LRU is calculated by using the specific memcg, so mismatch happens. This causes the number of shadow node not to be increased to the enough size and, therefore, workingset detection cannot work correctly. This patch fixes this bug by checking if the memcg is the root memcg or not. If it is the root memcg, instead of using the memcg-specific LRU, the system-wide LRU is used to calculate proper size of the shadow node so that the number of the shadow node can grow as expected. Signed-off-by: Joonsoo Kim --- mm/workingset.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/workingset.c b/mm/workingset.c index d04f70a..636aafc 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -468,7 +468,13 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, * PAGE_SIZE / xa_nodes / node_entries * 8 / PAGE_SIZE */ #ifdef CONFIG_MEMCG - if (sc->memcg) { + /* + * Kernel allocation on root memcg isn't regarded as allocation of + * specific memcg. So, if sc->memcg is the root memcg, we need to + * use the count for the node rather than one for the specific + * memcg. + */ + if (sc->memcg && !mem_cgroup_is_root(sc->memcg)) { struct lruvec *lruvec; int i; -- 2.7.4