From: Jarek Poplawski <jarkao2@o2.pl>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>
Subject: Re: Fw: [PATCH -mm] workqueue: debug possible endless loop in cancel_rearming_delayed_work
Date: Thu, 26 Apr 2007 14:59:18 +0200 [thread overview]
Message-ID: <20070426125918.GC3145@ff.dom.local> (raw)
In-Reply-To: <20070425144759.GA201@tv-sign.ru>
On Wed, Apr 25, 2007 at 06:47:59PM +0400, Oleg Nesterov wrote:
> On 04/25, Oleg Nesterov wrote:
> >
> > On 04/25, Jarek Poplawski wrote:
> > >
> > > Probably this is also possible without timer i.e.
> > > with queue_work.
> >
> > Yes, thanks. While adding cpu-hotplug check I forgot to add ->current_work
> > check, which is needed to actually implement this
> >
> > > > Note that cancel_rearming_delayed_work() now can handle the works
> > > > which re-arm itself via queue_work(), not only queue_delayed_work().
> >
> > part. I'll resend after fix.
>
> Hm. But can't we do better? Looks like we don't need to check ->current_work,
>
> void cancel_rearming_delayed_work(struct delayed_work *dwork)
> {
> struct work_struct *work = &dwork->work;
> struct cpu_workqueue_struct *cwq = get_wq_data(work);
> int done;
I don't understand, why you think cwq cannot be NULL here.
>
> do {
> done = 1;
> spin_lock_irq(&cwq->lock);
>
> if (!list_empty(&work->entry))
> list_del_init(&work->entry);
BTW, isn't needs_a_good_name needles after this and after del_timer positive?
> else if (test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work)))
> done = del_timer(&dwork->timer)
If this runs while a work function is fired in run_workqueue,
it sets _PENDING bit, but if the work skips rearming, we have probably
endless loop, again.
>
> spin_unlock_irq(&cwq->lock);
> } while (!done);
>
> /*
> * Nobody can clear WORK_STRUCT_PENDING. This means that the
> * work can't be re-queued and the timer can't be re-started.
> */
> needs_a_good_name(cwq->wq, work);
> work_clear_pending(work);
> }
>
> Jarek, I didn't think much about this, just a new idea. I am posting this code
> in a hope you can review it while I sleep on this... CPU-hotplug is ignored for
> now. Note that this version doesn't need the change in run_workqueue().
It's very interesting proposal, but also hard to analyse - the locks
are taken and given away, and there is hard to forsee, when and where
the loop regains the lock again. It is something alike to the current
way, with some added measures: you try to shoot a work on the run,
while queued or timer_pending, plus the _PENDING flag set, so it seems,
there is some risk of longer than planed looping.
I have to look at this more, at home and, if something new, I'll write
tomorrow. So, the good news, is you should have enough sleep this time!
Cheers,
Jarek P.
next prev parent reply other threads:[~2007-04-26 12:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070419002548.72689f0e.akpm@linux-foundation.org>
[not found] ` <20070419102122.GA93@tv-sign.ru>
2007-04-20 9:22 ` Fw: [PATCH -mm] workqueue: debug possible endless loop in cancel_rearming_delayed_work Jarek Poplawski
2007-04-20 17:08 ` Oleg Nesterov
2007-04-23 9:00 ` Jarek Poplawski
2007-04-23 16:33 ` Oleg Nesterov
2007-04-24 11:53 ` Jarek Poplawski
2007-04-24 18:55 ` Oleg Nesterov
2007-04-25 6:12 ` Jarek Poplawski
2007-04-25 12:20 ` Jarek Poplawski
2007-04-25 12:28 ` Jarek Poplawski
2007-04-25 12:47 ` Oleg Nesterov
2007-04-25 14:47 ` Oleg Nesterov
2007-04-26 12:59 ` Jarek Poplawski [this message]
2007-04-26 16:34 ` Oleg Nesterov
2007-04-27 5:26 ` Jarek Poplawski
2007-04-27 7:52 ` Oleg Nesterov
2007-04-27 9:03 ` Jarek Poplawski
2007-04-26 13:13 ` Jarek Poplawski
2007-04-26 16:44 ` Oleg Nesterov
2007-04-27 5:52 ` Jarek Poplawski
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=20070426125918.GC3145@ff.dom.local \
--to=jarkao2@o2.pl \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
/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