From: Byungchul Park <byungchul.park@lge.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
mingo@kernel.org, linux-kernel@vger.kernel.org,
walken@google.com
Subject: Re: [PATCH] lockdep: Add a document describing crossrelease feature
Date: Wed, 6 Jul 2016 11:17:10 +0900 [thread overview]
Message-ID: <20160706021710.GA2279@X58A-UD3R> (raw)
In-Reply-To: <20160706004943.GA20366@insomnia>
On Wed, Jul 06, 2016 at 08:49:43AM +0800, Boqun Feng wrote:
> On Mon, Jul 04, 2016 at 03:42:59PM +0900, Byungchul Park wrote:
> [snip]
> > > > +2. A lock has dependency with all locks in the releasing context, having
> > > > + been held since the lock was held.
> > >
> > > But you cannot tell this. The 'since the lock was held' thing fully
> > > depends on timing and is not fundamentally correct.
> > >
> > > lock(A)
> > > unlock(A)
> > > lock(A)
> > > wait_for(B)
> > > unlock(A)
> > > wake(B)
> > >
> > > Between the wait_for(B) and wake(B), _nothing_ has been held, yet still
> > > there's the deadlock potential.
I mis-understood this sentence. However, anyway this does not cause
deadlock. Of course it's deadlock if an example below actually happens.
We should not presume that the below can happen, once the above happened
because some dependencies between these contexts may prevent the below.
Therefore we should decide to check only when the actual problematic
sequence happens like below.
lock(A)
wait_for(B)
~~~~~~~~~~~~~~~~~~~~~~~~ <- serialized by atomic operation
lock(A)
unlock(A)
wake(B)
unlock(A)
So I meant crossrelease can detect this deadlock if actually deadlock
causable sequence happens at least once. I tried to avoid false positive
detection, in other words, I made lockdep's detection stronger only with
true positive ones.
Of course I want this crosslock to be stronger than current
implementation. However I have no idea to make even what peterz's example
can be detected regarding all dependency with avoiding false positive
detection. It should be a future work. But it will be not simple or
impossible.
> >
> > Crossreleas feature can detect this situation as a deadlock. wait_for()
> > is not an actual lock, but we can make it detectable by using acquring and
> > releasing semantics on wait_for() and wake().
> >
> > > And note that if the timing was 'right', you would never get to wake(B)
> > > because deadlock, so you'd never establish that there would be a
> > > deadlock.
> >
> > If a deadlock actually happens, then we cannot establish it as you said.
> > Remind that current lockdep does nothing for this situation. But at least
> > crossrelease feature can detect this deadlock possibility at the time the
> > dependency tree(graph) is built, which is better than doing nothing.
> >
>
> Confused, how?
And I am sorry for making you confused.
>
> Say the sequence of events is as follow:
>
> (two tasks are initially with no lock held)
>
> Task 1 Task 2
> ============= ====================
> lock(A)
> unlock(A)
> lock(A)
> wait_for(B) // acquire
> wake(B) // commit + release
> unlock(A)
>
As you know this is not actual deadlock.
> by the time, the commit are called, the dependency tree will be built,
> and we will find there is _no_ lock held before wake(B). Therefore at
> the release stage, you will end up only adding dependency chain A->B in
> the lockdep, right? And it looks like neither Task1 or Task2 will break
> the dependency chain A->B. So how can crossrelease detect the potential
> deadlock?
It's similar to how the crossrelease work, but a little bit different.
I will reinforce and resend the document later.
>
> It will be better, that you could provide some samples that crossrelease
> can detect after your confirmation.
Yes I will.
Thank you,
Byungchul
>
> Regards,
> Boqun
next prev parent reply other threads:[~2016-07-06 2:19 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 4:55 [RFC 00/12] lockdep: Implement crossrelease feature Byungchul Park
2016-06-20 4:55 ` [RFC 01/12] lockdep: Refactor lookup_chain_cache() Byungchul Park
2016-06-20 4:55 ` [RFC 02/12] lockdep: Add a function building a chain between two hlocks Byungchul Park
2016-06-20 4:55 ` [RFC 03/12] lockdep: Make check_prev_add can use a stack_trace of other context Byungchul Park
2016-06-20 4:55 ` [RFC 04/12] lockdep: Make save_trace can copy from other stack_trace Byungchul Park
2016-06-20 4:55 ` [RFC 05/12] lockdep: Implement crossrelease feature Byungchul Park
2016-06-30 13:03 ` Peter Zijlstra
2016-06-30 23:28 ` Byungchul Park
2016-06-20 4:55 ` [RFC 06/12] lockdep: Apply crossrelease to completion Byungchul Park
2016-06-20 4:55 ` [RFC 07/12] pagemap.h: Remove trailing white space Byungchul Park
2016-06-20 4:55 ` [RFC 08/12] lockdep: Apply crossrelease to PG_locked lock Byungchul Park
2016-06-30 13:04 ` Peter Zijlstra
2016-06-30 23:21 ` Byungchul Park
2016-07-01 8:10 ` Peter Zijlstra
2016-07-01 11:18 ` Kirill A. Shutemov
2016-07-04 4:30 ` Byungchul Park
2016-06-20 4:55 ` [RFC 09/12] cifs/file.c: Remove trailing white space Byungchul Park
2016-06-20 4:55 ` [RFC 10/12] mm/swap_state.c: " Byungchul Park
2016-06-20 4:55 ` [RFC 11/12] lockdep: Call lock_acquire(release) when accessing PG_locked manually Byungchul Park
2016-06-20 4:55 ` [RFC 12/12] x86/dumpstack: Optimize save_stack_trace Byungchul Park
2016-06-20 7:29 ` xinhui
2016-06-20 7:50 ` byungchul.park
2016-06-29 12:43 ` Byungchul Park
2016-06-30 10:38 ` xinhui
2016-06-30 23:06 ` Byungchul Park
2016-06-23 23:37 ` [RFC 00/12] lockdep: Implement crossrelease feature Byungchul Park
2016-06-24 7:08 ` Peter Zijlstra
2016-06-24 11:13 ` Byungchul Park
2016-06-24 11:26 ` Nikolay Borisov
2016-06-27 1:34 ` Byungchul Park
2016-07-01 4:15 ` [PATCH] lockdep: Add a document describing " Byungchul Park
2016-07-01 10:45 ` Peter Zijlstra
2016-07-04 6:42 ` Byungchul Park
2016-07-06 0:49 ` Boqun Feng
2016-07-06 2:17 ` Byungchul Park [this message]
2016-07-06 5:33 ` Byungchul Park
2016-07-06 7:56 ` Peter Zijlstra
2016-07-06 8:12 ` Byungchul Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160706021710.GA2279@X58A-UD3R \
--to=byungchul.park@lge.com \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=walken@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).