linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/36] hrtimer: Provide softirq context hrtimers
@ 2017-12-21 10:41 Anna-Maria Gleixner
  2017-12-21 10:41 ` [PATCH v4 01/36] timers: Use static keys for migrate_enable/nohz_active Anna-Maria Gleixner
                   ` (36 more replies)
  0 siblings, 37 replies; 78+ messages in thread
From: Anna-Maria Gleixner @ 2017-12-21 10:41 UTC (permalink / raw)
  To: LKML
  Cc: Thomas Gleixner, Peter Zijlstra, Ingo Molnar, keescook,
	Christoph Hellwig, John Stultz

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

---
v3..v4:

  - [PATCH 10/36] "hrtimer: Switch for loop to _ffs() evaluation": Add
    Joe Perches' annotation
    
  - [PATCH 28/36] "hrtimer: Implement support for softirq based
    hrtimers":
     - WARN_ON_ONCE() on non equality of HRTIMER_MODE_SOFT bit and
       hrtimer.is_soft at the begin of hrtimer_start_range_ns() and
       without holding hrtimer base lock to prevent a deadlock
     - Fold fix for remote soft hrtimer enqueue: Bug was reported-by
       Bert Schulze and fixed by Sebastian Siewior:
       https://lkml.kernel.org/r/20171214104755.7bnfwfv6mer2toe2@breakpoint.cc
     - Ensure to update softirq expires next after migrating hrtimer
       lists
     - Add bh_disable/enable() with a comment in hrtimers_dead_cpu():
       https://lkml.kernel.org/r/20171219085843.l55fasrfdqdyta5z@breakpoint.cc
     - Fix comment before __hrtimer_get_next_event(): use
       HRTIMER_ACTIVE_ALL instead of HRTIMER_ACTIVE

v2..v3:

  - Use static keys for migrate_enable and nohz_active
  - fix missing struct documentation
  - integrate Sebastian Siewiors suggestions and fix bug he mentioned:
    https://lkml.kernel.org/r/20171110124224.ykr6n4z7zgypojnb@breakpoint.cc


v1..v2:

  - integration of Peter Zijlstras patch:
    https://lkml.kernel.org/r/20170927164025.GI17526@worktop.programming.kicks-ass.net
  - using hrtimer_mode instead of additional hrtimer clock bases
  - folding the fix for updating the base offsets:
    https://lkml.kernel.org/r/20171006102820.ou4wpm56ed6m3ewr@linutronix.de
  - 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/wireless/mac80211_hwsim.c |   44 +-
 drivers/usb/gadget/function/f_ncm.c   |   30 -
 include/linux/hrtimer.h               |  113 +++--
 include/linux/interrupt.h             |   25 -
 include/net/xfrm.h                    |    2 
 include/trace/events/timer.h          |   37 +
 kernel/softirq.c                      |   51 --
 kernel/time/hrtimer.c                 |  650 +++++++++++++++++++++-------------
 kernel/time/tick-internal.h           |   13 
 kernel/time/tick-sched.c              |    2 
 kernel/time/timer.c                   |   98 ++---
 net/can/bcm.c                         |  156 ++------
 net/xfrm/xfrm_state.c                 |   30 -
 sound/drivers/dummy.c                 |   27 -
 15 files changed, 709 insertions(+), 631 deletions(-)

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

end of thread, other threads:[~2018-01-16 10:28 UTC | newest]

