All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] timerfd: really wake up processes when timer is cancelled on clock change
@ 2011-06-03 20:53 Max Asbock
  2011-06-14 22:24 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Max Asbock @ 2011-06-03 20:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, kay.sievers, virtuoso, johnstul

When the system time is set the clock_was_set() function calls
timerfd_clock_was_set() to cancel and wake up processes waiting on
potential cancelable timerfd timers. However the wake up currently has
no effect because in the case of timerfd_read it is dependent on
ctx->ticks not being 0. timerfd_poll also requires ctx->ticks being non
zero. As a consequence processes waiting on cancelable timers only get
woken up when the timers expire. This patch fixes this by incrementing
ctx->ticks before calling wake_up.

Signed-off-by: Max Asbock <masbock@linux.vnet.ibm.com>
---

--- linux-3.0-rc1/fs/timerfd.c
+++ linux-3.0-rc1.timerfd/fs/timerfd.c
@@ -61,7 +61,9 @@ static enum hrtimer_restart timerfd_tmrp
 
 /*
  * Called when the clock was set to cancel the timers in the cancel
- * list.
+ * list. This will wake up processes waiting on these timers. The
+ * wake-up requires ctx->ticks to be non zero, therefore we increment
+ * it before calling wake_up_locked().
  */
 void timerfd_clock_was_set(void)
 {
@@ -76,6 +78,7 @@ void timerfd_clock_was_set(void)
 		spin_lock_irqsave(&ctx->wqh.lock, flags);
 		if (ctx->moffs.tv64 != moffs.tv64) {
 			ctx->moffs.tv64 = KTIME_MAX;
+			ctx->ticks++;
 			wake_up_locked(&ctx->wqh);
 		}
 		spin_unlock_irqrestore(&ctx->wqh.lock, flags);


-- 
Max Asböck



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] timerfd: really wake up processes when timer is cancelled on clock change
  2011-06-03 20:53 [PATCH] timerfd: really wake up processes when timer is cancelled on clock change Max Asbock
@ 2011-06-14 22:24 ` Andrew Morton
  2011-06-15 17:40   ` Max Asbock
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2011-06-14 22:24 UTC (permalink / raw)
  To: Max Asbock; +Cc: linux-kernel, tglx, kay.sievers, virtuoso, johnstul

On Fri, 03 Jun 2011 13:53:45 -0700 Max Asbock <masbock@linux.vnet.ibm.com> wrote:

> When the system time is set the clock_was_set() function calls
> timerfd_clock_was_set() to cancel and wake up processes waiting on
> potential cancelable timerfd timers. However the wake up currently has
> no effect because in the case of timerfd_read it is dependent on
> ctx->ticks not being 0. timerfd_poll also requires ctx->ticks being non
> zero. As a consequence processes waiting on cancelable timers only get
> woken up when the timers expire. This patch fixes this by incrementing
> ctx->ticks before calling wake_up.
> 
> Signed-off-by: Max Asbock <masbock@linux.vnet.ibm.com>
> ---
> 
> --- linux-3.0-rc1/fs/timerfd.c
> +++ linux-3.0-rc1.timerfd/fs/timerfd.c
> @@ -61,7 +61,9 @@ static enum hrtimer_restart timerfd_tmrp
>  
>  /*
>   * Called when the clock was set to cancel the timers in the cancel
> - * list.
> + * list. This will wake up processes waiting on these timers. The
> + * wake-up requires ctx->ticks to be non zero, therefore we increment
> + * it before calling wake_up_locked().
>   */
>  void timerfd_clock_was_set(void)
>  {
> @@ -76,6 +78,7 @@ void timerfd_clock_was_set(void)
>  		spin_lock_irqsave(&ctx->wqh.lock, flags);
>  		if (ctx->moffs.tv64 != moffs.tv64) {
>  			ctx->moffs.tv64 = KTIME_MAX;
> +			ctx->ticks++;
>  			wake_up_locked(&ctx->wqh);
>  		}
>  		spin_unlock_irqrestore(&ctx->wqh.lock, flags);

Do you think this fix should be backported into -stable kernels?  If so
(or if not), why?

It sounds like it _should_ be backported.  I wonder if that will break
any apps which depend on (or work around) the current behaviour.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] timerfd: really wake up processes when timer is cancelled on clock change
  2011-06-14 22:24 ` Andrew Morton
@ 2011-06-15 17:40   ` Max Asbock
  0 siblings, 0 replies; 3+ messages in thread
From: Max Asbock @ 2011-06-15 17:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Max Asbock, linux-kernel, tglx, kay.sievers, virtuoso, johnstul

On Tue, 2011-06-14 at 15:24 -0700, Andrew Morton wrote:
> On Fri, 03 Jun 2011 13:53:45 -0700 Max Asbock <masbock@linux.vnet.ibm.com> wrote:
> 
> Do you think this fix should be backported into -stable kernels?  If so
> (or if not), why?
> 

The feature this patch fixes has been introduced in 3.0, therefore there
is no need for a packport to stable kernels.

- Max


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-15 17:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-03 20:53 [PATCH] timerfd: really wake up processes when timer is cancelled on clock change Max Asbock
2011-06-14 22:24 ` Andrew Morton
2011-06-15 17:40   ` Max Asbock

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.