Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2720633lqo; Tue, 14 May 2024 07:21:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXOYRZZQJdFg5LCNV627JRd7LxgyN7+x7YMEjOFeI5Ip+8bfyc5JAL9kkJzkNfdBNEAG0yeUcfrUbAkBxam4T7AY+QxrY7CVhJa4L35qg== X-Google-Smtp-Source: AGHT+IFijCk5gLpFlcSKxM+UygU0HnFBSPm9HSpltRoeqp1RPu/w0J8F9nXzutCwAyACbWQr3/BW X-Received: by 2002:a17:90b:378a:b0:2b6:cd1f:b9c0 with SMTP id 98e67ed59e1d1-2b6cd1fb9femr10113861a91.4.1715696482397; Tue, 14 May 2024 07:21:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715696482; cv=pass; d=google.com; s=arc-20160816; b=bCAVo4Fbv9cy51tbn8SblNpoARuGIZElS4r8/2N7GB9a61NaFmamWEj/trtmbjUWdD SGyyo7eddAnFxO0eqqd/3Wny5qaf9WLa5O5DVtg4cXkf3Y34DQTyA7KpO0qsAnGpMupJ 1mxu3LT+5CXbUlV9YfUafNcIrjmoIJw6DhZYF++km9j9NMuWYjz3TG36N2bh6ZN5/05N MOgp43XhJowKzR7jMSjHRFl+TRCneXwPscBaQ4+KVPNzyeZBZN4WYVlvx59AlYeLjSar sD+5snNXbdROn7siYqaNEQGaNlzFCkhnSZEvi54iDun+4x3SaVXlJe5mx0VJKBaUg7cR OSaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=QyObfHROCQM34yYn3NOjoIfR1A4DlxepS3b18yjnmzo=; fh=1vqSqy5QWQgRRa5Lu2AiQHnqHexxHDFCWypXliuk03s=; b=dC+dVhs6k64ZWwbrk6E2zkzrpAk3DoEKz+tlQcNjpmBxS6E1dTURYju9guK/EW0ZIx F3A58gfk/dWXugCAByassNpO0e1T6mC2rgegl1wiAJu6OdBn+fF0vJ09vX6Vp0rEgOwQ 4zEeg7yHtoxmAVEjw9x4vked10YCx/FwEzNPU0TUiRcEdMFDP9JM5L3nXJ79FyrEcMx1 fwb061P9VbpAOHUPS3ZyON9umN+ibtJSMFJ7FXx1IOfK/ttceT+VshA9nFJQz8xxV8gm FK3o3yWgq7+capkXsPkU8d2yjScca4vxgKqRqtMu4Bzkq0CrIIYNetwTxsfjq6PMU/UV 3wmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=XrAYQPgy; dkim=pass header.i=@suse.com header.s=susede1 header.b=Z+ahYdDB; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-178790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628ea751dsi13732790a91.104.2024.05.14.07.21.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 07:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=XrAYQPgy; dkim=pass header.i=@suse.com header.s=susede1 header.b=Z+ahYdDB; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-178790-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8E87F282DA4 for ; Tue, 14 May 2024 14:10:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FCA3144D1C; Tue, 14 May 2024 14:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="XrAYQPgy"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Z+ahYdDB" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B13C1448D9; Tue, 14 May 2024 14:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715695810; cv=none; b=onN+VCCCYByVge14V0//NtScC2li7xFZqnAdCe8zcrtp/Anq/cH4C0c9/K2ZJ4ZmI2JRhTbyD8XMbnllUjeP+Xh/A/MFzRMEMBOu3lrDFDw/hWcs2mGvRghTdNawjR7uOqJnKJcTk3uy0PQgwDfeuA64++6FhG8Vk3kfB6xO6Ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715695810; c=relaxed/simple; bh=iWP8HSVSOriGJffY8FlJsZ27CjnV1fyLluT/GZJnVxE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XuTjd9FtLYbePXFfbNkRy6CcpeVFdkA741gABmiEpFxTUjEkgbcoi80+X5x+eq5u2dY+HZPD1XJrq00gwVCSqIMy5kTMNVG5WYsJkk+/52Op7XdTSdCrhSJQIcMucmwM6l1bf9WLjdHTd/FPh/6UjUdcPX2CwZKtUCBN72IUCVM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=XrAYQPgy; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Z+ahYdDB; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DF27060CBA; Tue, 14 May 2024 14:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1715695801; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QyObfHROCQM34yYn3NOjoIfR1A4DlxepS3b18yjnmzo=; b=XrAYQPgylTEL7g6Yo5/0DgxiLUTRWRRLkiGhCuK6M3u0Jh6IG/5CTKCMWRR+E8dRbQ+6RR hG6t8+TeaIZ6MZT0xraGqIH/czDduJua5MQLpN/yTD7msrAl5QtPiubbmrLiuuPLb6O4Cs ggx/XoJa1QHLVomm+XxUiabdGZRghW8= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1715695800; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QyObfHROCQM34yYn3NOjoIfR1A4DlxepS3b18yjnmzo=; b=Z+ahYdDBy7cmu/gmrcLI/7WfPEw2IMCy7EqIruO2VnhI9pqPK0VZVAiFVhLrB3MjAiAaYM xrMhaZsOhffmyJjSHwqXSk0gcz5v55/3zs3DlWvGZ/0TDCKuZ4iQmFBRHp76a7lAJGsaym AaPTg+rL1UCibRfdv8ys7tjDaPIVBUk= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8D6FE137C3; Tue, 14 May 2024 14:10:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Sg2vGbhwQ2Z6NwAAD6G6ig (envelope-from ); Tue, 14 May 2024 14:10:00 +0000 Date: Tue, 14 May 2024 16:09:58 +0200 From: Michal Hocko To: Xiu Jianfeng Cc: hannes@cmpxchg.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] memcg: don't handle event_list for v2 when offlining Message-ID: References: <20240514131106.1326323-1-xiujianfeng@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240514131106.1326323-1-xiujianfeng@huawei.com> X-Spam-Flag: NO X-Spam-Score: -2.82 X-Spam-Level: X-Spamd-Result: default: False [-2.82 / 50.00]; BAYES_HAM(-2.02)[95.17%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; MISSING_XM_UA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_SEVEN(0.00)[9]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] On Tue 14-05-24 13:11:06, Xiu Jianfeng wrote: > 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. You are right but the code as is works just fine. The list will be empty. It is true that we do not need to take event_list_lock lock but nobody should be using this lock anyway. Also the offline callback is not particularly hot path. So why do we want to change the code? > > Signed-off-by: Xiu Jianfeng > --- > 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 -- Michal Hocko SUSE Labs