From: Waiman Long <longman@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
linux-arch@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Waiman Long <longman@redhat.com>
Subject: [PATCH v2 0/5] x86, locking/qspinlock: Allow lock to store lock holder cpu number
Date: Thu, 16 Jul 2020 15:29:22 -0400 [thread overview]
Message-ID: <20200716192927.12944-1-longman@redhat.com> (raw)
This patchset modifies the x86 qspinlock and qrwlock code to allow it to
store the lock holder cpu number (lock writer cpu number for qrwlock)
in the lock itself if feasible. This lock holder cpu information is
useful for debugging and crash dump analysis. It may also be useful to
architectures like PowerPC that needs the lock holder cpu number for
better paravirtual spinlock performance.
This capability is enabled on a per-architecture basis by defining
the macros __cpu_number_sadd1 (for qrwlock) and __cpu_number_sadd2
(for qspinlock). These macros define the architecture's way to get
to a percpu saturated +1 and +2 cpu number that can be used in the
lock byte of qspinlock and qrwlock.
This patchset enables it for the x86 architecture only. Additional
patches can be submitted later on to enable other architectures,
if desired.
I have run some locking microbenchmark with and without this patch. I
saw about 1% peformance degradation at low lock contention level, but
about 1% performance gain at high lock contention level. That slight
performance may be caused by a slight difference in the generated code
and may not be entirely due to the access of the percpu variable. Anyway,
that performance difference should be negligible for most real workloads.
Waiman Long (5):
x86/smp: Add saturated +1/+2 1-byte cpu numbers
locking/pvqspinlock: Make pvqsinlock code easier to read
locking/qspinlock: Pass lock value as function argument
locking/qspinlock: Make qspinhlock store lock holder cpu number
locking/qrwlock: Make qrwlock store writer cpu number
arch/x86/include/asm/qspinlock_paravirt.h | 42 +++++++++++------------
arch/x86/include/asm/spinlock.h | 5 +++
arch/x86/kernel/setup_percpu.c | 11 ++++++
include/asm-generic/qrwlock.h | 12 ++++++-
include/asm-generic/qspinlock.h | 10 ++++++
include/asm-generic/qspinlock_types.h | 2 +-
kernel/locking/qrwlock.c | 11 +++---
kernel/locking/qspinlock.c | 31 ++++++++---------
kernel/locking/qspinlock_paravirt.h | 35 ++++++++++---------
9 files changed, 97 insertions(+), 62 deletions(-)
--
2.18.1
next reply other threads:[~2020-07-16 19:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 19:29 Waiman Long [this message]
2020-07-16 19:29 ` [PATCH v2 1/5] x86/smp: Add saturated +1/+2 1-byte cpu numbers Waiman Long
2020-07-16 19:29 ` [PATCH v2 2/5] locking/pvqspinlock: Make pvqsinlock code easier to read Waiman Long
2020-07-16 19:29 ` [PATCH v2 3/5] locking/qspinlock: Pass lock value as function argument Waiman Long
2020-07-16 19:29 ` [PATCH v2 4/5] locking/qspinlock: Make qspinhlock store lock holder cpu number Waiman Long
2020-07-17 7:39 ` [locking/qspinlock] 45877ea393: BUG:spinlock_already_unlocked_on_CPU kernel test robot
2020-07-19 23:48 ` Waiman Long
2020-07-16 19:29 ` [PATCH v2 5/5] locking/qrwlock: Make qrwlock store writer cpu number Waiman Long
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=20200716192927.12944-1-longman@redhat.com \
--to=longman@redhat.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dave@stgolabs.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.com \
--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
Powered by JetHome