From: David Laight <david.laight.linux@gmail.com>
To: Steve Wahl <steve.wahl@hpe.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Dave Hansen <dave.hansen@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, justin.ernst@hpe.com,
kyle.meyer@hpe.com, dimitri.sivanich@hpe.com,
russ.anderson@hpe.com, linux-kernel@vger.kernel.org,
mhiramat@kernel.org, Matt Mullins <mmullins@fb.com>
Subject: Re: [PATCH] x86: Drop KGDB support
Date: Fri, 30 Oct 2026 22:31:46 +0000 [thread overview]
Message-ID: <20261030223146.0fae9291@pumpkin> (raw)
In-Reply-To: <auUEkBg5P4AZdjLe@swahl-home.5wahls.com>
On Fri, 30 Oct 2026 15:56:48 -0500
Steve Wahl <steve.wahl@hpe.com> wrote:
> On Fri, Oct 30, 2026 at 04:28:41PM +0000, David Laight wrote:
> > On Thu, 29 Oct 2026 10:32:58 -0500
> > Steve Wahl <steve.wahl@hpe.com> wrote:
> >
> > > On Thu, Oct 29, 2026 at 10:51:21AM +0000, David Laight wrote:
> > > > On Wed, 28 Oct 2026 14:58:12 -0500
> > > > Steve Wahl <steve.wahl@hpe.com> wrote:
> > > >
> > > > > On Wed, Oct 28, 2026 at 08:10:54AM -0700, Dave Hansen wrote:
> > > > ...
> > > > >
> > > > > For an example, I recently used this method to discover that at
> > > > > least one version of Intel's MPI library likes to read up
> > > > > /proc/kallsyms from each of the processes it starts, and somewhere
> > > > > north of 1000's of processors the atomic increment on opening
> > > > > kallsyms, implemented with a compare-exchange, becomes a hot lock
> > > > > and initialization that takes little time on a smaller number of
> > > > > processors, suddenly balloons to half an hour.
> > > >
> > > > I'm guessing that was pre-ARMv8.1 ??
> > >
> > > x86, not arm. And it was on a distro kernel, I didn't check the
> > > current community kernel because it was a situation where it was
> > > enough to understand what's going on in the distro kernel, and avoid
> > > the behavior in the application.
> >
> > x86 shouldn't have an exponential issue with cas.
> > Something else must have been going on.
>
> Well, the large majority of some 2000+ cpus were all stuck in
> use_pde() in inode.c, which is
>
> return likely(atomic_inc_unless_negative(&pde->in_use));
There will be one of those per read system call.
If the code is using a sane buffer length that isn't really that many at all
(unless you are running an 'allyesconfig' kernel).
Provided the library isn't doing something really silly like 1 byte reads!
It is possible that /proc/kallsyms could be marked PROC_ENTRY_PERMANENT
and so avoid that atomic operation.
>
> atomic_inc_unless_negative() has alternates, but I think there's no
> arch version for x86, so comes down to this:
>
> static __always_inline bool
> raw_atomic_inc_unless_negative(atomic_t *v)
> {
> int c = raw_atomic_read(v);
>
> do {
> if (unlikely(c < 0))
> return false;
> } while (!raw_atomic_try_cmpxchg(v, &c, c + 1));
>
> return true;
> }
>
> If you manage to synchronize thousands of processors among many NUMA
> nodes all trying to do that same thing, how can that not create a
> horrible cache coherency protocol traffic jam?
On x86, in order for the cmpxchg to fail it must have succeeded for
a different cpu (as far as I understand things...).
So yes, you get a lot of cache coherency traffic but progress should
be made - probably with a maximum total rate of increments that you
hit well before 1000 cpu hit the code path.
It might just be that with the large NUMA memory system the required number
of cache line bounces (one for each successful CAS) just takes that length
of time - but that is linear in the number of applications/cpus.
OTOH an LL/SC loop loses the cache when another cpu does the LL (aka read)
bit. So when heavily contended no cpu manages to do a successful write
and overall absolutely no progress is made.
The more instructions between the LL and SC the worse it gets.
David
>
> Thanks for your thoughts on this; if our hardware is supposed to be
> doing something to alleviate this and it's not, I / we want to know!
>
> --> Steve
>
> > David
> >
> > >
> > > > The LL/SC retry loops for atomics are completely broken for contended
> > > > operations.
> > > > The kernel needs to patch them to use the LSE (single instruction
> > > > atomics) for ARMv8.1 which guarantee that some progress is made.
> > > > A CAS loop can still get starved on a single CPU, but some CPU
> > > > do proceed.
> > > > You really don't want to use LL/LC on a system with hraair CPU.
> > > >
> > > > One CPU (not arm) that implements LL/SC locks the cache line for a
> > > > few clocks after LL to give a reasonable chance of the associated SC
> > > > actually succeeding before the cache line is 'stolen' by another CPU
> > > > doing an LL.
> > >
> > > Thanks,
> > >
> > > --> Steve
> > >
> >
>
prev parent reply other threads:[~2026-10-30 22:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 12:21 Peter Zijlstra
2026-10-28 14:15 ` H. Peter Anvin
2026-10-28 14:26 ` Peter Zijlstra
2026-10-28 15:10 ` Dave Hansen
2026-10-28 19:58 ` Steve Wahl
2026-10-29 8:46 ` Peter Zijlstra
2026-10-29 10:34 ` David Laight
2026-10-30 2:00 ` Masami Hiramatsu (Google)
2026-10-30 16:27 ` David Laight
2026-10-29 10:51 ` David Laight
2026-10-29 15:32 ` Steve Wahl
2026-10-30 16:28 ` David Laight
2026-10-30 20:56 ` Steve Wahl
2026-10-30 22:31 ` David Laight [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=20261030223146.0fae9291@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dimitri.sivanich@hpe.com \
--cc=hpa@zytor.com \
--cc=justin.ernst@hpe.com \
--cc=kyle.meyer@hpe.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=mmullins@fb.com \
--cc=peterz@infradead.org \
--cc=russ.anderson@hpe.com \
--cc=steve.wahl@hpe.com \
--cc=tglx@kernel.org \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®