From: Muchun Song <songmuchun@bytedance.com>
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 <songmuchun@bytedance.com>
Subject: [PATCH v6 01/11] mm: memcontrol: remove dead code and comments
Date: Tue, 21 Jun 2022 20:56:48 +0800 [thread overview]
Message-ID: <20220621125658.64935-2-songmuchun@bytedance.com> (raw)
In-Reply-To: <20220621125658.64935-1-songmuchun@bytedance.com>
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 <songmuchun@bytedance.com>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
---
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) {
--
2.11.0
next prev parent reply other threads:[~2022-06-21 12:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 12:56 [PATCH v6 00/11] Use obj_cgroup APIs to charge the LRU pages Muchun Song
2022-06-21 12:56 ` Muchun Song [this message]
2022-06-21 12:56 ` [PATCH v6 02/11] mm: rename unlock_page_lruvec{_irq, _irqrestore} to lruvec_unlock{_irq, _irqrestore} Muchun Song
2022-06-21 12:56 ` [PATCH v6 03/11] mm: memcontrol: prepare objcg API for non-kmem usage Muchun Song
2022-06-21 12:56 ` [PATCH v6 04/11] mm: memcontrol: make lruvec lock safe when LRU pages are reparented Muchun Song
2022-06-21 12:56 ` [PATCH v6 05/11] mm: vmscan: rework move_pages_to_lru() Muchun Song
2022-06-21 12:56 ` [PATCH v6 06/11] mm: thp: make split queue lock safe when LRU pages are reparented Muchun Song
2022-06-21 12:56 ` [PATCH v6 07/11] mm: memcontrol: make all the callers of {folio,page}_memcg() safe Muchun Song
2022-06-21 12:56 ` [PATCH v6 08/11] mm: memcontrol: introduce memcg_reparent_ops Muchun Song
2022-06-21 12:56 ` [PATCH v6 09/11] mm: memcontrol: use obj_cgroup APIs to charge the LRU pages Muchun Song
2022-06-21 12:56 ` [PATCH v6 10/11] mm: lru: add VM_WARN_ON_ONCE_FOLIO to lru maintenance function Muchun Song
2022-06-21 12:56 ` [PATCH v6 11/11] mm: lru: use lruvec lock to serialize memcg changes Muchun Song
2022-06-26 10:32 ` [PATCH v6 00/11] Use obj_cgroup APIs to charge the LRU pages Yosry Ahmed
2022-06-27 7:11 ` Muchun Song
2022-06-27 8:05 ` Yosry Ahmed
2022-06-27 10:13 ` Muchun Song
2022-06-27 16:46 ` Yosry Ahmed
2022-06-28 1:24 ` Roman Gushchin
2022-06-28 1:31 ` Yosry Ahmed
2022-06-28 1:37 ` Roman Gushchin
2022-06-28 1:45 ` Yosry Ahmed
2022-06-27 10:43 ` Mika Penttilä
2022-06-27 16:49 ` Yosry Ahmed
2022-07-07 22:14 ` Yosry Ahmed
2022-07-08 6:52 ` Muchun Song
2022-07-08 9:26 ` Yosry Ahmed
2022-07-09 5:51 ` Muchun Song
2022-07-09 9:23 ` Yosry Ahmed
2022-07-03 23:23 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220621125658.64935-2-songmuchun@bytedance.com \
--to=songmuchun@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=duanxiongchun@bytedance.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mhocko@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox