Re: pagecache locking

From: Boaz Harrosh
Date: Tue Jul 02 2019 - 21:26:00 EST


On 03/07/2019 04:07, Patrick Farrell wrote:
> Recursively read locking is generally unsafe, thatâs why lockdep
> complains about it. The common RW lock primitives are queued in
> their implementation, meaning this recursive read lock sequence:
> P1 - read (gets lock)
> P2 - write
> P1 - read
>
> Results not in a successful read lock, but P1 blocking behind P2,
> which is blocked behind P1.

> Readers are not allowed to jump past waiting writers.

OK thanks that makes sense. I did not know about that last part. Its a kind
of a lock fairness I did not know we have.

So I guess I'll keep my two locks than. The write_locker is the SLOW
path for me anyway, right?

[if we are already at the subject, Do mutexes have the same lock fairness as
above? Do the write_lock side of rw_sem have same fairness? Something I never
figured out]

Thanks
Boaz

>
> - Patrick