From patchwork Tue Feb 1 00:46:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12731331 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 2233CC433F5 for ; Tue, 1 Feb 2022 00:47:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B5908D0038; Mon, 31 Jan 2022 19:47:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 762B38D0028; Mon, 31 Jan 2022 19:47:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 604208D0038; Mon, 31 Jan 2022 19:47:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 52A178D0028 for ; Mon, 31 Jan 2022 19:47:01 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03EFF92EB2 for ; Tue, 1 Feb 2022 00:47:01 +0000 (UTC) X-FDA: 79092371442.08.9267F09 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf03.hostedemail.com (Postfix) with ESMTP id 9DDE920005 for ; Tue, 1 Feb 2022 00:47:00 +0000 (UTC) Received: by mail-ej1-f44.google.com with SMTP id p15so48467182ejc.7 for ; Mon, 31 Jan 2022 16:47:00 -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; bh=uPVLcxrrpf12Ei4lWc6lSHRXgw8cc0G/gavfe4Q9af4=; b=hdpLvN0QxInM8+zBsj9rlh83NVjYyFJoIFuN/De4NAA9EcVJhT7Wqhkcj75YZEeEV2 th2W52TZaFlmrPuVbf6bmepEh9nDGgI4CSDd+GaLoRrX1GocorJrKLmA9JiVmpB6t8s5 66kbKsZny0SG2cCxsmhC78eAk8a3CPKbs558vyZgfnz46XL3sxK28SQN2uG3f6XLjnzl LNghAm/XyZAZInH39ADFZhe9ctC11i3g7jcQor7TRZxqtGO16EuWNH8wT2AC3cDP3IuA 0C0BTkQ33c8fKzbuibkJDmgEw1NtwrOcnpFtlrZOFnPEaDzl3jCxB+jJoKQlGI40mEK6 Gi2g== 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; bh=uPVLcxrrpf12Ei4lWc6lSHRXgw8cc0G/gavfe4Q9af4=; b=0baR9s/rqmwD4HFgrkB0G5t7+iIuNltl1ZbD7MlR8qfQ1YdX6oB0LeCoNH98Z4NJnR 3hVO5hzTq4hpBYIDhQJPMJAVcG/AzX6r+rVP/0U9g5N7ppZdqY6h5E6fgejPDgA9yNBV S1I7Dnn8ibxa9BgXCL/aBNgRJJkCZNU2GTZLrNysnPOddTuGR5fckVFKjFwq8r03M5bz Im5oi6HOQykJmAsvEbhKT+tOoOeTf1kioHz/wOrVylP4bNtwAlZJUeceRXjTF+jgro9G iK397iUWG5zhON7YijFBAWiGL9hng1ZRBTAg7woqi5mSo4CIkCoNjW1+XnhYMKiGmGsN oaBg== X-Gm-Message-State: AOAM530GAvtDTQVAoQnBeUuC33sQd+jJIpGX0ijennHaNY+2Ryq1oEL/ AapktpvwC8kgLO5+FvOS6D0= X-Google-Smtp-Source: ABdhPJw8HWmyZMvyKUz/GCpLFtIhWj2bZvqHd92ATTkn5xbAydEP5bf6sPKyPc0j527YW5ynQlVdrQ== X-Received: by 2002:a17:907:c19:: with SMTP id ga25mr20364151ejc.606.1643676419516; Mon, 31 Jan 2022 16:46:59 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id v10sm18500935edx.36.2022.01.31.16.46.58 (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 1/2] mm/memcg: mem_cgroup_per_node is already set to 0 on allocation Date: Tue, 1 Feb 2022 00:46:42 +0000 Message-Id: <20220201004643.8391-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9DDE920005 X-Stat-Signature: z1yc95qrhf17s6e98kbgkmnd59dssa6q Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hdpLvN0Q; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com X-HE-Tag: 1643676420-304754 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: kzalloc_node() would set data to 0, so it's not necessary to set it again. Signed-off-by: Wei Yang Reviewed-by: Muchun Song Acked-by: Michal Hocko Reviewed-by: Roman Gushchin Reviewed-by: Mike Rapoport Reviewed-by: Shakeel Butt --- mm/memcontrol.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ea8460658550..ce7060907df2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5070,8 +5070,6 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) } lruvec_init(&pn->lruvec); - pn->usage_in_excess = 0; - pn->on_tree = false; pn->memcg = memcg; memcg->nodeinfo[node] = pn; 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,