From patchwork Tue Oct 27 08:02:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11859635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EE7B6A2 for ; Tue, 27 Oct 2020 08:03:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DADA021D24 for ; Tue, 27 Oct 2020 08:03:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="PJog1NMt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DADA021D24 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0F9C16B0070; Tue, 27 Oct 2020 04:03:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D0266B0071; Tue, 27 Oct 2020 04:03:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F03C16B0072; Tue, 27 Oct 2020 04:03:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id C18C36B0070 for ; Tue, 27 Oct 2020 04:03:48 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 604FB8249980 for ; Tue, 27 Oct 2020 08:03:48 +0000 (UTC) X-FDA: 77416966536.20.joke13_3b17e452727a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 39EC2180C07A3 for ; Tue, 27 Oct 2020 08:03:48 +0000 (UTC) X-Spam-Summary: 1,0,0,60d471ac2f5c77ba,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2895:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:3872:4321:4385:5007:6261:6653:6737:8603:10004:11026:11473:11658:11914:12048:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13161:13229:13311:13357:13894:14096:14181:14384:14394:14721:21080:21444:21451:21627:21740:30054:30070,0,RBL:209.85.214.194:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04ygkoqq73zbb11z7e3xqoeirueimocdr1qf13tsaqupjf99h7rh85433diacgg.8t118q1qw3ktrnruzywh1puc6tjsuzhwzkttb5fh5tsmtwdibz9c1m7fpcgka54.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: joke13_3b17e452727a X-Filterd-Recvd-Size: 4703 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 08:03:47 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id x10so327218plm.13 for ; Tue, 27 Oct 2020 01:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LN3286O1QAMAK+WN2hg/G+SRa6WlZWbQzoibyYb4wWo=; b=PJog1NMte5d9AcJQ2N25yRGouMltF5NBzhqBTv5dYQmj59PEpXsswhsrU0LQ+VWVfn aLdhc9z+7+C3pAXFkSsi/4lSgs4MYKwF7uVxVl+NsaEQOQzS04XB6RLzkTkl9RkPB0Oq SkIb23JF1hsg16qTRBKdvWjTQabtx+3Q9R5e4k+VNRf43+TfAiWbkEICxD3t3+7NB7p7 L8yLqDncE2eSZPNsDjZSHXJ2Wv2O3UCu1Gk29TEbivdr3CCZBt8Zstueo74xQ/0viaBY EDV9Pv6BY3iPIabSdepfkGEm9H2JQlMqBjsX0yyAsdIyNWdN466cnPESkPb7kZHS7hKf LJSQ== 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:mime-version:content-transfer-encoding; bh=LN3286O1QAMAK+WN2hg/G+SRa6WlZWbQzoibyYb4wWo=; b=HGUc7xKyIk4RSz/3ZlT709YE+jgGzBxRVssVXiS0Xu4a2ArEF7kff/VRwLFkX1J8s9 9mFdLwxSY2f1BmM8orgKApo++f1KrSF1zXe2Fx7GhTIlVWukcktgF/ZsiyuufA0CdfGZ wiPWB6c+rUCJ4KljkBqMVQ1RHRDoVRax1JbEP1ks0oMGva17T//zRy34JrElW7FpZfDC 52zO5VxSCMX399CRPSkPYQ7bcJ5KwbXGB0F9SKq9SGP8zJG7PKqzxQ2v2mJMaHHDUuw4 4BsxEr7luMlGbZXX1QdASsuLFrPUsMyLyk4snAaWkDTfC/xNDKKQKeYC+VOGw8zyxn8C uyLQ== X-Gm-Message-State: AOAM530HyQmP63qbN8eY+lcUZeiUDooTZ78h87L6x5/uMAM2UzAEdBgk BK94voXZwfbxS5sEKlROuJU24w== X-Google-Smtp-Source: ABdhPJy+4tj9XYz/K9k/YpdyvUdWeb1R34jmZQ+GTNvy94neoHvWyQPy95s/Z5NTlj+jeS4gGAA20g== X-Received: by 2002:a17:90a:9a1:: with SMTP id 30mr971273pjo.85.1603785826642; Tue, 27 Oct 2020 01:03:46 -0700 (PDT) Received: from Smcdef-MBP.local.net ([103.136.220.89]) by smtp.gmail.com with ESMTPSA id p8sm1039580pgs.34.2020.10.27.01.03.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2020 01:03:46 -0700 (PDT) From: Muchun Song To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, iamjoonsoo.kim@lge.com, laoar.shao@gmail.com, chris@chrisdown.name, christian.brauner@ubuntu.com, peterz@infradead.org, mingo@kernel.org, keescook@chromium.org, tglx@linutronix.de, esyr@redhat.com, surenb@google.com, areber@redhat.com, elver@google.com Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Muchun Song Subject: [PATCH 4/5] mm: memcg/slab: Fix root memcg vmstats Date: Tue, 27 Oct 2020 16:02:55 +0800 Message-Id: <20201027080256.76497-5-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201027080256.76497-1-songmuchun@bytedance.com> References: <20201027080256.76497-1-songmuchun@bytedance.com> MIME-Version: 1.0 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: If we reparent the slab objects to the root memcg, when we free the slab object, we need to update the per-memcg vmstats to keep it correct for the root memcg. Now this at least affects the vmstat of NR_KERNEL_STACK_KB for !CONFIG_VMAP_STACK when the thread stack size is smaller than the PAGE_SIZE. Fixes: ec9f02384f60 ("mm: workingset: fix vmstat counters for shadow nodes") Signed-off-by: Muchun Song Acked-by: Roman Gushchin --- mm/memcontrol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 22b4fb941b54..70345b15b150 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -875,8 +875,13 @@ void __mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val) rcu_read_lock(); memcg = mem_cgroup_from_obj(p); - /* Untracked pages have no memcg, no lruvec. Update only the node */ - if (!memcg || memcg == root_mem_cgroup) { + /* + * Untracked pages have no memcg, no lruvec. Update only the + * node. If we reparent the slab objects to the root memcg, + * when we free the slab object, we need to update the per-memcg + * vmstats to keep it correct for the root memcg. + */ + if (!memcg) { __mod_node_page_state(pgdat, idx, val); } else { lruvec = mem_cgroup_lruvec(memcg, pgdat);