lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 4 Feb 2011 12:13:01 +0100
From:	Tejun Heo <tj@...nel.org>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Jens Axboe <axboe@...nel.dk>,
	Faisal Latif <faisal.latif@...el.com>,
	Roland Dreier <roland@...nel.org>,
	Sean Hefty <sean.hefty@...el.com>,
	Hal Rosenstock <hal.rosenstock@...il.com>,
	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Alessandro Rubini <rubini@...l.unipv.it>,
	Trond Myklebust <Trond.Myklebust@...app.com>,
	Mark Fasheh <mfasheh@...e.com>,
	Joel Becker <jlbec@...lplan.org>,
	"David S. Miller" <davem@...emloft.net>,
	"John W. Linville" <linville@...driver.com>,
	Johannes Berg <johannes@...solutions.net>,
	Yong Zhang <yong.zhang0@...il.com>
Subject: Re: [PATCH 4/4] workqueue: Remove now superfluous
 cancel_delayed_work() calls

Hello, Peter.

On Thu, Feb 03, 2011 at 06:45:41PM +0100, Peter Zijlstra wrote:
> On Thu, 2011-02-03 at 17:19 +0100, Tejun Heo wrote:
> > On Thu, Feb 03, 2011 at 03:09:44PM +0100, Peter Zijlstra wrote:
> > > Since queue_delayed_work() can now deal with existing timers, we don't
> > > need to explicitly call cancel_delayed_work() anymore.
> > 
> > This is nice but there's small complication with the way
> > queue_delayed_work() behaves.  If a delayed work item is already
> > pending, another queue_delayed_work() doesn't modify the delay whether
> > the new delay is longer or shorter than the current one.  The previous
> > patch doesn't really change the behavior as the whole thing is gated
> > with WORK_STRUCT_PENDING_BIT.
> > 
> > So, cancel_delayed_work() followed by queue_delayed_work() schedules
> > the work to be executed at the specified time regardless of the
> > current pending state while queue_delayed_work() takes effect iff
> > currently the work item is not pending.
> 
> Right, I didn't think it would matter much, the difference is tiny. Only
> a small window between the timer triggering and the work getting
> scheduled has a different semantics, it used to be the same as before
> that window, now its like after that window.
> 
> Since its all timing the code needs to deal with those cases anyway, no?

No, AFAICS the change from add_timer() to mod_timer() doesn't make any
difference.  The control never reaches there if the work item is
already pending.  Please consider the following two sequences.

seq1.	queue_delayed_work(wq, dwork, 10*HZ);
	cancel_delayed_work(dwork);
	queue_delayed_work(wq, dwork, 5*HZ);

seq2.	queue_delayed_work(wq, dwork, 10*HZ);
	queue_delayed_work(wq, dwork, 5*HZ);

With or without the patch, dwork in seq1 will execute in 5 seconds,
and, again, with our without the patch dwork in seq2 will execute in
10 seconds, because queueing is gated by WORK_STRUCT_PENDING_BIT and
if the bit is already set the timer isn't modified at all.

IOW, those cancel_delayed_work()'s are there not because
queue_delayed_work() calls add_timer() instead of mod_timer().
They're there because queue_delayed_work() always uses the first
timeout duration and the users want to change it to a new value.

As I wrote before, I'm not a fan of the current behavior but that's
how it is currently.  This patch series doesn't change the behavior
because the timers are guaranteed to be offline when
queue_delayed_work_on() calls add_timer().  To actually change the
behavior, queue_delayed_work_on() needs to be restructured and all its
users audited.

Thank you.

-- 
tejun
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