locking/rwsem: Allow slowpath writer to ignore handoff bit if not set by first waiter
Waiman Long authored
commit 6eebd5fb upstream.

With commit d257cc8c ("locking/rwsem: Make handoff bit handling more
consistent"), the writer that sets the handoff bit can be interrupted
out without clearing the bit if the wait queue isn't empty. This disables
reader and writer optimistic lock spinning and stealing.

Now if a non-first writer in the queue is somehow woken up or a new
waiter enters the slowpath, it can't acquire the lock.  This is not the
case before commit d257cc8c as the writer that set the handoff bit
will clear it when exiting out via the out_nolock path. This is less
efficient as the busy rwsem stays in an unlock state for a longer time.

In some cases, this new behavior may cause lockups as shown in [1] and
[2].

This patch allows a non-first writer to ignore the handoff bit if it
is not originally set or initiated by the first waiter. This patch is
shown to be effective in fixing...
27edf079
Name Last commit Last update
Documentation docs/kernel-parameters: Update descriptions for "mitigations=" param with retbleed
LICENSES LICENSES/LGPL-2.1: Add LGPL-2.1-or-later as valid identifiers
arch ARM: 9216/1: Fix MAX_DMA_ADDRESS overflow
block block: pop cached rq before potentially blocking rq_qos_throttle()
certs certs/blacklist_hashes.c: fix const confusion in certs blacklist
crypto crypto: memneq - move into lib/
drivers EDAC/synopsys: Re-enable the error interrupts on v3 hw
fs fs: sendfile handles O_NONBLOCK of out_fd
include net: Fix data-races around sysctl_[rw]mem(_offset)?.
init gcc-12: disable '-Warray-bounds' universally for now
ipc ipc/mqueue: use get_tree_nodev() in mqueue_get_tree()
kernel locking/rwsem: Allow slowpath writer to ignore handoff bit if not set by first waiter
lib ida: don't use BUG_ON() for debugging
mm page_alloc: fix invalid watermark check on a negative value
net tcp: Fix data-races around sysctl_tcp_workaround_signed_windows.
samples samples/landlock: Format with clang-format
scripts x86/retbleed: Add fine grained Kconfig knobs
security lockdown: Fix kexec lockdown bypass with ima policy
sound ASoC: SOF: Intel: disable IMR boot when resuming from ACPI S4 and S5 states
tools perf symbol: Correct address for bss symbols
usr Merge tag 'kbuild-v5.18-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
virt KVM: Don't null dereference ops->destroy
.clang-format genirq/msi: Make interrupt allocation less convoluted
.cocciconfig scripts: add Linux .cocciconfig for coccinelle
.get_maintainer.ignore Opt out of scripts/get_maintainer.pl
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.