[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20091015190024.GA31559@redhat.com>
Date: Thu, 15 Oct 2009 21:00:24 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Alan Cox <alan@...rguk.ukuu.org.uk>,
Paul Fulghum <paulkf@...rogate.com>,
Boyan <btanastasov@...oo.co.uk>,
"Rafael J. Wysocki" <rjw@...k.pl>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Kernel Testers List <kernel-testers@...r.kernel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Ed Tomlinson <edt@....ca>
Subject: Re: [Bug #14388] keyboard under X with 2.6.31
On 10/16, OGAWA Hirofumi wrote:
>
> > +void flush_delayed_work(struct delayed_work *dwork)
> > +{
> > + if (del_timer(&dwork->timer)) {
> > + struct cpu_workqueue_struct *cwq;
> > + cwq = wq_per_cpu(keventd_wq, get_cpu());
> > + __queue_work(cwq, &dwork->work);
> > + put_cpu();
> > + }
> > + flush_work(&dwork->work);
> > +}
> > +EXPORT_SYMBOL(flush_delayed_work);
> > +
> > +/**
>
> Sorry if I'm missing the point. Doesn't this have (possible) race with
> schedule_delayed_work() (i.e. by tty writer)?
>
> cpu0 cpu1
>
> if (del_timer(&dwork->timer)) {
If dwork->timer is pending - _PENDING must be set.
If del_timer() succeeds, nobody else can clear this bit.
> // cpu0 doesn't set _PENDING
> schedule_delayed_work()
and in this case schedule_delayed_work()->queue_delayed_work_on()
can't succeed because it does test_and_set_bit(_PENDING).
But. Since this helper was merged, I think it should use del_timer_sync()
to be correct. Yes, it is slower, but otherwise flush is racy.
And I think it should return a bolean to match flush_work(). IOW,
int flush_delayed_work(struct delayed_work *dwork)
{
int requeued = false;
if (del_timer(&dwork->timer)) {
struct cpu_workqueue_struct *cwq;
cwq = wq_per_cpu(keventd_wq, get_cpu());
__queue_work(cwq, &dwork->work);
put_cpu();
requeued = true;
}
return flush_work(&dwork->work) || requeued;
}
Not that I think this is terribly important, but still.
I'll send the patch.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists