cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiu Jianfeng <xiujianfeng@huawei.com>
To: <hannes@cmpxchg.org>, <mhocko@kernel.org>,
	<roman.gushchin@linux.dev>, <shakeel.butt@linux.dev>,
	<muchun.song@linux.dev>, <akpm@linux-foundation.org>
Cc: <cgroups@vger.kernel.org>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH -next] memcg: don't handle event_list for v2 when offlining
Date: Tue, 14 May 2024 13:11:06 +0000	[thread overview]
Message-ID: <20240514131106.1326323-1-xiujianfeng@huawei.com> (raw)

The event_list for memcg is only valid for v1 and not used for v2,
so it's unnessesary to handle event_list for v2.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 mm/memcontrol.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d127c9c5fabf..4254f9cd05f4 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5881,12 +5881,14 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
 	 * Notify userspace about cgroup removing only after rmdir of cgroup
 	 * directory to avoid race between userspace and kernelspace.
 	 */
-	spin_lock_irq(&memcg->event_list_lock);
-	list_for_each_entry_safe(event, tmp, &memcg->event_list, list) {
-		list_del_init(&event->list);
-		schedule_work(&event->remove);
+	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
+		spin_lock_irq(&memcg->event_list_lock);
+		list_for_each_entry_safe(event, tmp, &memcg->event_list, list) {
+			list_del_init(&event->list);
+			schedule_work(&event->remove);
+		}
+		spin_unlock_irq(&memcg->event_list_lock);
 	}
-	spin_unlock_irq(&memcg->event_list_lock);
 
 	page_counter_set_min(&memcg->memory, 0);
 	page_counter_set_low(&memcg->memory, 0);
-- 
2.34.1


             reply	other threads:[~2024-05-14 13:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 13:11 Xiu Jianfeng [this message]
2024-05-14 14:09 ` [PATCH -next] memcg: don't handle event_list for v2 when offlining Michal Hocko
2024-05-14 15:21   ` Roman Gushchin
2024-05-15  2:47     ` xiujianfeng
2024-05-15  2:45   ` xiujianfeng

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=20240514131106.1326323-1-xiujianfeng@huawei.com \
    --to=xiujianfeng@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).