From patchwork Tue Jan 11 01:03:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12709358 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 6AE5FC433EF for ; Tue, 11 Jan 2022 01:03:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30FF06B0074; Mon, 10 Jan 2022 20:03:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D3456B0075; Mon, 10 Jan 2022 20:03:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3FFB6B0078; Mon, 10 Jan 2022 20:03:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id DDFA26B0074 for ; Mon, 10 Jan 2022 20:03:07 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 997E7181F6CBC for ; Tue, 11 Jan 2022 01:03:07 +0000 (UTC) X-FDA: 79016207214.20.CC1BC85 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf13.hostedemail.com (Postfix) with ESMTP id 42C7420002 for ; Tue, 11 Jan 2022 01:03:07 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id u21so38195257edd.5 for ; Mon, 10 Jan 2022 17:03:07 -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=Jn9HpCa6G4upWAzqy9L2iSMpMRASsTNp9iLWrRF7M4U=; b=KnHpqKaf4bNL9UoWb2i9eRaXV2Ftcl/MbpDJtelOe1wEeOH/D/nh89jJcbfwg4oH+0 g2jPXX1T8MpZTmQ+tmWaj4HEEwm7x/rHOWOaM0l6jzdQtSYxHnlmJB+jPT3xio5EKIYk Y8YjJ54LxCRf/YrbmV5yZCMFyTWDsgKF4NYUg80ytXHbjc0jcmwcHVL5ozQbucW9qL0e qLXgAMlMTlo5mVmPryAwe5Nfw1KcbnY0mJrlJZbjm7z1KrdVcxVMIIrqwh0WbS9A5ZPm NFyEUea7SjrAU4JkCZ750sDihBugarUnqrZ7t4MPy4XyWTzkw6sARu7MPD/1eaziPnfI 7bBQ== 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=Jn9HpCa6G4upWAzqy9L2iSMpMRASsTNp9iLWrRF7M4U=; b=lkphF/eSbGXgwPApMeQ4UhZk5t9+RgoIZfmEDeLaO3HHOvGo2ds5RqwvWOZ4NNewQ+ VdFX82iorkhenuqzpqUVOA9Bh1GBH0USUtO6Le1HU8/EFWXf1IGoQ5YljAwpcVwzuU+f 8S+krbUV6WJih+YZWQcNjKerY8v0QSkrtRsiPbGLmNGdH0/KM76yHFVknq+yYEIGezWa Ssp+lkW2Js/PfAmw4AJfvHXde6aLBiVKXrcCSjfE7JM1biCtoqrCNJtynk/BEc6FsDed 5PprAzLy1PQSxbZiGfMvdvC8pRxTLK5sjmC3De7a9TM8tL2qXs3UUoBZdeCS86/IR7Dr rKbg== X-Gm-Message-State: AOAM530r4MdHlJTvKsig8+spRt+lWtSm87CzbIL1gdF0v629zV+RHP1L q9/k4pNabc/oErMeW8ElWtw= X-Google-Smtp-Source: ABdhPJw9UFs+56GbYPq0rQ7c7c2tDNpm9aeaKw9djhH1aOOiy2Z5/mzl5j0wKXy1MJnVh9k7Huienw== X-Received: by 2002:a17:906:2dc3:: with SMTP id h3mr1665725eji.713.1641862986144; Mon, 10 Jan 2022 17:03:06 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id e16sm4286362edu.15.2022.01.10.17.03.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jan 2022 17:03:05 -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, vbabka@suse.cz, 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, Wei Yang Subject: [PATCH 3/4] mm/memcg: retrieve parent memcg from css.parent Date: Tue, 11 Jan 2022 01:03:01 +0000 Message-Id: <20220111010302.8864-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220111010302.8864-1-richard.weiyang@gmail.com> References: <20220111010302.8864-1-richard.weiyang@gmail.com> Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KnHpqKaf; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-Stat-Signature: feuib9mz6fot18yn4mbyghacm4de7bpe X-Rspamd-Queue-Id: 42C7420002 X-Rspamd-Server: rspam12 X-HE-Tag: 1641862987-556123 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: 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,