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

From: Waiman Long
Date: Wed May 11 2022 - 08:01:50 EST


On 5/11/22 03:20, Arnd Bergmann wrote:
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

Yes, it is based on the latest tip tree.

Cheers,
Longman