Message ID | 20210914072938.6440-3-songmuchun@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=Ci01=OE=kvack.org=owner-linux-mm@kernel.org> 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 8F566C4332F for <linux-mm@archiver.kernel.org>; Tue, 14 Sep 2021 07:33:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 45D0A61056 for <linux-mm@archiver.kernel.org>; Tue, 14 Sep 2021 07:33:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 45D0A61056 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 E2C08940008; Tue, 14 Sep 2021 03:33:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDB9D6B0071; Tue, 14 Sep 2021 03:33:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCC76940008; Tue, 14 Sep 2021 03:33:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id BEA686B006C for <linux-mm@kvack.org>; Tue, 14 Sep 2021 03:33:11 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 711CA8249980 for <linux-mm@kvack.org>; Tue, 14 Sep 2021 07:33:11 +0000 (UTC) X-FDA: 78585362982.31.678895F Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf28.hostedemail.com (Postfix) with ESMTP id 36F9490000A2 for <linux-mm@kvack.org>; Tue, 14 Sep 2021 07:33:11 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id me5-20020a17090b17c500b0019af76b7bb4so777451pjb.2 for <linux-mm@kvack.org>; Tue, 14 Sep 2021 00:33:11 -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=q+aIm9+GM4emS27x0YwVh2nGeYKtoN9v9qJyVZ5TBac=; b=tcVTQvhIix8U0yHs7BLHxZMEPABn2dsISnmA+yZSjfp2ev8MDXF7eDdHAJvKPJ4xkX PNr4ylRUrZ34B88F2kvtAUWfVN/EBD5BtpS3HZkEZR7BfQzT4p6Y06tR5/9VG6+Aodei kRVGcb0pqYSCsfsEgkErotCWrmEoNZD3PSjBW5Y1YAHYtiI/6gja9Wn4fePBE7onrQvH XAJ9td79+7/0McQCwSWs8BQRVLW9G2c19R0KmRwiF3B0GmMMCIdbZo5u6p4o2Eey12cL A5JPRu3pkpDV34iUR4H0LYryP9pdO/oldTjF/MRuJrzVq0xtrcya5/P41feW2Vomf4bo xiMQ== 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=q+aIm9+GM4emS27x0YwVh2nGeYKtoN9v9qJyVZ5TBac=; b=MrZdVAtp5J2cLA8swUEYxGO2lJd5pfSbXUkbSXaneirSPxXour+dc0aWtz7Vh2agQU DA16FoqmKONCuL/eqNbwYnGAeyrk2B8xgD6q9UVnZWR8teBnEJLiALn0YndyDjMIqztz izBtC6cK0Yh8rUCAdQ5Y/NF0mE3PtDTq8FXMty3O8+2idn7LJYcplyy+jQVvWSxia8a9 AtBLB9H8cUiXmswWaw2p/QLErTLHoUc+3huK5739cdLCTlVUsNWtVbejoSxI+ogYKgLc 0FPug5IO/+bXTW9oKsj+MnyayfbkLOBvq6eFrOeMsceYjkm1jrQsBp7bzoibGNvpFMsi nUpA== X-Gm-Message-State: AOAM533xZMXK1Y6OUSflBt6PniG9rleBk/f2+WqPK/RSwOu6tCJGh+7N Kff6AaXu8HVp0KIgIImB9DQY6g== X-Google-Smtp-Source: ABdhPJy5yp11xZApIkE1Vn113OINJsFeyKeaalsWeRxGnUmKvHenQWNNl7bwBD87nXmQEd1XiYqflQ== X-Received: by 2002:a17:90a:7f85:: with SMTP id m5mr510983pjl.185.1631604790353; Tue, 14 Sep 2021 00:33:10 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id s3sm9377839pfd.188.2021.09.14.00.33.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Sep 2021 00:33:10 -0700 (PDT) From: Muchun Song <songmuchun@bytedance.com> 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 <songmuchun@bytedance.com> Subject: [PATCH v3 02/76] mm: memcontrol: remove kmemcg_id reparenting Date: Tue, 14 Sep 2021 15:28:24 +0800 Message-Id: <20210914072938.6440-3-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: 36F9490000A2 X-Stat-Signature: 6psyh4x49ercfcqfinrz4141ooeo6djt Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=tcVTQvhI; spf=pass (imf28.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.46 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1631604791-252731 Content-Transfer-Encoding: quoted-printable 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: <linux-mm.kvack.org> |
Series |
Optimize list lru memory consumption
|
expand
|
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 999e626f4111..e0d7ceb0db26 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3635,8 +3635,7 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) static void memcg_offline_kmem(struct mem_cgroup *memcg) { - struct cgroup_subsys_state *css; - struct mem_cgroup *parent, *child; + struct mem_cgroup *parent; int kmemcg_id; if (memcg->kmem_state != KMEM_ONLINE) @@ -3653,22 +3652,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) kmemcg_id = memcg->kmemcg_id; BUG_ON(kmemcg_id < 0); - /* - * Change kmemcg_id of this cgroup and all its descendants to the - * parent's id, and then move all entries from this cgroup's list_lrus - * to ones of the parent. After we have finished, 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(). - */ - rcu_read_lock(); /* can be called from css_free w/o cgroup_mutex */ - css_for_each_descendant_pre(css, &memcg->css) { - child = mem_cgroup_from_css(css); - BUG_ON(child->kmemcg_id != kmemcg_id); - child->kmemcg_id = parent->kmemcg_id; - } - rcu_read_unlock(); - + /* memcg_reparent_objcgs() must be called before this. */ memcg_drain_all_list_lrus(kmemcg_id, parent); memcg_free_cache_id(kmemcg_id);
Since slab objects and kmem pages are charged to object cgroup instead of memory cgroup, memcg_reparent_objcgs() will reparent this cgroup and all its descendants to its parent cgroup. This already makes further list_lru_add()'s add elements to the parent's list. So it is unnecessary to change kmemcg_id of an offline cgroup to its parent's id. It just wastes CPU cycles. Just to remove those redundant code. Signed-off-by: Muchun Song <songmuchun@bytedance.com> --- mm/memcontrol.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)