From: Peter Zijlstra <peterz@infradead.org>
To: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: "Shi-Wu, Lo(Gmail)" <shiwulo@gmail.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Mel Gorman" <mgorman@suse.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, "Theodore Ts'o" <tytso@mit.edu>
Subject: Re: A new spinlock for multicore (>16) platform
Date: Mon, 15 Jul 2024 11:54:11 +0200 [thread overview]
Message-ID: <20240715095411.GY27299@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <ZpRjDDKGq1F4cSBr@archie.me>
On Mon, Jul 15, 2024 at 06:45:16AM +0700, Bagas Sanjaya wrote:
> On Mon, Jul 15, 2024 at 01:07:40AM +0800, Shi-Wu, Lo(Gmail) wrote:
> > Dear Linux Contributors,
> > A detailed introduction to this method can be found in the following paper:
> > https://www.usenix.org/conference/osdi23/presentation/lo
So if I understand this right, the algorithm basically boils down to a
circular path and unlock will iterate this path looking for the next CPU
waiting.
The worst case wait-time is one full circle of the rotor, which is
bounded, so that's good.
The immediate problem however is that O(n) iteration on unlock, given
Linux runs on many big machines with 1e3 order of CPUs, which would be
quite terrible on low to medium contention.
You mention in Future work, to alleviate this unlock issue by switching
to a linked-list, whereby unlock would then become O(1). The problem
then becomes lock() needs to an insertion-sort, which needs to know the
rotor position (eg. current lock owner).
I don't think that is a much easier proposition -- notably uncontended
fast path doesn't (want) to track the rotor position, and in the worst
case you're still iterating 1e3 order CPUs.
Hierachical rotors come to mind, but complexity -- is it warranted?
> > Our laboratory is currently developing a system that can apply the
> > same optimization strategy to all multi-core processors. Below is our
> > plan.
> >
> > The New Method and Its Compatibility with qspinlock:
> > 1. The default algorithm in the Linux kernel remains qspinlock.
> > 2. A new file is created in /proc/routing_path, where a shortest path
> > can be input, for example:
> > sudo echo 1,2,3,4,16,17,18,19,5,6,7,8,11,12,13,14 > /proc/routing_path
> > 3. After inputting the shortest path, the kernel switches to using the
> > RON algorithm.
This is quite horrendous. If you cannot compute the OWCR from the
provided topology (CPUID on x86) 'nobody' is going to be using this.
Additionally, what locks are so contended that this gives a significant
performance gain, and can't we better rework the locking rather than the
lock implementation to alleviate this problem.
Eg. the futex hash lock is an oft cited example, but something like:
https://lkml.kernel.org/r/20230721105744.434742902@infradead.org
can significantly reduce this.
That is, in general is helps more to reduce lock contention rather than
to optimize the contention behaviour.
So which locks do you see sufficient contention on to make this
worthwhile and how much do you gain by doing this?
Additionally, per the paper there are Linux patches (albeit for rather
old kernel versions), why aren't those included?
next prev parent reply other threads:[~2024-07-15 9:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-14 17:07 Shi-Wu, Lo(Gmail)
2024-07-14 23:45 ` Bagas Sanjaya
2024-07-15 2:08 ` Waiman Long
2024-07-15 10:01 ` Shi-Wu, Lo(Gmail)
2024-07-15 9:54 ` Peter Zijlstra [this message]
2024-07-15 10:33 ` Shi-Wu, Lo(Gmail)
2024-07-16 18:10 ` Shi-Wu, Lo(Gmail)
2024-07-20 7:08 ` Bagas Sanjaya
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=20240715095411.GY27299@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bagasdotme@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=shiwulo@gmail.com \
--cc=tglx@linutronix.de \
--cc=tytso@mit.edu \
--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 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®