lkml.org 
[lkml]   [2019]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 24/28] locking/lockdep: Remove !dir in lock irq usage check
On Thu, Apr 25, 2019 at 10:03:36PM +0200, Peter Zijlstra wrote:
> On Wed, Apr 24, 2019 at 06:19:30PM +0800, Yuyang Du wrote:
> > In mark_lock_irq(), the following checks are performed:
> >
> > ----------------------------------
> > | -> | unsafe | read unsafe |
> > |----------------------------------|
> > | safe | F B | F* B* |
> > |----------------------------------|
> > | read safe | F? B* | - |
> > ----------------------------------
> >
> > Where:
> > F: check_usage_forwards
> > B: check_usage_backwards
> > *: check enabled by STRICT_READ_CHECKS
> > ?: check enabled by the !dir condition
> >
> > From checking point of view, the special F? case does not make sense,
> > whereas it perhaps is made for peroformance concern. As later patch will
> > address this issue, remove this exception, which makes the checks
> > consistent later.
> >
> > With STRICT_READ_CHECKS = 1 which is default, there is no functional
> > change.
>
> Oh man.. thinking required and it is way late.. anyway this whole read
> stuff made me remember we had a patch set on readlocks last year.
>
> https://lkml.kernel.org/r/20180411135110.9217-1-boqun.feng@gmail.com
>
> I remember reviewing that a few times and then it dropped on the floor,
> probably because Spectre crap or something sucked up all my time again :/

So if we look at Boqun's patches (as posted, I haven't looked at his
github, but I'm assuming this hasn't changed with the 'Shared' state),
we'll find he'll only does either 1 backward or 1 foward search (which
is already an improvement over the current state).

His mark_lock_irq() looks like:

static int
mark_lock_irq(struct task_struct *curr, struct *held_lock *this,
enum lock_usage_bit new_bit)
{
int excl_bit = exclusive_bit(new_bit);

+ if (new_bit & 2) {
+ /*
+ * mark ENABLED has to look backwards -- to ensure no dependee
+ * has USED_IN state, which, again, would allow recursion
+ * deadlocks.
+ */
+ if (!check_usage_backwards(curr, this, new_bit, excl_bit))
return 0;
+ } else {
+ /*
+ * mark USED_IN has to look forwards -- to ensure no dependency
+ * has ENABLED state, which would allow recursion deadlocks.
+ */
+ if (!check_usage_forwards(curr, this, new_bit, excl_bit))
return 0;
}

return 1;
}

Where '& 2' would read '& LOCK_USAGE_DIR_MASK' in the current code.

Now, I'm thinking you're proposing to replace the backward search for
USED_IN/safe with your reachable-safe state, which, if done on his
'strong' links, should still work.

That is; I _think_ the two patch-sets are not in conceptual conflict.

Of course; I could have missed something; I've just read both patchsets
again, and it's a bit much :-)

\
 
 \ /
  Last update: 2019-04-30 17:36    [W:0.099 / U:1.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site