All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Jisheng Zhang <jszhang@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>, Dennis Zhou <dennis@kernel.org>,
	Tejun Heo <tj@kernel.org>,  Christoph Lameter <cl@gentwo.org>,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] arm64: remove HAVE_CMPXCHG_LOCAL
Date: Fri, 20 Feb 2026 15:27:51 -0800	[thread overview]
Message-ID: <aZjiHt7h2z3Ye81_@linux.dev> (raw)
In-Reply-To: <aZf9RsIUh8ARg_RP@xhacker>

On Fri, Feb 20, 2026 at 02:20:54PM +0800, Jisheng Zhang wrote:
> On Wed, Feb 18, 2026 at 02:07:57PM -0800, Shakeel Butt wrote:
> > On Sun, Feb 15, 2026 at 11:39:44AM +0800, Jisheng Zhang wrote:
> > > It turns out the generic disable/enable irq this_cpu_cmpxchg
> > > implementation is faster than LL/SC or lse implementation. Remove
> > > HAVE_CMPXCHG_LOCAL for better performance on arm64.
> > > 
> > > Tested on Quad 1.9GHZ CA55 platform:
> > > average mod_node_page_state() cost decreases from 167ns to 103ns
> > > the spawn (30 duration) benchmark in unixbench is improved
> > > from 147494 lps to 150561 lps, improved by 2.1%
> > > 
> > > Tested on Quad 2.1GHZ CA73 platform:
> > > average mod_node_page_state() cost decreases from 113ns to 85ns
> > > the spawn (30 duration) benchmark in unixbench is improved
> > > from 209844 lps to 212581 lps, improved by 1.3%
> > > 
> > > Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> > 
> > Please note that mod_node_page_state() can be called in NMI context and
> > generic disable/enable irq are not safe against NMIs (newer arm arch supports
> > NMI).
> 
> hmm, interesting...
> 
> fgrep HAVE_NMI arch/*/Kconfig
> then
> fgrep HAVE_CMPXCHG_LOCAL arch/*/Kconfig
> 
> shows that only x86, arm64, s390 and loongarch are safe, while arm,
> powerpc and mips enable HAVE_NMI but missing HAVE_CMPXCHG_LOCAL, so
> they rely on generic generic disable/enable irq version, so you imply
> that these three arch are not safe considering mod_node_page_state()
> in NMI context.

Yes it seems like it. For memcg stats, we use ARCH_HAVE_NMI_SAFE_CMPXCHG and
ARCH_HAS_NMI_SAFE_THIS_CPU_OPS config options to correctly handle the updates
from NMI context. Maybe we need something similar for vmstat as well.

So arm, powerpc and mips does not have ARCH_HAS_NMI_SAFE_THIS_CPU_OPS but
powerpc does have ARCH_HAVE_NMI_SAFE_CMPXCHG and arm has
it for CPU_V7, CPU_V7M & CPU_V6K models.

I wonder if we need to add complexity for these archs.


      reply	other threads:[~2026-02-20 23:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15  3:39 [PATCH] arm64: remove HAVE_CMPXCHG_LOCAL Jisheng Zhang
2026-02-16 10:59 ` Dev Jain
2026-02-16 11:00 ` Will Deacon
2026-02-16 15:29   ` Dev Jain
2026-02-17 13:53     ` Catalin Marinas
2026-02-17 15:00       ` Will Deacon
2026-02-17 16:48         ` Catalin Marinas
2026-02-18  4:01           ` K Prateek Nayak
2026-02-18  9:29             ` Catalin Marinas
2026-02-17 17:19     ` Christoph Lameter (Ampere)
2026-02-23  9:19       ` Heiko Carstens
2026-02-20  6:14     ` Jisheng Zhang
2026-02-18 22:07 ` Shakeel Butt
2026-02-20  6:20   ` Jisheng Zhang
2026-02-20 23:27     ` Shakeel Butt [this message]

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=aZjiHt7h2z3Ye81_@linux.dev \
    --to=shakeel.butt@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=cl@gentwo.org \
    --cc=dennis@kernel.org \
    --cc=jszhang@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.