timers: Provide timer_shutdown[_sync]()
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
- v3 Latest17 patches 7 repliesApplied
- v217 patches 19 repliesSuperseded
- 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 files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/17 | Documentation: Remove bogus claim about del_timer_sync()Documentation/ Documentation/ | +2 | 1 reply | |
| 2/17 | ARM: spear: Do not use timer namespace for timer_shutdown() functionarch/ | +4 | 0 replies | |
| 3/17 | clocksource/drivers/arm_arch_timer: Do not use timer namespace for timer_shutdown() functiondrivers/ | +6 | 0 replies | |
| 4/17 | clocksource/drivers/sp804: Do not use timer namespace for timer_shutdown() functiondrivers/ | +3 | 0 replies | |
| 5/17 | timers: Get rid of del_singleshot_timer_sync()drivers/ drivers/ drivers/ +3 more | +9 | 0 replies | |
| 6/17 | timers: Replace BUG_ON()skernel/ | +6 | 0 replies | |
| 7/17 | timers: Update kernel-doc for various functionskernel/ | +92 | 0 replies | |
| 8/17 | timers: Use del_timer_sync() even on UPinclude/ kernel/ | +1 | 0 replies | |
| 9/17 | timers: Rename del_timer_sync() to timer_delete_sync()include/ kernel/ | +23 | 0 replies | |
| 10/17 | timers: Rename del_timer() to timer_delete()include/ kernel/ | +17 | 0 replies | |
| 11/17 | Documentation: Replace del_timer/del_timer_sync()Documentation/ Documentation/ Documentation/ +3 more | +14 | 0 replies | |
| 12/17 | timers: Silently ignore timers with a NULL functionkernel/ | +52 | 2 replies | |
| 12/17 | timers: Silently ignore timers with a NULL functionkernel/ | +52 | 1 reply | |
| 13/17 | timers: Split [try_to_]del_timer[_sync]() to prepare for shutdown modekernel/ | +92 | 0 replies | |
| 14/17 | timers: Add shutdown mechanism to the internal functionskernel/ | +55 | 1 reply | |
| 15/17 | timers: Provide timer_shutdown[_sync]()include/ kernel/ | +68 | 0 replies | |
| 16/17 | timers: Update the documentation to reflect on the new timer_shutdown() APIDocumentation/ Documentation/ Documentation/ +1 more | +8 | 0 replies | |
| 17/17 | Bluetooth: hci_qca: Fix the teardown problem for realdrivers/ | +8 | 1 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.
| Patch | Jacob Keller | Guenter Roeck | Arnd Bergmann | Viresh Kumar | Marc Zyngier | Steven Rostedt (Google) | Luiz Augusto von Dentz | Anna-Maria Behnsen |
|---|---|---|---|---|---|---|---|---|
| Series | R-b | |||||||
| 1/17 | R-b | |||||||
| 2/17 | R-b | T-b R-b | A-b | A-b | ||||
| 3/17 | R-b | T-b R-b | A-b | |||||
| 4/17 | R-b | T-b R-b | ||||||
| 5/17 | R-b | T-b | ||||||
| 6/17 | R-b | T-b | ||||||
| 7/17 | R-b | T-b | ||||||
| 8/17 | R-b | T-b | ||||||
| 9/17 | R-b | T-b | R-b | |||||
| 10/17 | R-b | T-b | R-b | |||||
| 11/17 | R-b | |||||||
| 12/17 | R-b R-b | T-b T-b | ||||||
| 12/17 | R-b R-b | T-b T-b | ||||||
| 13/17 | R-b | T-b | ||||||
| 14/17 | R-b | T-b | ||||||
| 15/17 | R-b | T-b | ||||||
| 16/17 | R-b | T-b | ||||||
| 17/17 | R-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.
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(-)