linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Hocko" <mhocko@kernel.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Vlastimil Babka" <vbabka@suse.cz>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Harry Yoo" <harry.yoo@oracle.com>,
	"Yosry Ahmed" <yosry.ahmed@linux.dev>,
	bpf@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Meta kernel team" <kernel-team@meta.com>
Subject: Re: [PATCH 2/3] cgroup: make css_rstat_updated nmi safe
Date: Tue, 10 Jun 2025 11:26:35 -1000	[thread overview]
Message-ID: <aEijC1iHehAxdsfi@slm.duckdns.org> (raw)
In-Reply-To: <20250609225611.3967338-3-shakeel.butt@linux.dev>

Hello,

On Mon, Jun 09, 2025 at 03:56:10PM -0700, Shakeel Butt wrote:
...
> +	self = &rstatc->lnode;
> +	if (!try_cmpxchg(&(rstatc->lnode.next), &self, NULL))
>  		return;
>  
> +	llist_add(&rstatc->lnode, lhead);

I may be missing something but when you say multiple inserters, you mean the
function being re-entered from stacked contexts - ie. process context, BH,
irq, nmi? If so, would it make sense to make the nmi and non-nmi paths use
separate lnode? In non-nmi path, we can just disable irq and test whether
lnode is empty and add it. nmi path can just test whether its lnode is empty
and add it. I suppose nmi's don't nest, right? If they do, we can do
try_cmpxchg() there I suppose.

While the actual addition to the list would be relatively low frequency,
css_rstat_updated() itself can be called pretty frequently. Before, the hot
path was early exit after data_race(css_rstat_cpu(css, cpu)->updated_next).
After, the hot path is now !try_cmpxchg() which doesn't seem great.

Thanks.

-- 
tejun


  reply	other threads:[~2025-06-10 21:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 22:56 [PATCH 0/3] cgroup: nmi safe css_rstat_updated Shakeel Butt
2025-06-09 22:56 ` [PATCH 1/3] cgroup: support to enable nmi-safe css_rstat_updated Shakeel Butt
2025-06-09 22:56 ` [PATCH 2/3] cgroup: make css_rstat_updated nmi safe Shakeel Butt
2025-06-10 21:26   ` Tejun Heo [this message]
2025-06-10 22:31     ` Shakeel Butt
2025-06-10 22:39       ` Tejun Heo
2025-06-10 23:28         ` Shakeel Butt
2025-06-10 23:33           ` Tejun Heo
2025-06-11  5:23   ` JP Kobryn
2025-06-11 13:56     ` Shakeel Butt
2025-06-09 22:56 ` [PATCH 3/3] memcg: cgroup: call memcg_rstat_updated irrespective of in_nmi() Shakeel Butt
2025-06-09 23:44 ` [PATCH 0/3] cgroup: nmi safe css_rstat_updated Andrew Morton
2025-06-09 23:51   ` Shakeel Butt
2025-06-10 10:53 ` Michal Koutný
2025-06-10 16:24   ` Shakeel Butt

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=aEijC1iHehAxdsfi@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=harry.yoo@oracle.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=vbabka@suse.cz \
    --cc=yosry.ahmed@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