[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <02f50037-46ce-ec08-63cb-e855694e69a5@redhat.com>
Date: Mon, 28 Mar 2022 16:18:57 +0200
From: David Hildenbrand <david@...hat.com>
To: Hillf Danton <hdanton@...a.com>, Waiman Long <longman@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>, MM <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [RFC] locking/rwsem: dont wake up wwaiter in case of lock holder
On 26.03.22 14:40, Hillf Danton wrote:
> In the slowpath of down for write, we bail out in case of signal received and
> try to wake up any pending waiter but it makes no sense to wake up a write
> waiter given any lock holder, either write or read.
But is handling this better really worth additional code and runtime
checks? IOW, does this happen often enough that we actually care about
optimizing this? I have no idea :)
>
> The RFC is do nothing for wwaiter if any lock holder present - they will fill
> their duty at lock release time.
>
> Only for thoughts now.
>
> Hillf
>
> --- x/kernel/locking/rwsem.c
> +++ y/kernel/locking/rwsem.c
> @@ -418,6 +418,8 @@ static void rwsem_mark_wake(struct rw_se
> waiter = rwsem_first_waiter(sem);
>
> if (waiter->type == RWSEM_WAITING_FOR_WRITE) {
> + if (RWSEM_LOCK_MASK & atomic_long_read(&sem->count))
> + return;
> if (wake_type == RWSEM_WAKE_ANY) {
> /*
> * Mark writer at the front of the queue for wakeup.
> --
>
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists