Skip to content

hrtimer: Provide softirq context hrtimers

Anna-Maria Gleixner alsa-devel linux-can linux-wireless lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest36 of 37 patches 10 repliesIn review
  2. v125 patches 41 repliesSuperseded

36 of 37 patches are in this archive. The cover letter announces 37.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/37hrtimer: Correct blantanly wrong commentkernel/time/hrtimer.c+3 -30 replies
2/37hrtimer: Fix kerneldoc for struct hrtimer_cpu_baseinclude/linux/hrtimer.h+4 -40 replies
3/37hrtimer: Cleanup clock argument in schedule_hrtimeout_range_clock()include/linux/hrtimer.h kernel/time/hrtimer.c+7 -70 replies
4/37hrtimer: Fix hrtimer function descriptioninclude/linux/hrtimer.h kernel/time/hrtimer.c+8 -70 replies
5/37hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers)kernel/time/hrtimer.c+6 -10 replies
6/37hrtimer: Cleanup hrtimer_mode enuminclude/linux/hrtimer.h+11 -50 replies
7/37tracing: hrtimer: Take all clock bases and modes into accountinclude/trace/events/timer.h+16 -40 replies
8/37tracing: hrtimer: Print hrtimer mode in hrtimer_start tracepointinclude/trace/events/timer.h kernel/time/hrtimer.c+17 -120 replies
9/37hrtimer: Switch for loop to _ffs() evaluationkernel/time/hrtimer.c+21 -100 replies
10/37hrtimer: Store running timer in hrtimer_clock_baseinclude/linux/hrtimer.h kernel/time/hrtimer.c+22 -260 replies
11/37hrtimer: Change boolean struct members into bitfieldinclude/linux/hrtimer.h kernel/time/timer.c+6 -40 replies
12/37hrtimer: Make room in struct hrtimer_cpu_baseinclude/linux/hrtimer.h+2 -20 replies
13/37hrtimer: Reduce conditional code (hres_active)include/linux/hrtimer.h kernel/time/hrtimer.c+23 -280 replies
14/37hrtimer: Use accesor functions instead of direct accesskernel/time/hrtimer.c+2 -20 replies
15/37hrtimer: Make the remote enqueue check unconditionalinclude/linux/hrtimer.h kernel/time/hrtimer.c+9 -230 replies
16/37hrtimer: Make hrtimer_cpu_base.next_timer handling unconditionalinclude/linux/hrtimer.h kernel/time/hrtimer.c+4 -120 replies
17/37hrtimer: Make hrtimer_reprogramm() unconditionalinclude/linux/hrtimer.h kernel/time/hrtimer.c+65 -700 replies
18/37hrtimer: Reduce conditional code and make hrtimer_force_reprogramm() unconditionalkernel/time/hrtimer.c+28 -300 replies
19/37hrtimer: Unify handling of hrtimer removekernel/time/hrtimer.c+4 -60 replies
20/37hrtimer: Unify handling of remote enqueuekernel/time/hrtimer.c+7 -120 replies
21/37hrtimer: Make remote enqueue decision less restrictivekernel/time/hrtimer.c+1 -10 replies
22/37hrtimer: Remove base argument from hrtimer_reprogram()kernel/time/hrtimer.c+3 -30 replies
23/37hrtimer: Split hrtimer_start_range_ns()kernel/time/hrtimer.c+24 -200 replies
24/37hrtimer: Split __hrtimer_get_next_event()kernel/time/hrtimer.c+16 -40 replies
25/37hrtimer: Use irqsave/irqrestore around __run_hrtimer()kernel/time/hrtimer.c+18 -130 replies
26/37hrtimer: Add clock bases and hrtimer mode for soft irq contextinclude/linux/hrtimer.h include/trace/events/timer.h kernel/time/hrtimer.c+39 -10 replies
27/37hrtimer: Prepare handling of hard and softirq based hrtimerskernel/time/hrtimer.c+29 -90 replies
28/37hrtimer: Implement support for softirq based hrtimersinclude/linux/hrtimer.h kernel/time/hrtimer.c+174 -312 replies
29/37hrtimer: Implement SOFT/HARD clock base selectionkernel/time/hrtimer.c+11 -40 replies
30/37can/bcm: Replace hrtimer_tasklet with softirq based hrtimernet/can/bcm.c+52 -1041 reply
31/37mac80211_hwsim: Replace hrtimer tasklet with softirq hrtimerdrivers/net/wireless/mac80211_hwsim.c+20 -245 replies
32/37xfrm: Replace hrtimer tasklet with softirq hrtimerinclude/net/xfrm.h net/xfrm/xfrm_state.c+19 -130 replies
33/37softirq: Remove tasklet_hrtimerinclude/linux/interrupt.h kernel/softirq.c+0 -760 replies
34/37ALSA/dummy: Replace tasklet with softirq hrtimersound/drivers/dummy.c+12 -151 reply
36/37usb/gadget/NCM: Replace tasklet with softirq hrtimerdrivers/usb/gadget/function/f_ncm.c+7 -230 replies
37/37net/mvpp2: Replace tasklet with softirq hrtimerdrivers/net/ethernet/marvell/mvpp2.c+25 -370 replies

