From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6CFDC11D81 for ; Thu, 20 Feb 2020 05:12:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 81A0324654 for ; Thu, 20 Feb 2020 05:12:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SNXlrIU9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81A0324654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DDCAA6B000E; Thu, 20 Feb 2020 00:12:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D90896B0010; Thu, 20 Feb 2020 00:12:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C591C6B0032; Thu, 20 Feb 2020 00:12:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id A781D6B000E for ; Thu, 20 Feb 2020 00:12:20 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7308D180AD80F for ; Thu, 20 Feb 2020 05:12:20 +0000 (UTC) X-FDA: 76509334440.26.joke82_4e9666e335224 X-HE-Tag: joke82_4e9666e335224 X-Filterd-Recvd-Size: 5017 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 05:12:19 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id y30so1290291pga.13 for ; Wed, 19 Feb 2020 21:12:19 -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=9wb/P3LPDlbugq1CDyVA5kSUSv6vOvUhfJXNTDD+0wY=; b=SNXlrIU9vBkpDfdPdssBSOmNPnkkuPS8e9u8DKOKxgUG2zjLVLmiawotnQ7HGxuBvp TtmFtfHu9I5EAyoS14CaZ1dEJe/YpiXVccQYzt/ombDO0lbXOesSmoybJcyQwQWH1+yi qYCh8vavpMm6H6Wt6RLSv4ImGte9dPS5TZfryLqP6SFK/9wnlhYyf81sChx4KqTyGnDP Wq2ctFI2eUql1q0CGLCgYPytPx1kosaKCW3mFFybgRqfflwuAojiY860V+C4p+vQ9Mji 1CSnkGQtP78B77oscphEFESc+dR4BpUJuVmgD7MNkYkSN331A0bDPIf0N0e8U8PCQuT8 iy6w== 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=9wb/P3LPDlbugq1CDyVA5kSUSv6vOvUhfJXNTDD+0wY=; b=ugI1CRZm//RqYMbFgy4awGVm1NgW6BMMKdQX0y1IxQPcDfSWQJPLYUMt6hQ/rJqRhQ 1LriG/5tvaMGS0bg4k8DoKmW7P7LS8IhrKkG/73quKfXlnE17mYnIyYfWzuZI2l8rAIW +lQzyNxMFG9eIs8aXAtLDcKqaA8zq0Ia0kuwJFmgNyPEDa06kYfi+5DsEcFJufUzPjXN L/C0E77za4PPkjXWdy9uDpdHLkq2uDGr8AgLh8OA65nRq0e5knCme1QhzCSu2jNbMg7X TQpYCcYsCGryHvQRM1SicZxb5AWA3PQC4o822PIbJWn7zz7GvstfhE2/stg4Tgek6j11 2ZxA== X-Gm-Message-State: APjAAAVmo664Elz0YdibQ8MaRCjP6FHps1SitlWforYnOW6fc7TdcgtH OEsR41fRuS5tUU6Mu+6PZGs= X-Google-Smtp-Source: APXvYqxGhH1XvgsCzvYlxhVrJSu1Cx/AEALUQCK1x+DR5+5e9wZy+smGUonK+C39lOt0K325+K/Rjg== X-Received: by 2002:a62:1cd6:: with SMTP id c205mr30226967pfc.179.1582175538873; Wed, 19 Feb 2020 21:12:18 -0800 (PST) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id t15sm1472599pgr.60.2020.02.19.21.12.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Feb 2020 21:12:18 -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 v2 5/9] mm/workingset: use the node counter if memcg is the root memcg Date: Thu, 20 Feb 2020 14:11:49 +0900 Message-Id: <1582175513-22601-6-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582175513-22601-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1582175513-22601-1-git-send-email-iamjoonsoo.kim@lge.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 5fb8f85..a9f474a 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