From: Tejun Heo <tj@kernel.org>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Byungchul Park <byungchul.park@lge.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH] workqueue/lockdep: Explicitly initialize wq_barrier::done::map
Date: Thu, 17 Aug 2017 06:26:35 -0700 [thread overview]
Message-ID: <20170817132635.GE3238792@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <20170817094622.12915-1-boqun.feng@gmail.com>
On Thu, Aug 17, 2017 at 05:46:12PM +0800, Boqun Feng wrote:
> With CROSSRELEASE feature introduced, such a potential deadlock is
> reported:
>
> > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be released
> > Task B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> > Task C : acquired of lock#3 -> wait for completion of barr->done
> > (Task C is in lru_add_drain_all_cpuslocked())
> > Worker D : wait for wfc.work to be released -> will complete barr->done
>
> However, given this very case, such a dead lock could not happen because
> Task C's barr->done and Worker D's barr->done can not be the same
> instance. So this is a false positive.
>
> The reason of this false positive is we initialize all wq_barrier::done
> at insert_wq_barrier() via init_completion(), which makes them belong to
> the same lock class, therefore, impossible circles are reported.
>
> To fix this, explicitly initialize the lockdep map for wq_barrier::done
> in insert_wq_barrier(), so that the lock class key of wq_barrier::done
> is a subkey of the corresponding work_struct, as a result we won't build
> a dependency between a wq_barrier with a unrelated work, and we can
> differ wq barriers based on the related works, so the false positive
> above is avoided.
>
> Also define the empty lockdep_init_map_crosslock() for !CROSSRELEASE
> to make the code simple and away from unnecessary #ifdefs.
>
> Reported-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Cc: Byungchul Park <byungchul.park@lge.com>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
prev parent reply other threads:[~2017-08-17 13:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 9:46 [PATCH] workqueue/lockdep: Explicitly initialize wq_barrier::done::map Boqun Feng
2017-08-17 10:22 ` [tip:locking/core] locking/lockdep: " tip-bot for Boqun Feng
2017-08-17 13:26 ` Tejun Heo [this message]
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=20170817132635.GE3238792@devbig577.frc2.facebook.com \
--to=tj@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=byungchul.park@lge.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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