Thread overview: 78+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 10:41 [PATCH v4 00/36] hrtimer: Provide softirq context hrtimers Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 01/36] timers: Use static keys for migrate_enable/nohz_active Anna-Maria Gleixner
2017-12-22 15:45   ` [PATCH v5 " Sebastian Andrzej Siewior
2018-01-14 22:13     ` Thomas Gleixner
2018-01-14 22:30       ` [PATCH v6 " Thomas Gleixner
2018-01-11  4:25   ` [PATCH v4 " Frederic Weisbecker
2018-01-16  3:40   ` [tip:timers/core] hrtimer: Optimize the hrtimer code by using static keys for migration_enable/nohz_active tip-bot for Thomas Gleixner
2017-12-21 10:41 ` [PATCH v4 02/36] hrtimer: Correct blantanly wrong comment Anna-Maria Gleixner
2018-01-11 18:28   ` Frederic Weisbecker
2018-01-16  1:02   ` Ingo Molnar
2018-01-16  3:40   ` [tip:timers/core] hrtimer: Correct blatantly incorrect comment tip-bot for Thomas Gleixner
2017-12-21 10:41 ` [PATCH v4 03/36] hrtimer: Fix kerneldoc for struct hrtimer_cpu_base Anna-Maria Gleixner
2018-01-16  3:41   ` [tip:timers/core] hrtimer: Fix kerneldoc syntax for 'struct hrtimer_cpu_base' tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 04/36] hrtimer: Cleanup clock argument in schedule_hrtimeout_range_clock() Anna-Maria Gleixner
2018-01-16  3:41   ` [tip:timers/core] hrtimer: Clean up the 'int clock' parameter of schedule_hrtimeout_range_clock() tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 05/36] hrtimer: Fix hrtimer function description Anna-Maria Gleixner
2018-01-16  3:42   ` [tip:timers/core] hrtimer: Fix hrtimer_start[_range_ns]() function descriptions tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 06/36] hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers) Anna-Maria Gleixner
2018-01-16  3:42   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 07/36] hrtimer: Cleanup hrtimer_mode enum Anna-Maria Gleixner
2018-01-16  3:43   ` [tip:timers/core] hrtimer: Clean up 'enum hrtimer_mode' tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 08/36] tracing/hrtimer: Take all clock bases and modes into account Anna-Maria Gleixner
2018-01-16  3:43   ` [tip:timers/core] tracing/hrtimer: Fix tracing bugs by taking " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 09/36] tracing/hrtimer: Print hrtimer mode in hrtimer_start tracepoint Anna-Maria Gleixner
2018-01-16  3:43   ` [tip:timers/core] tracing/hrtimer: Print the hrtimer mode in the 'hrtimer_start' tracepoint tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 10/36] hrtimer: Switch for loop to _ffs() evaluation Anna-Maria Gleixner
2018-01-16  3:44   ` [tip:timers/core] hrtimer: Switch 'for' " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 11/36] hrtimer: Store running timer in hrtimer_clock_base Anna-Maria Gleixner
2018-01-16  3:44   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 12/36] hrtimer: Make room in struct hrtimer_cpu_base Anna-Maria Gleixner
2018-01-16  3:45   ` [tip:timers/core] hrtimer: Make room in 'struct hrtimer_cpu_base' tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 13/36] hrtimer: Reduce conditional code (hres_active) Anna-Maria Gleixner
2018-01-16  3:45   ` [tip:timers/core] hrtimer: Make the hrtimer_cpu_base::hres_active field unconditional, to simplify the code tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 14/36] hrtimer: Use accesor functions instead of direct access Anna-Maria Gleixner
2018-01-16  3:46   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 15/36] hrtimer: Make the remote enqueue check unconditional Anna-Maria Gleixner
2018-01-16  3:46   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 16/36] hrtimer: Make hrtimer_cpu_base.next_timer handling unconditional Anna-Maria Gleixner
2018-01-16  3:46   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 17/36] hrtimer: Make hrtimer_reprogramm() unconditional Anna-Maria Gleixner
2018-01-16  3:47   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 18/36] hrtimer: Make hrtimer_force_reprogramm() unconditionally available Anna-Maria Gleixner
2018-01-16  3:47   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 19/36] hrtimer: Unify handling of hrtimer remove Anna-Maria Gleixner
2018-01-16  3:48   ` [tip:timers/core] hrtimer: Unify hrtimer removal handling tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 20/36] hrtimer: Unify handling of remote enqueue Anna-Maria Gleixner
2018-01-16  3:48   ` [tip:timers/core] hrtimer: Unify remote enqueue handling tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 21/36] hrtimer: Make remote enqueue decision less restrictive Anna-Maria Gleixner
2018-01-16  3:49   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 22/36] hrtimer: Remove base argument from hrtimer_reprogram() Anna-Maria Gleixner
2018-01-16  3:49   ` [tip:timers/core] hrtimer: Remove the 'base' parameter " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 23/36] hrtimer: Split hrtimer_start_range_ns() Anna-Maria Gleixner
2018-01-16  3:49   ` [tip:timers/core] hrtimer: Factor out __hrtimer_start_range_ns() tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 24/36] hrtimer: Split __hrtimer_get_next_event() Anna-Maria Gleixner
2018-01-16  3:50   ` [tip:timers/core] hrtimer: Factor out __hrtimer_next_event_base() tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 25/36] hrtimer: Use irqsave/irqrestore around __run_hrtimer() Anna-Maria Gleixner
2018-01-16  3:50   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 26/36] hrtimer: Add clock bases and hrtimer mode for soft irq context Anna-Maria Gleixner
2018-01-16  3:51   ` [tip:timers/core] hrtimer: Add clock bases and hrtimer mode for softirq context tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 27/36] hrtimer: Prepare handling of hard and softirq based hrtimers Anna-Maria Gleixner
2018-01-16  3:51   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 28/36] hrtimer: Implement support for " Anna-Maria Gleixner
2018-01-16 10:22   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 29/36] hrtimer: Implement SOFT/HARD clock base selection Anna-Maria Gleixner
2018-01-16 10:22   ` [tip:timers/core] " tip-bot for Anna-Maria Gleixner
2017-12-21 10:41 ` [PATCH v4 30/36] can/bcm: Replace hrtimer_tasklet with softirq based hrtimer Anna-Maria Gleixner
2017-12-21 10:42 ` [PATCH v4 31/36] mac80211_hwsim: Replace hrtimer tasklet with softirq hrtimer Anna-Maria Gleixner
2018-01-04 15:12   ` Johannes Berg
2018-01-04 15:18     ` Thomas Gleixner
2017-12-21 10:42 ` [PATCH v4 32/36] xfrm: " Anna-Maria Gleixner
2017-12-21 10:42 ` [PATCH v4 33/36] softirq: Remove tasklet_hrtimer Anna-Maria Gleixner
2017-12-21 10:42 ` [PATCH v4 34/36] ALSA/dummy: Replace tasklet with softirq hrtimer Anna-Maria Gleixner
2018-01-16 10:23   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2017-12-21 10:42 ` [PATCH v4 35/36] usb/gadget/NCM: " Anna-Maria Gleixner
2018-01-16 10:23   ` [tip:timers/core] " tip-bot for Thomas Gleixner
2017-12-21 10:42 ` [PATCH v4 36/36] net/mvpp2: " Anna-Maria Gleixner
2018-01-16  1:39 ` [PATCH v4 00/36] hrtimer: Provide softirq context hrtimers Ingo Molnar
2018-01-16  2:03   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).