All of lore.kernel.org
 help / color / mirror / Atom feed
* (no subject)
@ 2012-08-08 18:10 Tejun Heo
  2012-08-08 18:10 ` [PATCH 1/4] timer: generalize timer->base flags handling Tejun Heo
                   ` (6 more replies)
  0 siblings, 7 replies; 31+ messages in thread
From: Tejun Heo @ 2012-08-08 18:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds, mingo, akpm, tglx, peterz

Timer internals are protected by irqsafe lock but the lock is
naturally dropped and irq enabled while a timer is executed.  This
makes dequeueing timer for execution and the actual execution
non-atomic against IRQs.  No matter what the timer function does, IRQs
can occur between timer dispatch and execution.  This means that an
IRQ handler could interrupt any timer in progress and it's impossible
for an IRQ handler to cancel and drain a timer.

This restriction manifests as ugly convolutions in workqueue
delayed_work interface.  A !idle delayed_work is either on timer,
being transferred from timer to worklist, on worklist, or executing.
There are interfaces which need to cancel a pending delayed_work -
cancel_delayed_work() and friends and mod_delayed_work().  They want
to cancel a work item in the first three states but it's impossible to
drain the second state from IRQ handlers which lead to the following
oddities.

* mod_delayed_work() can't be used from IRQ handlers.

* __cancel_delayed_work() can't use the usual try_to_grab_pending()
  which handles all three states but instead only deals with the first
  state using a separate implementation.  There's no way to make a
  delayed_work not pending from IRQ handlers.

* The context / behavior differences among cancel_delayed_work(),
  __cancel_delayed_work(), cancel_delayed_work_sync() are subtle and
  confusing (the first two are mostly historical tho).

This patchset implements irqsafe timers.  For an irqsafe timer, IRQ is
not enabled from dispatch till the end of its execution making it safe
to drain the timer regardless of context.  This will enable cleaning
up delayed_work interface.

This patchset contains the following four patches.

 0001-timer-generalize-timer-base-flags-handling.patch
 0002-timer-relocate-declarations-of-init_timer_on_stack_k.patch
 0003-timer-clean-up-timer-initializers.patch
 0004-timer-implement-TIMER_IRQSAFE.patch

0001 generalizes timer->base flags handling so that TIMER_IRQSAFE can
be added easily.

0002-0003 clean up initializers so that adding TIMER_IRQSAFE doesn't
need to duplicate init code multiple times.

0004 implements TIMER_IRQSAFE.

This patchset is also available in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git review-timer-irqsafe

Will soon post workqueue patchset which makes use of this.  If this
goes in, it would be great if this either goes through wq/for-3.7 or
gets its own branch somewhere so that it can be pulled into
wq/for-3.7.

Thanks.

 include/linux/timer.h |  161 ++++++++++++++++++--------------------------------
 kernel/timer.c        |  108 +++++++++++++++------------------
 2 files changed, 110 insertions(+), 159 deletions(-)

--
tejun

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

end of thread, other threads:[~2012-08-21 19:27 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-08 18:10 Tejun Heo
2012-08-08 18:10 ` [PATCH 1/4] timer: generalize timer->base flags handling Tejun Heo
2012-08-21 16:40   ` [tip:timers/core] timer: Generalize " tip-bot for Tejun Heo
2012-08-08 18:10 ` [PATCH 2/4] timer: relocate declarations of init_timer_on_stack_key() Tejun Heo
2012-08-21 16:41   ` [tip:timers/core] timer: Relocate " tip-bot for Tejun Heo
2012-08-08 18:10 ` [PATCH 3/4] timer: clean up timer initializers Tejun Heo
2012-08-21 16:42   ` [tip:timers/core] timer: Clean " tip-bot for Tejun Heo
2012-08-08 18:10 ` [PATCH 4/4] timer: implement TIMER_IRQSAFE Tejun Heo
2012-08-21 16:43   ` [tip:timers/core] timer: Implement TIMER_IRQSAFE tip-bot for Tejun Heo
2012-08-21 19:26     ` Tejun Heo
2012-08-08 18:13 ` $SUBJ should have been "[PATCHSET] timer: clean up initializers and implement irqsafe timers" Tejun Heo
2012-08-13 23:35 ` [PATCHSET] timer: clean up initializers and implement irqsafe timers Tejun Heo
2012-08-14  8:32   ` Thomas Gleixner
2012-08-14 19:16   ` Thomas Gleixner
2012-08-14 19:22     ` Tejun Heo
2012-08-14 21:03       ` Thomas Gleixner
2012-08-14 21:56         ` Tejun Heo
2012-08-14 22:45           ` Thomas Gleixner
2012-08-14 23:01             ` Tejun Heo
2012-08-14 23:33               ` Thomas Gleixner
2012-08-15  0:18                 ` Tejun Heo
2012-08-15 10:58                   ` Peter Zijlstra
2012-08-16 19:36                     ` Tejun Heo
2012-08-14 18:55 ` Thomas Gleixner
2012-08-14 19:15   ` Tejun Heo
2012-08-14 20:43     ` Thomas Gleixner
2012-08-14 21:40       ` Tejun Heo
2012-08-14 23:12         ` Thomas Gleixner
2012-08-14 23:27           ` Tejun Heo
2012-08-14 23:46             ` Thomas Gleixner
2012-08-14 23:52               ` Tejun Heo

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.