hrtimer/tick: Optimizations, cleanups and solutions for various issues
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest38 of 39 patches 22 repliesIn review
38 of 39 patches are in this archive. The cover letter announces 39.
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/39 | hrtimer: Update active_bases before calling hrtimer_force_reprogram()kernel/ | +3 | 0 replies | |
| 2/39 | hrtimer: Get rid of the resolution field in hrtimer_clock_baseinclude/ kernel/ kernel/ | +17 | 3 replies | |
| 3/39 | net: sched: Use hrtimer_resolution instead of hrtimer_get_res()net/ | +1 | 1 reply | |
| 4/39 | sound: Use hrtimer_resolution instead of hrtimer_get_res()sound/ sound/ | +7 | 2 replies | |
| 5/39 | hrtimer: Get rid of hrtimer_get_res()include/ kernel/ kernel/ +1 more | +15 | 0 replies | |
| 6/39 | hrtimer: Make the statistics fields smallerinclude/ kernel/ kernel/ | +7 | 0 replies | |
| 7/39 | hrtimer: Get rid of softirq timeinclude/ kernel/ kernel/ +1 more | +64 | 0 replies | |
| 8/39 | hrtimer: Make offset update smarterinclude/ include/ kernel/ +2 more | +26 | 1 reply | |
| 9/39 | hrtimer: Use a bits for various boolean indicatorsinclude/ kernel/ | +19 | 0 replies | |
| 10/39 | hrtimer: Use cpu_base->active_base for hotpath iteratorskernel/ | +8 | 3 replies | |
| 11/39 | hrtimer: Cache line align the hrtimer cpu baseinclude/ | +1 | 0 replies | |
| 12/39 | hrtimer: Align the hrtimer clock bases as wellinclude/ | +9 | 0 replies | |
| 13/39 | timerqueue: Let timerqueue_add/del return informationinclude/ lib/ | +11 | 0 replies | |
| 14/39 | hrtimer: Make use of timerqueue_add/del return valueskernel/ | +2 | 0 replies | |
| 15/39 | hrtimer: Keep pointer to first timer and simplify __remove_hrtimer()include/ kernel/ | +34 | 0 replies | |
| 16/39 | hrtimer: Get rid of hrtimer softirqinclude/ include/ include/ +3 more | +44 | 0 replies | |
| 17/39 | tick: sched: Remove hrtimer_active() checkskernel/ | +4 | 1 reply | |
| 18/39 | tick: sched: Force tick interrupt and get rid of softirq magickernel/ | +29 | 5 replies | |
| 19/39 | tick: sched: Restructure codekernel/ | +82 | 0 replies | |
| 20/39 | tick: nohz: Rework next timer evaluationinclude/ include/ include/ +8 more | +107 | 2 replies | |
| 21/39 | x86: perf: Use hrtimer_start()arch/ | +2 | 0 replies | |
| 22/39 | x86: perf: uncore: Use hrtimer_start()arch/ | +2 | 0 replies | |
| 23/39 | perf: core: Use hrtimer_start()kernel/ | +3 | 0 replies | |
| 24/39 | sched: core: Use hrtimer_start[_expires]()kernel/ kernel/ | +9 | 0 replies | |
| 25/39 | sched: deadline: Use hrtimer_start()kernel/ | +2 | 0 replies | |
| 26/39 | hrtimer: Get rid of __hrtimer_start_range_ns()include/ kernel/ | +15 | 0 replies | |
| 27/39 | hrtimer: Make hrtimer_start() a inline wrapperinclude/ kernel/ | +17 | 0 replies | |
| 28/39 | hrtimer: Remove bogus hrtimer_active() checkkernel/ | +0 | 0 replies | |
| 29/39 | hrtimer: Rmove bogus hrtimer_active() checkkernel/ | +1 | 0 replies | |
| 30/39 | rtmutex: Remove bogus hrtimer_active() checkkernel/ | +1 | 0 replies | |
| 31/39 | net: core: pktgen: Remove bogus hrtimer_active() checknet/ | +0 | 1 reply | |
| 32/39 | alarmtimer: Get rid of unused return valueinclude/ kernel/ | +6 | 0 replies | |
| 34/39 | tick: broadcast-hrtimer: Remove overly clever return value abusekernel/ | +5 | 1 reply | |
| 35/39 | hrtimer: Remove hrtimer_start() return valueinclude/ include/ kernel/ | +19 | 0 replies | |
| 36/39 | hrtimer: Avoid locking in hrtimer_cancel() if timer not activekernel/ | +9 | 0 replies | |
| 37/39 | staging: ozwpan: Remove hrtimer_active() checkdrivers/ | +3 | 0 replies | |
| 38/39 | timer: Remove pointless return value of do_usleep_range()kernel/ | +2 | 0 replies | |
| 39/39 | timer: Put usleep_range into the __sched sectionkernel/ | +1 | 0 replies |
Reviews trailers per patch
9 of 38 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Preeti U Murthy | Frans Klaver | Takashi Iwai | Frederic Weisbecker | David S. Miller |
|---|---|---|---|---|---|
| Series | A-b | ||||
| 1/39 | R-b | ||||
| 2/39 | R-b | ||||
| 3/39 | A-b | ||||
| 4/39 | A-b | ||||
| 5/39 | |||||
| 6/39 | |||||
| 7/39 | |||||
| 8/39 | R-b | ||||
| 9/39 | |||||
| 10/39 | R-b | ||||
| 11/39 | |||||
| 12/39 | |||||
| 13/39 | |||||
| 14/39 | |||||
| 15/39 | |||||
| 16/39 | |||||
| 17/39 | R-b | ||||
| 18/39 | |||||
| 19/39 | |||||
| 20/39 | |||||
| 21/39 | |||||
| 22/39 | |||||
| 23/39 | |||||
| 24/39 | |||||
| 25/39 | |||||
| 26/39 | |||||
| 27/39 | |||||
| 28/39 | |||||
| 29/39 | |||||
| 30/39 | |||||
| 31/39 | A-b | ||||
| 32/39 | |||||
| 34/39 | R-b | ||||
| 35/39 | |||||
| 36/39 | |||||
| 37/39 | |||||
| 38/39 | |||||
| 39/39 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.
Cover letter [patch 00/39] hrtimer/tick: Optimizations, cleanups and solutions for various issues
When I returned from my break I got offended by a pile of patches which kill the patient with the cure.
The issues at hand:
- NOHZ: Get rid of the softirq invocation
- hrtimer: Use the active_bases field in order to avoid evaluating inactive bases
- hrtimer: Cache footprint issues
Aside of that Peter and I were discussing for a long time to get rid of the hrtimer softirq.
After staring at all of it for quite some time it occured to me that all issues are related in one way or the other. So I sat down and reworked the code in various ways:
- Reduce the data size, so the hrtimer clock bases can be made cache line aligned.
- Consolidate everything on the high resolution timer implementation and get rid of dubious optimizations for the non highres case which bloat code and data.
- Implement the active_bases mechanism proper and avoid touching inactive hrtimer clock bases. This includes a conditional update mechanism for the hrtimer clock offsets to update them only when they changed, which they do seldom enough instead of polluting 4 cache lines in every tick/hrtimer interrupt.
- Get rid of the softirq deferment and simply enforce a hrtimer interrupt when the timer was already expired. This allows to remove the ugly __hrtimer_start_range_ns() interface and to cleanup the usage sites (sched/perf). As a consequence this also gets rid of the forward loops in the tick nohz code.
- Analogous to the hrtimer enforcement, force a tick interrupt for NOHZ non highres systems when the forwarding code tries to fire an expired tick. This allows to get rid of the softirq invocation in the NOHZ code.
- A cleanup of the code which evaluates the next timer event: Use nsec based calculations instead of the jiffy magic. That makes it actually readable by some definition of readable.
- While doing the above I had to audit quite some usage sites of various hrtimer interfaces, which revealed some entertaining bugs. The fixes have been posted in a seperate series already. Some other bogosities have been removed as part of this series.
The total change size of this overhaul is:
37 files changed, 515 insertions(+), 794 deletions(-)
The resulting text size of hrtimers.o shrinks in the range of 8-10% depending on the architecture.
The cache foot print of the hrtimer per cpu data shrinks as well.
x8684 i386 ARM ARM64 power64 Before: 328 248 280 328 328 Bytes 6 4 5 6 6 cache lines (64byte)
After: 320 192 192 320 320 Bytes
5 3 3 5 5 cache lines (64byte)
Note, that the new code avoids to touch the inactive clock bases which are now cache line aligned and therefor reduces the cache foot print in normal usage scenarios significantly.
I did some perf measurements on an isolated core running
- hrtimer centric workloads
- idle scenarios with periodic wakeups of various length
The patches reduce the number of instructions executed during the test runs between 2.5 and 6% depending on the scenario and the cache misses between 3 and 8%.
For your convenience this series is also available at:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/wip
Note: The branch is temporary and not meant to base other work on it.
Thanks,
tglx
--- arch/x86/kernel/cpu/perf_event_intel_rapl.c | 5 arch/x86/kernel/cpu/perf_event_intel_uncore.c | 5 drivers/power/reset/ltc2952-poweroff.c | 18 drivers/staging/ozwpan/ozpd.c | 8 include/linux/alarmtimer.h | 4 include/linux/hrtimer.h | 101 ++--- include/linux/interrupt.h | 7 include/linux/rcupdate.h | 6 include/linux/rcutree.h | 2 include/linux/timekeeper_internal.h | 2 include/linux/timer.h | 7 include/linux/timerqueue.h | 8 include/trace/events/irq.h | 1 kernel/events/core.c | 9 kernel/futex.c | 5 kernel/locking/rtmutex.c | 5 kernel/rcu/tree_plugin.h | 14 kernel/sched/core.c | 28 - kernel/sched/deadline.c | 12 kernel/sched/fair.c | 2 kernel/softirq.c | 2 kernel/time/alarmtimer.c | 17 kernel/time/hrtimer.c | 525 +++++++++----------------- kernel/time/posix-timers.c | 17 kernel/time/tick-broadcast-hrtimer.c | 8 kernel/time/tick-internal.h | 2 kernel/time/tick-sched.c | 288 +++++--------- kernel/time/tick-sched.h | 2 kernel/time/timekeeping.c | 55 -- kernel/time/timekeeping.h | 10 kernel/time/timer.c | 79 +-- kernel/time/timer_list.c | 14 lib/timerqueue.c | 10 net/core/pktgen.c | 2 net/sched/sch_api.c | 5 sound/core/hrtimer.c | 9 sound/drivers/pcsp/pcsp.c | 15 37 files changed, 515 insertions(+), 794 deletions(-)