From patchwork Tue Mar 22 21:40:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12789077 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 623D9C43219 for ; Tue, 22 Mar 2022 21:40:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3E936B0093; Tue, 22 Mar 2022 17:40:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEDBC6B0099; Tue, 22 Mar 2022 17:40:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDD1F6B009A; Tue, 22 Mar 2022 17:40:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id BE6D96B0093 for ; Tue, 22 Mar 2022 17:40:20 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 89601A4DDB for ; Tue, 22 Mar 2022 21:40:20 +0000 (UTC) X-FDA: 79273341000.29.B77928F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf22.hostedemail.com (Postfix) with ESMTP id D62E1C0036 for ; Tue, 22 Mar 2022 21:40:19 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BF83AB81D77; Tue, 22 Mar 2022 21:40:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 806F9C340EC; Tue, 22 Mar 2022 21:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985217; bh=vzhFL6mlQti7d58JDlxxBNhVkqwV3XQfc4/UNOriJag=; h=Date:To:From:In-Reply-To:Subject:From; b=0sRv+MWOIF0jYQ4lKQICEGXrbbm9gidGVdF7HQoZOJi8PbT72N0UkStaKuBIVeAjW QCMMAdOxBx0jBdh5UVu46K8rclguFGyzbIZA8bT5kiGsyfuUbT1kko2RX4tK62IQo6 hoQAATH5/iIIUfWpr+DTng1bTAMox5RQipJzHJxE= Date: Tue, 22 Mar 2022 14:40:16 -0700 To: vdavydov.dev@gmail.com,vbabka@suse.cz,surenb@google.com,songmuchun@bytedance.com,shy828301@gmail.com,shakeelb@google.com,rppt@linux.ibm.com,roman.gushchin@linux.dev,mhocko@suse.com,hannes@cmpxchg.org,guro@fb.com,richard.weiyang@gmail.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 035/227] mm/memcg: retrieve parent memcg from css.parent Message-Id: <20220322214017.806F9C340EC@smtp.kernel.org> X-Stat-Signature: ipsh859hp4hg9prpt416pd83e9jcb8xx Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=0sRv+MWO; spf=pass (imf22.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D62E1C0036 X-HE-Tag: 1647985219-81051 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: Wei Yang Subject: mm/memcg: retrieve parent memcg from css.parent 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. Link: https://lkml.kernel.org/r/20220201004643.8391-2-richard.weiyang@gmail.com Signed-off-by: Wei Yang Reviewed-by: Muchun Song Acked-by: Michal Hocko Reviewed-by: Roman Gushchin Reviewed-by: Shakeel Butt Cc: Roman Gushchin Cc: Johannes Weiner Cc: Vladimir Davydov Cc: Yang Shi Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Mike Rapoport Signed-off-by: Andrew Morton --- include/linux/memcontrol.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/include/linux/memcontrol.h~mm-memcg-retrieve-parent-memcg-from-cssparent +++ a/include/linux/memcontrol.h @@ -842,9 +842,7 @@ static inline struct mem_cgroup *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,