From: Peter Zijlstra <peterz@infradead.org>
To: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>, "Rafael J. Wysocki" <rjw@sisk.pl>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH UPDATED] workqueue: relax lockdep annotation on flush_work()
Date: Mon, 03 Jan 2011 16:14:45 +0100 [thread overview]
Message-ID: <1294067685.2016.83.camel@laptop> (raw)
In-Reply-To: <20110103150052.GU18831@htj.dyndns.org>
On Mon, 2011-01-03 at 16:00 +0100, Tejun Heo wrote:
> Hello,
>
> On Mon, Jan 03, 2011 at 03:54:50PM +0100, Peter Zijlstra wrote:
> > On Mon, 2011-01-03 at 15:17 +0100, Tejun Heo wrote:
> >
> > > @@ -2384,8 +2384,18 @@ static bool start_flush_work(struct work_struct *work, struct wq_barrier *barr,
> > > insert_wq_barrier(cwq, barr, work, worker);
> > > spin_unlock_irq(&gcwq->lock);
> > >
> > > - lock_map_acquire(&cwq->wq->lockdep_map);
> > > + /*
> > > + * If @max_active is 1 or rescuer is in use, flushing another work
> > > + * item on the same workqueue may lead to deadlock. Make sure the
> > > + * flusher is not running on the same workqueue by verifying write
> > > + * access.
> > > + */
> > > + if (cwq->wq->saved_max_active == 1 || cwq->wq->flags & WQ_RESCUER)
> > > + lock_map_acquire(&cwq->wq->lockdep_map);
> > > + else
> > > + lock_map_acquire_read(&cwq->wq->lockdep_map);
> > > lock_map_release(&cwq->wq->lockdep_map);
> > > +
> > > return true;
> > > already_gone:
> > > spin_unlock_irq(&gcwq->lock);
> >
> > Ah, but this violates the rule that you must always use the most strict
> > constraints. Code doesn't know if it will run in a rescue thread or not,
> > hence it must assume it does.
>
> Hmmm? The code applies the most strict contraints. If the workqueue
> has a rescuer, flushing another work from the workqueue will always
> trigger lockdep warning. The rule is relaxed only for workqueues
> which aren't used for memory reclaiming && support parallel execution.
Ah, ok. I read it like: if the current thread is a rescue thread.
next prev parent reply other threads:[~2011-01-03 15:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-29 12:57 [PATCH] workqueue: relax lockdep annotation on flush_work() Tejun Heo
2010-12-29 14:20 ` Rafael J. Wysocki
2011-01-03 9:31 ` Peter Zijlstra
2011-01-03 14:17 ` [PATCH UPDATED] " Tejun Heo
2011-01-03 14:54 ` Peter Zijlstra
2011-01-03 15:00 ` Tejun Heo
2011-01-03 15:14 ` Peter Zijlstra [this message]
2011-01-03 15:20 ` Tejun Heo
2011-01-03 15:29 ` Peter Zijlstra
2011-01-03 21:25 ` Rafael J. Wysocki
2011-01-09 22:34 ` Tejun Heo
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=1294067685.2016.83.camel@laptop \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rjw@sisk.pl \
--cc=tj@kernel.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