From patchwork Tue Sep 14 07:29:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12492231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E40C433F5 for ; Tue, 14 Sep 2021 07:41:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C69A60238 for ; Tue, 14 Sep 2021 07:41:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1C69A60238 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BB1D6900003; Tue, 14 Sep 2021 03:41:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6179940007; Tue, 14 Sep 2021 03:41:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5E0D900003; Tue, 14 Sep 2021 03:41:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 9676C900003 for ; Tue, 14 Sep 2021 03:41:27 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 53F2D1816BB6D for ; Tue, 14 Sep 2021 07:41:27 +0000 (UTC) X-FDA: 78585383814.06.D58A336 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf29.hostedemail.com (Postfix) with ESMTP id C900090001BC for ; Tue, 14 Sep 2021 07:41:26 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id nn5-20020a17090b38c500b0019af1c4b31fso1283716pjb.3 for ; Tue, 14 Sep 2021 00:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bsjYfDNMEc/jELMvGHtKH2gf13kKEK2Ue14TQA3Gi28=; b=OrcumWMrE2b/nfxa+Zj0GT88EGILDhLgk4KgBS0ly+inFAxhtUgjeLsg7pT69wYqZH wFV+svd7CjJghPycVKXor0/CzlVMpoZiR/nACPVNg1YQi55tIjsHrBdrFN87fp1KkE0y Ob8TDgk9Liwk6v9/oGafCXgkhUVrHPo4xjOuLzznMtX7ZT/cupnuhoLdcPq8tNkJs/lu gsHvmMCOvl6suOH5NhnzIMK4sRo73Z7yDOBsPs5iz86nLMFrrSEhzS1tBt5mGxmW5quY WpLnz6MQDewqeASmohKE2wSzc4WQSVje8QRVvxtsCaW2k0uaOrO05coInYwR0u5KHl+B XboQ== 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=bsjYfDNMEc/jELMvGHtKH2gf13kKEK2Ue14TQA3Gi28=; b=nZAycnwEmHR6pX62FdpsM8KIleLUGBOtt9sqWrkx5gaTVuMNek8ahqvh2onzfD68ZR KsdZpRCxQRlio1HDutoarrJl2cgWo/t2g3/bVFdOyKDH95DFRG2nRaxhc784CljtViSc hNNf85GrpJ8iiYPJh6NzQy+y6xSc6jmauS6soxbX2dWON7r12pLnF+FHwalXcx2rItoj IWeXlVbWEdO2j8udgo0jzimKBpwZOge10EnFN+Rnt4c3dWms3P4k7RZ2sKORdyHNuaV2 Inp2Z1TmmyPC2bq5NG7mxvCFKv1CyrxkzsLeEtz96u6A/juhnf2VlJ+MA04OjetGz25W 3Z+w== X-Gm-Message-State: AOAM531c+La5IvQzZaonuVn3B8lD/2eNGjbBvCDkaW3aLhD14dqDxzZZ zAFOUO580qMtjWNYoJSxC1ojuA== X-Google-Smtp-Source: ABdhPJyuMSpSZr9qGteJJluv8QWQshuC0AqQLwhRVohTduvgabtXntr2JJefLZNIQDJJ1sZNrcZ/uw== X-Received: by 2002:a17:902:7c94:b0:13b:8d10:cc4f with SMTP id y20-20020a1709027c9400b0013b8d10cc4fmr9894718pll.54.1631605285968; Tue, 14 Sep 2021 00:41:25 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id s3sm9377839pfd.188.2021.09.14.00.41.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Sep 2021 00:41:25 -0700 (PDT) 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 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 v3 71/76] mm: list_lru: rename memcg_drain_all_list_lrus to memcg_reparent_list_lrus Date: Tue, 14 Sep 2021 15:29:33 +0800 Message-Id: <20210914072938.6440-72-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210914072938.6440-1-songmuchun@bytedance.com> References: <20210914072938.6440-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C900090001BC X-Stat-Signature: eqxut7qyssqcdw9xatohp5p6uy7uy678 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=OrcumWMr; spf=pass (imf29.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1631605286-215213 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 | 3 +-- mm/list_lru.c | 25 ++++++++++++------------- mm/memcontrol.c | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h index 62f407831b8c..5e9c632c9eb7 100644 --- a/include/linux/list_lru.h +++ b/include/linux/list_lru.h @@ -77,8 +77,7 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, __list_lru_init((lru), true, NULL, shrinker) int memcg_update_all_list_lrus(int num_memcgs); -void memcg_drain_all_list_lrus(struct mem_cgroup *src_memcg, - struct mem_cgroup *dst_memcg); +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 48651c29a9d1..1e42d9847b08 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -460,8 +460,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; @@ -489,23 +489,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_memcg, - struct mem_cgroup *dst_memcg) +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_memcg->kmemcg_id; + int src_idx = memcg->kmemcg_id; /* * Change kmemcg_id of this cgroup and all its descendants to the @@ -520,17 +519,17 @@ void memcg_drain_all_list_lrus(struct mem_cgroup *src_memcg, * memcg_list_lru_free(). */ rcu_read_lock(); - css_for_each_descendant_pre(css, &src_memcg->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_memcg->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); + memcg_reparent_list_lru(lru, src_idx, parent); mutex_unlock(&list_lrus_mutex); } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2045cd8b1d7f..4cf98de2ad09 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3636,12 +3636,12 @@ 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 @kmemcg_id. */ kmemcg_id = memcg->kmemcg_id; - memcg_drain_all_list_lrus(memcg, parent); + memcg_reparent_list_lrus(memcg, parent); memcg_free_cache_id(kmemcg_id); }