Skip to content

timers: Provide timer_shutdown[_sync]()

Thomas Gleixner linux-bluetooth lkml netdev 3 versions – Applied

Status from this message: The following commit has been merged into the timers/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest17 patches 7 repliesApplied
  2. v217 patches 19 repliesSuperseded
  3. v115 patches 23 repliesSuperseded

Changes in v3 from the cover letter

- Fixed up change logs and comments (Anna-Maria)

- Picked up Reviewed-by tags

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/17Documentation: Remove bogus claim about del_timer_sync()Documentation/kernel-hacking/locking.rst Documentation/translations/it_IT/kernel-hacking/locking.rst+2 -51 reply
2/17ARM: spear: Do not use timer namespace for timer_shutdown() functionarch/arm/mach-spear/time.c+4 -40 replies
3/17clocksource/drivers/arm_arch_timer: Do not use timer namespace for timer_shutdown() functiondrivers/clocksource/arm_arch_timer.c+6 -60 replies
4/17clocksource/drivers/sp804: Do not use timer namespace for timer_shutdown() functiondrivers/clocksource/timer-sp804.c+3 -30 replies
5/17timers: Get rid of del_singleshot_timer_sync()drivers/char/tpm/tpm-dev-common.c drivers/staging/wlan-ng/hfa384x_usb.c drivers/staging/wlan-ng/prism2usb.c +3 more+9 -110 replies
6/17timers: Replace BUG_ON()skernel/time/timer.c+6 -50 replies
7/17timers: Update kernel-doc for various functionskernel/time/timer.c+92 -600 replies
8/17timers: Use del_timer_sync() even on UPinclude/linux/timer.h kernel/time/timer.c+1 -80 replies
9/17timers: Rename del_timer_sync() to timer_delete_sync()include/linux/timer.h kernel/time/timer.c+23 -100 replies
10/17timers: Rename del_timer() to timer_delete()include/linux/timer.h kernel/time/timer.c+17 -40 replies
11/17Documentation: Replace del_timer/del_timer_sync()Documentation/RCU/Design/Requirements/Requirements.rst Documentation/core-api/local_ops.rst Documentation/kernel-hacking/locking.rst +3 more+14 -150 replies
12/17timers: Silently ignore timers with a NULL functionkernel/time/timer.c+52 -52 replies
12/17timers: Silently ignore timers with a NULL functionkernel/time/timer.c+52 -51 reply
13/17timers: Split [try_to_]del_timer[_sync]() to prepare for shutdown modekernel/time/timer.c+92 -510 replies
14/17timers: Add shutdown mechanism to the internal functionskernel/time/timer.c+55 -91 reply
15/17timers: Provide timer_shutdown[_sync]()include/linux/timer.h kernel/time/timer.c+68 -00 replies
16/17timers: Update the documentation to reflect on the new timer_shutdown() APIDocumentation/RCU/Design/Requirements/Requirements.rst Documentation/core-api/local_ops.rst Documentation/kernel-hacking/locking.rst +1 more+8 -30 replies
17/17Bluetooth: hci_qca: Fix the teardown problem for realdrivers/bluetooth/hci_qca.c+8 -21 reply

Reviews trailers per patch

All 18 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJacob KellerGuenter RoeckArnd BergmannViresh KumarMarc ZyngierSteven Rostedt (Google)Luiz Augusto von DentzAnna-Maria Behnsen
SeriesR-b
1/17R-b
2/17R-b T-b R-b A-b A-b
3/17R-b T-b R-b A-b
4/17R-b T-b R-b
5/17R-b T-b
6/17R-b T-b
7/17R-b T-b
8/17R-b T-b
9/17R-b T-b R-b
10/17R-b T-b R-b
11/17R-b
12/17R-b R-b T-b T-b
12/17R-b R-b T-b T-b
13/17R-b T-b
14/17R-b T-b
15/17R-b T-b
16/17R-b T-b
17/17R-b T-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 8 reviewers.

Read the v3 thread

Cover letter [patch V3 00/17] timers: Provide timer_shutdown[_sync]()

This is the third version of the timer shutdown work. The second version can be found here:

https://lore.kernel.org/all/[email protected]

Tearing down timers can be tedious when there are circular dependencies to other things which need to be torn down. A prime example is timer and workqueue where the timer schedules work and the work arms the timer.

Steven and the Google Chromebook team ran into such an issue in the Bluetooth HCI code.

Steven suggested to create a new function del_timer_free() which marks the timer as shutdown. Rearm attempts of shutdown timers are discarded and he wanted to emit a warning for that case:

https://lore.kernel.org/all/[email protected]

This resulted in a lengthy discussion and suggestions how this should be implemented. The patch series went through several iterations and during the review of the last version it turned out that this approach is suboptimal:

https://lore.kernel.org/all/[email protected]

The warning is not really helpful because it's entirely unclear how it should be acted upon. The only way to address such a case is to add 'if (in_shutdown)' conditionals all over the place. This is error prone and in most cases of teardown like the HCI one which started this discussion not required all.

What needs to prevented is that pending work which is drained via destroy_workqueue() does not rearm the previously shutdown timer. Nothing in that shutdown sequence relies on the timer being functional.

The conclusion was that the semantics of timer_shutdown_sync() should be:

- timer is not enqueued
- timer callback is not running
- timer cannot be rearmed

Preventing the rearming of shutdown timers is done by discarding rearm attempts silently.

As Steven is short of cycles, I made some spare cycles available and reworked the patch series to follow the new semantics and plugged the races which were discovered during review.

The patches have been split up into small pieces to make review easier and I took the liberty to throw a bunch of overdue cleanups into the picture instead of proliferating the existing state further.

The last patch in the series addresses the HCI teardown issue for real.

The series is also available from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git timers

Changes vs. V2:

- Fixed up change logs and comments (Anna-Maria)

- Picked up Reviewed-by tags

Thanks,

tglx

---
 Documentation/RCU/Design/Requirements/Requirements.rst      |    2 
 Documentation/core-api/local_ops.rst                        |    2 
 Documentation/kernel-hacking/locking.rst                    |   17 
 Documentation/timers/hrtimers.rst                           |    2 
 Documentation/translations/it_IT/kernel-hacking/locking.rst |   14 
 Documentation/translations/zh_CN/core-api/local_ops.rst     |    2 
 arch/arm/mach-spear/time.c                                  |    8 
 drivers/bluetooth/hci_qca.c                                 |   10 
 drivers/char/tpm/tpm-dev-common.c                           |    4 
 drivers/clocksource/arm_arch_timer.c                        |   12 
 drivers/clocksource/timer-sp804.c                           |    6 
 drivers/staging/wlan-ng/hfa384x_usb.c                       |    4 
 drivers/staging/wlan-ng/prism2usb.c                         |    6 
 include/linux/timer.h                                       |   35 
 kernel/time/timer.c                                         |  425 +++++++++---
 net/sunrpc/xprt.c                                           |    2 
 16 files changed, 405 insertions(+), 146 deletions(-)