From: Steve Wahl <steve.wahl@hpe.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: Steve Wahl <steve.wahl@hpe.com>,
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: Mon, 2 Nov 2026 16:14:46 -0600 [thread overview]
Message-ID: <aukLVl_22lVd9Auh@fedora> (raw)
In-Reply-To: <20261030223146.0fae9291@pumpkin>
On Fri, Oct 30, 2026 at 10:31:46PM +0000, David Laight wrote:
> 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!
I don't have the backtraces saved. For whatever reason, I'm left with
the impression that the processes I examined closely were all in the
open call, not the read call. But you're correct, it looks like reads
would sit on this too. That makes even more sense that it got stuck
as long as it did.
> It is possible that /proc/kallsyms could be marked PROC_ENTRY_PERMANENT
> and so avoid that atomic operation.
Maybe. That seems like a specific solution to a general problem.
Even if /proc/kallsyms is fixed, there will be others that are not.
And the right place to fix this is much in question. Is there a good
reason to read /proc/kallsyms 1000s of times? I doubt it. We
switched to a different MPI library that does not have this problem.
(I did not take this to the community for a number of reasons. I
didn't have time to make sure I could reproduce with the latest
version of the library, with the community kernel instead of the
distro kernel. I don't have a good explanation of why the library
would want to do it in the first place. We have a workaround for the
time being.)
My point was more that they're taking away the tool that I used to
figure this out.
> >
> > 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.
I think I disagree with the "one bounce for each successful CAS"
assertion; I think it's one bounce for each CAS, successful or not.
If there's any mechanism like a short term hold on the cache line
before it will relinquish ownership after a failure, perhaps in this
case the extra "unless negative" instructions are making the loop too
long? I don't know.
Thanks for your insight,
--> Steve Wahl
> 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
> > > >
> > >
> >
>
--
Steve Wahl, Hewlett Packard Enterprise
next prev parent reply other threads:[~2026-11-02 22:15 UTC|newest]
Thread overview: 16+ 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
2026-11-02 22:14 ` Steve Wahl [this message]
2026-11-02 13:33 ` Breno Leitao
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=aukLVl_22lVd9Auh@fedora \
--to=steve.wahl@hpe.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=david.laight.linux@gmail.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=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®