Re: [PATCH 01/17] locking/lockdep: Add lock type enum to explicitly specify read or write locks

Yuyang Du
2019-05-14T01:32:07Z

Thanks for review.

On Mon, 13 May 2019 at 19:45, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Mon, May 13, 2019 at 05:11:47PM +0800, Yuyang Du wrote:
> > + * Note that we have an assumption that a lock class cannot ever be both
> > + * read and recursive-read.
>
> We have such locks in the kernel... see:
>
> kernel/qrwlock.c:queued_read_lock_slowpath()
>
> And yes, that is somewhat unfortunate, but hard to get rid of due to
> hysterical raisins.

That is ok, then LOCK_TYPE_RECURSIVE has to be 3 such that
LOCK_TYPE_RECURSIVE & LOCK_TYPE_READ != 0. I thought to do this in the
first place without assuming. Anyway, it is better to know.

And I guess in a task:

(1) read(X);
recursive_read(x); /* this is ok ? */

(2) recursive_read(x);
read(x) /* not ok ? */

Either way, very small change may need to be made.