Re: [RFC tip/locking/lockdep v5 08/17] lockdep: Fix recursive read lock related safe->unsafe detection
From: Peter Zijlstra
Date: Fri Feb 23 2018 - 06:36:56 EST
On Fri, Feb 23, 2018 at 04:58:12PM +0800, Boqun Feng wrote:
> Hmm... think again, maybe I can combine case 1 with 3, and case 2 with
> 4, because each of them could share the same find_usage_backwards(), and
> find_usage_forwards() uses a usage_match_forwards() as follow for the
> match function:
>
> static inline int usage_match_forwards(struct lock_list *entry, void *bit)
> {
> enum lock_usage_bit ub = (enum lock_usage_bit)bit;
> unsigned long mask;
> unsigned long read_mask;
>
> /* mask out the read bit */
> ub &= ~1;
>
> mask = 1ULL << ub;
> read_mask = 1ULL << (ub + 1);
>
> return (entry->class->usage_mask & mask) || // *-> L2 and L2 is an irq-unsafe lock
> ((entry->class->usage_mask & read_mask) && !entry->is_rr); // N-> L2 and L2 is an irq-read-unsafe lock
> }
>
> Got a bus to catch, I can explain this later, if you need ;-)
Right, that's about what I was thinking of. Clearly that needs a wee
comment but it's much better.