From: Tejun Heo <tj@kernel.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: linux-kernel@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
tytso@mit.edu
Subject: Re: [PATCH 3/3] kernel/workqueue: Suppress a false positive lockdep complaint
Date: Thu, 25 Oct 2018 08:37:34 -0700 [thread overview]
Message-ID: <20181025153734.GH4182586@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <20181025153657.GG4182586@devbig004.ftw2.facebook.com>
On Thu, Oct 25, 2018 at 08:36:57AM -0700, Tejun Heo wrote:
> Hello, Bart.
>
> On Thu, Oct 25, 2018 at 08:05:40AM -0700, Bart Van Assche wrote:
> > diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
> > index 60d673e15632..375ec764f148 100644
> > --- a/include/linux/workqueue.h
> > +++ b/include/linux/workqueue.h
> > @@ -344,6 +344,7 @@ enum {
> > __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
> > __WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */
> > __WQ_ORDERED_EXPLICIT = 1 << 19, /* internal: alloc_ordered_workqueue() */
> > + __WQ_HAS_BEEN_USED = 1 << 20, /* internal: work has been queued */
> >
> > WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */
> > WQ_MAX_UNBOUND_PER_CPU = 4, /* 4 * #cpus for unbound wq */
> > diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > index fc9129d5909e..0ef275fe526c 100644
> > --- a/kernel/workqueue.c
> > +++ b/kernel/workqueue.c
> > @@ -1383,6 +1383,10 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
> > if (unlikely(wq->flags & __WQ_DRAINING) &&
> > WARN_ON_ONCE(!is_chained_work(wq)))
> > return;
> > +
> > + if (!(wq->flags & __WQ_HAS_BEEN_USED))
> > + wq->flags |= __WQ_HAS_BEEN_USED;
> > +
> > retry:
> > if (req_cpu == WORK_CPU_UNBOUND)
> > cpu = wq_select_unbound_cpu(raw_smp_processor_id());
> > @@ -2889,7 +2893,7 @@ static bool start_flush_work(struct work_struct *work, struct wq_barrier *barr,
> > * workqueues the deadlock happens when the rescuer stalls, blocking
> > * forward progress.
> > */
> > - if (!from_cancel &&
> > + if (!from_cancel && (pwq->wq->flags & __WQ_HAS_BEEN_USED) &&
> > (pwq->wq->saved_max_active == 1 || pwq->wq->rescuer)) {
> > lock_acquire_exclusive(&pwq->wq->lockdep_map, 0, 0, NULL,
> > _THIS_IP_);
>
> We likely wanna skip the whole drain instead of eliding lockdep
> annotation here. Other than that, this patch looks fine to me but for
> the others, I think it'd be a better idea to listen to Johannes. We
> wanna annotate the users for the exceptions rather than weakening the
> workqueue lockdep checks, especially because workqueue related
> deadlocks can be pretty difficult to trigger and root cause
> afterwards.
Ooh, also, please only do the HAS_BEEN_USED marking if LOCKDEP is
enabled.
Thanks.
--
tejun
next prev parent reply other threads:[~2018-10-25 15:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 15:05 [PATCH 0/3] Suppress false positives triggered by workqueue lockdep annotations Bart Van Assche
2018-10-25 15:05 ` [PATCH 1/3] kernel/workqueue: Remove lockdep annotation from __flush_work() Bart Van Assche
2018-10-25 15:31 ` Johannes Berg
2018-10-25 15:57 ` Johannes Berg
2018-10-25 16:01 ` Bart Van Assche
2018-10-25 15:05 ` [PATCH 2/3] kernel/workqueue: Surround work execution with shared lock annotations Bart Van Assche
2018-10-25 16:53 ` Johannes Berg
2018-10-25 17:22 ` Bart Van Assche
2018-10-25 19:17 ` Johannes Berg
2018-10-25 15:05 ` [PATCH 3/3] kernel/workqueue: Suppress a false positive lockdep complaint Bart Van Assche
2018-10-25 15:34 ` Johannes Berg
2018-10-25 15:55 ` Bart Van Assche
2018-10-25 19:59 ` Johannes Berg
2018-10-25 20:21 ` Theodore Y. Ts'o
2018-10-25 20:26 ` Johannes Berg
2018-10-25 15:36 ` Tejun Heo
2018-10-25 15:37 ` Tejun Heo [this message]
2018-10-25 20:13 ` Johannes Berg
2018-10-25 15:40 ` Theodore Y. Ts'o
2018-10-25 17:02 ` Johannes Berg
2018-10-25 17:11 ` Bart Van Assche
2018-10-25 19:51 ` Johannes Berg
2018-10-25 20:39 ` Bart Van Assche
2018-10-25 20:47 ` Johannes Berg
2018-10-25 15:27 ` [PATCH 0/3] Suppress false positives triggered by workqueue lockdep annotations Johannes Berg
2018-10-25 15:47 ` Bart Van Assche
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=20181025153734.GH4182586@devbig004.ftw2.facebook.com \
--to=tj@kernel.org \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sagi@grimberg.me \
--cc=tytso@mit.edu \
/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).