From patchwork Tue Jun 21 12:56:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12889202 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 0703AC433EF for ; Tue, 21 Jun 2022 12:57:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E4906B0072; Tue, 21 Jun 2022 08:57:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 693B48E0003; Tue, 21 Jun 2022 08:57:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5345E8E0002; Tue, 21 Jun 2022 08:57:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 436056B0072 for ; Tue, 21 Jun 2022 08:57:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1F1E5FDD for ; Tue, 21 Jun 2022 12:57:47 +0000 (UTC) X-FDA: 79602244974.24.922B641 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf01.hostedemail.com (Postfix) with ESMTP id 1BCAB40018 for ; Tue, 21 Jun 2022 12:57:45 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id g8so12449097plt.8 for ; Tue, 21 Jun 2022 05:57:45 -0700 (PDT) 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=EillBei8kFa/6bw4XJ6MyIzznZyI10pUVH5tAnTdeuw=; b=Jv9GaHJN86Q1C8Y+YpP2HCf9JPFImIvPmz0BU9q0OZd0+4E84aO4jvX7w2JJE8HLii xXvy2BsIyrtipyPfO3JiQ1L4gabF6BNM/uSE7D/v4vl5Vc36NMI2yEg+YZ5KSpNsGptU HO2lidk6QI25ifAr3ya3fadEcyz9Zbz8Qo1Yg9d9O1CQjjvVGXgpg23fllv4PPkdtuY7 rKxObA5Q8AuofZlnIdgY5syfjw3uLfKsvjs7i/wXGnHIM/h1h8t1/P4ZXW1c8yFLligG siardVDC/TnIZX7H68y5GKiYC9yQyG4FPJP7v8L66B47QZvSC5zmsPVyqmAM4Ajp6REh K7Pw== 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=EillBei8kFa/6bw4XJ6MyIzznZyI10pUVH5tAnTdeuw=; b=BGn6BRHJIIKhRTTxQsvMyGXIl85CES4vj0B+7S/5IXNnaamTxJvSKiywPwVXTwaHzY IPeDtSBNoqf7H8pY6+dRqmTIg3iKqmgd5i+awWctqJlOYExXFj+azOjGBExhJ4yQJMtK FIvceKT7fxTeOqG+Q1LDVNoTBX6393UV47pNT5Coz8K9aEyEDVnPMqgkmdIc3qcsE4B4 D2iOW48MoUNGzkL+qkIjWup6WU1HJnH3bixWKcjYC7DLc5gOg+5Unixcj66c8MBygth0 7jA0zumklfl2d4MZDALTSGyP8VD8Y7+qBiAzHyRRVA4TtlR/i9NCrQabja9YoD7yIACd LQ+w== X-Gm-Message-State: AJIora89o3U/GsBIIB50gzkSXmNvFQH2zHRArcMsWXPHP7mew08BFlo9 NB8iE0HLoJlIQqLQ2dIMLHbGeA== X-Google-Smtp-Source: AGRyM1tSXaqiZZOhIChBYioUnW0DVCRqwFclVFY428N7/E3eP36ixMt0VVOaIjmyV7ksj0qm20VtAQ== X-Received: by 2002:a17:902:c2c6:b0:168:d8ce:90b2 with SMTP id c6-20020a170902c2c600b00168d8ce90b2mr29357788pla.110.1655816265091; Tue, 21 Jun 2022 05:57:45 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id e3-20020a170903240300b0015ea3a491a1sm10643134plo.191.2022.06.21.05.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 05:57:44 -0700 (PDT) From: Muchun Song To: akpm@linux-foundation.org, hannes@cmpxchg.org, longman@redhat.com, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com Cc: cgroups@vger.kernel.org, duanxiongchun@bytedance.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song Subject: [PATCH v6 01/11] mm: memcontrol: remove dead code and comments Date: Tue, 21 Jun 2022 20:56:48 +0800 Message-Id: <20220621125658.64935-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220621125658.64935-1-songmuchun@bytedance.com> References: <20220621125658.64935-1-songmuchun@bytedance.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655816266; a=rsa-sha256; cv=none; b=18+CPX4QKqeOXpFfOjFu7t+UCuEtGhAYVLY4HcJi51lD6JeRXXWl4UrCXDMD80VQjh+4j/ w+UI/Ya8CMmtImfBCzSR8nEdg6VCUuYBLquzyrPyCKghD9PSHYxiTroMreQ1jdjrujYqcO hi7Hzet5Gdgx11LKfW3TZmjt5UgcMl4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Jv9GaHJN; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655816266; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EillBei8kFa/6bw4XJ6MyIzznZyI10pUVH5tAnTdeuw=; b=x2khicglFEK798/AZAu5in9+iQ5iOJrczEArJgEAwru10vzc3WpJFCDt37oejoiYgQtgIC HpuYPe/ib6TUgKOfym3RbRHIOGWAq3TnGYk9CZmBMJx3p8AQMWHFfN9pTZdN9+CMnQrQTT bYI7lbfJ/363IuFnlBYo43Kip6jrmkI= X-Rspamd-Server: rspam01 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Jv9GaHJN; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Stat-Signature: zfst9axxzagydxshqxwydymnap4x55ti X-Rspamd-Queue-Id: 1BCAB40018 X-HE-Tag: 1655816265-955249 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: Since no-hierarchy mode is deprecated after commit bef8620cd8e0 ("mm: memcg: deprecate the non-hierarchical mode") so parent_mem_cgroup() cannot return a NULL except root memcg, however, root memcg cannot be offline, so it is safe to drop the check of returned value of parent_mem_cgroup(). Remove those dead code. The comments in memcg_offline_kmem() above memcg_reparent_list_lrus() are out of date since commit 5abc1e37afa0 ("mm: list_lru: allocate list_lru_one only when needed") There is no ordering requirement between memcg_reparent_list_lrus() and memcg_reparent_objcgs(), so remove those outdated comments. Signed-off-by: Muchun Song Acked-by: Roman Gushchin --- include/linux/memcontrol.h | 3 +-- mm/memcontrol.c | 12 ------------ mm/vmscan.c | 6 +----- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 4d31ce55b1c0..318d8880d62a 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -866,8 +866,7 @@ static inline struct mem_cgroup *lruvec_memcg(struct lruvec *lruvec) * parent_mem_cgroup - find the accounting parent of a memcg * @memcg: memcg whose parent to find * - * Returns the parent memcg, or NULL if this is the root or the memory - * controller is in legacy no-hierarchy mode. + * Returns the parent memcg, or NULL if this is the root. */ static inline struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 163492b9efa9..fc706d6fc265 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3684,17 +3684,7 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) return; parent = parent_mem_cgroup(memcg); - if (!parent) - parent = root_mem_cgroup; - memcg_reparent_objcgs(memcg, parent); - - /* - * 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_reparent_list_lrus(). - */ memcg_reparent_list_lrus(memcg, parent); } #else @@ -7195,8 +7185,6 @@ static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) break; } memcg = parent_mem_cgroup(memcg); - if (!memcg) - memcg = root_mem_cgroup; } return memcg; } diff --git a/mm/vmscan.c b/mm/vmscan.c index 88fce64cfa96..b68b0216424d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -409,13 +409,9 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg) { int i, nid; long nr; - struct mem_cgroup *parent; + struct mem_cgroup *parent = parent_mem_cgroup(memcg); struct shrinker_info *child_info, *parent_info; - parent = parent_mem_cgroup(memcg); - if (!parent) - parent = root_mem_cgroup; - /* Prevent from concurrent shrinker_info expand */ down_read(&shrinker_rwsem); for_each_node(nid) {