Re: [PATCH 2/2] locking/qrwlock: Reduce cacheline contention for rwlocks used in interrupt context

From: Arnd Bergmann
Date: Wed May 11 2022 - 03:21:36 EST


On Tue, May 10, 2022 at 9:21 PM Waiman Long <longman@xxxxxxxxxx> wrote:
>
> Even though qrwlock is supposed to be a fair lock, it does allow readers
> from interrupt context to spin on the lock until it can acquire it making
> it not as fair. This exception was added due to the requirement to allow
> recursive read lock in interrupt context. This can also be achieved by
> just ignoring the writer waiting bit without spinning on the lock.
>
> By making this change, we make qrwlock a bit more fair and eliminating
> the problem of cacheline bouncing for rwlocks that are used heavily in
> interrupt context, like the networking stack. This should also reduce
> the chance of lock starvation for those interrupt context rwlocks.
>
> Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
> ---
> include/asm-generic/qrwlock.h | 6 +++---
> kernel/locking/qrwlock.c | 17 ++++++-----------
> 2 files changed, 9 insertions(+), 14 deletions(-)

I have no opinion on the change itself, but I made sure this does
not conflict with the generic ticket spinlock changes that I merged
in the asm-generic tree, since those also touch the comments in
qrwlock.h [1]

I assume you are merging both patches through the tip tree, so

Acked-by: Arnd Bergmann <arnd@xxxxxxxx> # for asm-generic

If you want me to pick them up in the asm-generic tree instead,
just let me know.

Arnd

[1] https://lore.kernel.org/lkml/20220509222956.2886-4-palmer@xxxxxxxxxxxx/