From patchwork Mon Dec 13 16:53:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12674403 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 DDC7DC433EF for ; Mon, 13 Dec 2021 17:01:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E6356B0087; Mon, 13 Dec 2021 11:56:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4960C6B0088; Mon, 13 Dec 2021 11:56:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 336966B0089; Mon, 13 Dec 2021 11:56:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 20F6D6B0087 for ; Mon, 13 Dec 2021 11:56:19 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E499B8249980 for ; Mon, 13 Dec 2021 16:56:08 +0000 (UTC) X-FDA: 78913373616.20.E763EFF Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf14.hostedemail.com (Postfix) with ESMTP id 658BA10000C for ; Mon, 13 Dec 2021 16:56:07 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so13811981pjb.5 for ; Mon, 13 Dec 2021 08:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bdtfe1LcQo3Qu9RxCCpvyKyO2e4/06WIWZXzrRc4RLo=; b=cDze2dAZOSxa0rvXQ0rj9yRXAegrrUEEqhed0oeppCWkPnVhi6j/MuKPEGva/FuQhd UOOIPLRc4wSDbmfdIxdP7p1QN8/YojbI8s9/A+FKC9xb5x/G/Q16ICTYWRHVVgW8/VIC vE2b8peoAWBA3FeIKXq/vQdCNxhDvTSCiNkegbxpuRT5YSXtC7gk27XzXQ7ToGHW4d/c TyXG12LgvZ5WjhXcfHnI4wpJU3y5gcvJrBrSEeexfMGMfDOPCapE1xUyrQ6luP+OZaCq Oh4oZJbat7ALDmSMTTlWVexeRYB6AMmxqVifEORvu5bcnhXDEFzKgS8I6pzwuISwac7s GLZg== 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:mime-version:content-transfer-encoding; bh=bdtfe1LcQo3Qu9RxCCpvyKyO2e4/06WIWZXzrRc4RLo=; b=Z+AFki83fm60Qact9/UK/VA5514kZ+AbRcHCLTDebbVJlCPuQHsRYwuYO/J0rucSdN /sCi/2TmZMbxP1g70An1oZ5/d/bQbBB9uohdUvuR+DvxIkUuUDF45DOjdScMMymLlTCX hkr1mTROnHQS7/AUnFDOk5czx94HKRqkuhxugH1sJT2G2YP5G+X4VhWYoKUVKbN96M7X P0oZd+wMOUH/BAueW2di6j1W/Z57c36eZa6HztowmjVcnCcFT9VP12h+Z7lEmL5H6V+F /io1A/rLKG63F0BecilxC1RPE9JT8W7TY46mppS60i1PDiS9vqDvVT2xqNif2Hb3shOT mLCg== X-Gm-Message-State: AOAM5334ZEHefbp5soOLuvPQLUxkRjiCAoEjNrO4/rn+k4zVFp5H3YbK kgt6J2DWQrfE+iLYc1fjZjk26w== X-Google-Smtp-Source: ABdhPJx3vZN32C6bOQQc0YtUhrrg3EL/OFD/PYgy/UznQ1p6vhAieu0TD482F2XmslQUgNUI8udVSA== X-Received: by 2002:a17:90a:5d8e:: with SMTP id t14mr45024882pji.95.1639414567507; Mon, 13 Dec 2021 08:56:07 -0800 (PST) Received: from localhost.localdomain ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id n11sm10430992pgp.15.2021.12.13.08.55.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Dec 2021 08:56:07 -0800 (PST) From: Muchun Song To: willy@infradead.org, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, shakeelb@google.com, guro@fb.com, shy828301@gmail.com, alexs@kernel.org, richard.weiyang@gmail.com, david@fromorbit.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, jaegeuk@kernel.org, chao@kernel.org, kari.argillander@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, zhengqi.arch@bytedance.com, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, smuchun@gmail.com, Muchun Song Subject: [PATCH v4 12/17] mm: list_lru: rename memcg_drain_all_list_lrus to memcg_reparent_list_lrus Date: Tue, 14 Dec 2021 00:53:37 +0800 Message-Id: <20211213165342.74704-13-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20211213165342.74704-1-songmuchun@bytedance.com> References: <20211213165342.74704-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 658BA10000C X-Stat-Signature: jcmf7poxqu8ek39muy8r594x9exjqw9n Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=cDze2dAZ; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1639414567-166223 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 purpose of the memcg_drain_all_list_lrus() is list_lrus reparenting. It is very similar to memcg_reparent_objcgs(). Rename it to memcg_reparent_list_lrus() so that the name can more consistent with memcg_reparent_objcgs(). Signed-off-by: Muchun Song --- include/linux/list_lru.h | 2 +- mm/list_lru.c | 24 ++++++++++++------------ mm/memcontrol.c | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h index c36db6dc2a65..4b00fd8cb373 100644 --- a/include/linux/list_lru.h +++ b/include/linux/list_lru.h @@ -78,7 +78,7 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, int memcg_list_lru_alloc(struct mem_cgroup *memcg, struct list_lru *lru, gfp_t gfp); int memcg_update_all_list_lrus(int num_memcgs); -void memcg_drain_all_list_lrus(struct mem_cgroup *src, struct mem_cgroup *dst); +void memcg_reparent_list_lrus(struct mem_cgroup *memcg, struct mem_cgroup *parent); /** * list_lru_add: add an element to the lru list's tail diff --git a/mm/list_lru.c b/mm/list_lru.c index 4af820c191a7..9116e220e9b8 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -456,8 +456,8 @@ int memcg_update_all_list_lrus(int new_size) return ret; } -static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, - int src_idx, struct mem_cgroup *dst_memcg) +static void memcg_reparent_list_lru_node(struct list_lru *lru, int nid, + int src_idx, struct mem_cgroup *dst_memcg) { struct list_lru_node *nlru = &lru->node[nid]; int dst_idx = dst_memcg->kmemcg_id; @@ -485,22 +485,22 @@ static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, spin_unlock_irq(&nlru->lock); } -static void memcg_drain_list_lru(struct list_lru *lru, - int src_idx, struct mem_cgroup *dst_memcg) +static void memcg_reparent_list_lru(struct list_lru *lru, + int src_idx, struct mem_cgroup *dst_memcg) { int i; for_each_node(i) - memcg_drain_list_lru_node(lru, i, src_idx, dst_memcg); + memcg_reparent_list_lru_node(lru, i, src_idx, dst_memcg); memcg_list_lru_free(lru, src_idx); } -void memcg_drain_all_list_lrus(struct mem_cgroup *src, struct mem_cgroup *dst) +void memcg_reparent_list_lrus(struct mem_cgroup *memcg, struct mem_cgroup *parent) { struct cgroup_subsys_state *css; struct list_lru *lru; - int src_idx = src->kmemcg_id; + int src_idx = memcg->kmemcg_id; /* * Change kmemcg_id of this cgroup and all its descendants to the @@ -516,17 +516,17 @@ void memcg_drain_all_list_lrus(struct mem_cgroup *src, struct mem_cgroup *dst) * call. */ rcu_read_lock(); - css_for_each_descendant_pre(css, &src->css) { - struct mem_cgroup *memcg; + css_for_each_descendant_pre(css, &memcg->css) { + struct mem_cgroup *child; - memcg = mem_cgroup_from_css(css); - memcg->kmemcg_id = dst->kmemcg_id; + child = mem_cgroup_from_css(css); + child->kmemcg_id = parent->kmemcg_id; } rcu_read_unlock(); mutex_lock(&list_lrus_mutex); list_for_each_entry(lru, &memcg_list_lrus, list) - memcg_drain_list_lru(lru, src_idx, dst); + memcg_reparent_list_lru(lru, src_idx, parent); mutex_unlock(&list_lrus_mutex); } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 94d8f742c32e..a19b1a1c8ea9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3644,7 +3644,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) memcg_reparent_objcgs(memcg, parent); /* - * memcg_drain_all_list_lrus() can change memcg->kmemcg_id. + * memcg_reparent_list_lrus() can change memcg->kmemcg_id. * Cache it to local @kmemcg_id. */ kmemcg_id = memcg->kmemcg_id; @@ -3653,9 +3653,9 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) * After we have finished memcg_reparent_objcgs(), all list_lrus * corresponding to this cgroup are guaranteed to remain empty. * The ordering is imposed by list_lru_node->lock taken by - * memcg_drain_all_list_lrus(). + * memcg_reparent_list_lrus(). */ - memcg_drain_all_list_lrus(memcg, parent); + memcg_reparent_list_lrus(memcg, parent); memcg_free_cache_id(kmemcg_id); }