From patchwork Tue Feb 1 00:46:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12731332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09135C433EF for ; Tue, 1 Feb 2022 00:47:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67E1B8D003B; Mon, 31 Jan 2022 19:47:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DE018D0028; Mon, 31 Jan 2022 19:47:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 344F18D003B; Mon, 31 Jan 2022 19:47:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 217638D0028 for ; Mon, 31 Jan 2022 19:47:02 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D2EA41823020C for ; Tue, 1 Feb 2022 00:47:01 +0000 (UTC) X-FDA: 79092371442.21.3ADA46D Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf12.hostedemail.com (Postfix) with ESMTP id 8DF9B40003 for ; Tue, 1 Feb 2022 00:47:01 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id m11so30531424edi.13 for ; Mon, 31 Jan 2022 16:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GYfi12SpmN0g9NqCoQ6tYL22xFi8Uo1iR/vTcnK9fck=; b=M8JyDPdDdfrEs1luJVidkqPn7+qgD4TNYcQAXFMm0RPY0nfJUSyFdHSYKBx3dzqcfJ wjDKrCKhJEa/VH4upcSnRwzq43GqdetPEPK02terNMKeobZISvpFpg+OLMKkXJIiRohZ RKqi01JwhYCy97rwRMiRDbzaxzb7rFt6NuXoaObwhZSU6MTauJT/320Lbr2K3otV2rLo Nuw4NPg3mzoRAe6gyu1kt9BqCIoF+9Xk5c/wWEfuPFviHOP6UP8XDExpwUO22re57moT 9zqp6p8fUCanOl1R2fgrr3/wsQNlHOg0JwBcUVs2xoTaxLS7VIuHmzQwu7gj1gXlEdkW cIVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GYfi12SpmN0g9NqCoQ6tYL22xFi8Uo1iR/vTcnK9fck=; b=4TYuLKNde7+O0KbIjIh8uBBk2IXoHqcEo7AU4HvI4gBI+iJe8mIyhul/WdCiYC+vyz 6Q14mF6Lm5okJuOgpoihNQnougc7c1UtYYn3qx8peXEoJtxA+9d8FqZEPkn2KZOjc6XF d4hNEolWCTZMnnl/DUW+Cm/osMK0yeFMZU1InjwOgDJ2J5J+6SfSP8lvgi4sjBH1Toof cvXZg8v1BHzMIyU2+jAPyBt6BvDr5VbUCcgz7RmCdGUhviEYuYgQShs3gxEAn5L9r3AN 3BxUxCfrxkfpCuoIpG5LzI5JJ0M6BUB5rUdbJNlZcb+toX+Ldz8BOhxOK4M3elp0oSPo Aa+Q== X-Gm-Message-State: AOAM530Othgqb9IoU7sspdETPLpm7mC/1tEkx7lPFv9vyOHAUTAlPTwo NYcPhPajmGmo7KcOn6fnJc8= X-Google-Smtp-Source: ABdhPJxlpF/0P8RQcRZyxNk3LwNbmTSQP+mAUSu26uEJPUvLBUp70MI2dhcbvJ2xJt+TjQ5nHnrtPw== X-Received: by 2002:a05:6402:228e:: with SMTP id cw14mr23041894edb.378.1643676420231; Mon, 31 Jan 2022 16:47:00 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id gv34sm13977377ejc.125.2022.01.31.16.46.59 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Jan 2022 16:46:59 -0800 (PST) From: Wei Yang To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, willy@infradead.org, songmuchun@bytedance.com, shy828301@gmail.com, surenb@google.com Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz, Wei Yang Subject: [PATCH 2/2] mm/memcg: retrieve parent memcg from css.parent Date: Tue, 1 Feb 2022 00:46:43 +0000 Message-Id: <20220201004643.8391-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220201004643.8391-1-richard.weiyang@gmail.com> References: <20220201004643.8391-1-richard.weiyang@gmail.com> X-Stat-Signature: jnw5ethge9akdw9ixj1a6jow4h4sbaj1 X-Rspam-User: nil Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=M8JyDPdD; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.50 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8DF9B40003 X-HE-Tag: 1643676421-838689 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000080, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The parent we get from page_counter is correct, while this is two different hierarchy. Let's retrieve the parent memcg from css.parent just like parent_cs(), blkcg_parent(), etc. Signed-off-by: Wei Yang Reviewed-by: Muchun Song Acked-by: Michal Hocko Reviewed-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0c5c403f4be6..12bf443f7b14 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -886,9 +886,7 @@ static inline struct mem_cgroup *lruvec_memcg(struct lruvec *lruvec) */ static inline struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg) { - if (!memcg->memory.parent) - return NULL; - return mem_cgroup_from_counter(memcg->memory.parent, memory); + return mem_cgroup_from_css(memcg->css.parent); } static inline bool mem_cgroup_is_descendant(struct mem_cgroup *memcg,