Reviews trailers per patch

2 of 36 patches have a Reviewed-by or Acked-by.

PatchTakashi IwaiOliver Hartkopp
1/37
2/37
3/37
4/37
5/37
6/37
7/37
8/37
9/37
10/37
11/37
12/37
13/37
14/37
15/37
16/37
17/37
18/37
19/37
20/37
21/37
22/37
23/37
24/37
25/37
26/37
27/37
28/37
29/37
30/37A-b
31/37
32/37
33/37
34/37R-b
36/37
37/37

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/37] hrtimer: Provide softirq context hrtimers

There are quite some places in the kernel which use a combination of hrtimers and tasklets to make use of the precise expiry of hrtimers, which schedule a tasklet to bring the actual function into softirq context.

This was introduced when the previous hrtimer softirq code was removed. That code was implemented by expiring the timer in hard irq context and then deferring the execution of the callback into softirq context. That caused a lot of pointless shuffling between the rbtree and a linked list.

In recent discussions it turned out that more potential users of hrtimers in softirq context might come up. Aside of that the RT patches need this functionality as well to defer hrtimers into softirq context if their callbacks are not interrupt safe on RT.

This series implements a new approach by adding SOFT hrtimer mode and instead of doing the list shuffle, timers started with this mode are put into separate soft expiry hrtimer queues. These queues are evaluated only when the hardirq context detects that the first expiring timer in the softirq queues has expired. That makes the overhead in the hardirq context minimal.

The series reworks the code to reuse as much as possible from the existing facilities for the new softirq hrtimers and integrates them with all flavours of hrtimers (HIGH_RES=y/n - NOHZ=y/n).

To achieve this quite some of the conditionals in the existing code are removed for the price of adding some pointless data and state tracking to the HIGH_RES=n case. That's minimal, but well worth it as it increases the readability and maintainability of the code.

The first part of the series implements the new functionality and the second part converts the hrtimer/tasklet users to make use of it and removes struct hrtimer_tasklet and the surrounding helper functions.

This series is available from git as well:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.timers

Thanks,

Anna-Maria

---
v1..v2:

- integration of Peter Zijlstras patch:

    https://lkml.kernel.org/r/[email protected]
  - using hrtimer_mode instead of additional hrtimer clock bases
  - folding the fix for updating the base offsets:
    https://lkml.kernel.org/r/[email protected]

- rework of 08/25 - 10/25 (all of those patches are facing reduction of conditional code) and make hrtimer_force_reprogram() unconditional as well
- integration of new versions of "ALSA/dummy: Replace tasklet with softirq hrtimer" and "net/cdc_ncm: Replace tasklet with softirq hrtimer"
- additional hrtimer/tasklet user conversion: "net/mvpp2: Replace tasklet with softirq hrtimer"
- additional fixes of several wrong comments
- update hrtimer tracing (mode and clock bases)

 drivers/net/ethernet/marvell/mvpp2.c  |   62 +--
 drivers/net/usb/cdc_ncm.c             |   38 --
 drivers/net/wireless/mac80211_hwsim.c |   44 +-
 drivers/usb/gadget/function/f_ncm.c   |   30 -
 include/linux/hrtimer.h               |  110 +++---
 include/linux/interrupt.h             |   25 -
 include/linux/usb/cdc_ncm.h           |    1 
 include/net/xfrm.h                    |    2 
 include/trace/events/timer.h          |   37 +-
 kernel/softirq.c                      |   51 --
 kernel/time/hrtimer.c                 |  623 +++++++++++++++++++++-------------
 kernel/time/timer.c                   |    6 
 net/can/bcm.c                         |  156 ++------
 net/xfrm/xfrm_state.c                 |   30 -
 sound/drivers/dummy.c                 |   27 -
 15 files changed, 652 insertions(+), 590 deletions(-)