Skip to content

timers/nohz: Fixes and cleanups v2

Frederic Weisbecker lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 3 repliesIn review

Changes since v1 from the cover letter

* Fix compute_delta left unused (thanks Hillf)
* Pass directly struct tick_sched to get_cpu_sleep_time_us()
* Add Peterz ack
* Remove selftests with wrong assertions

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7timers/nohz: Restructure and reshuffle struct tick_schedkernel/time/tick-sched.h+41 -250 replies
2/7timers/nohz: Only ever update sleeptime from idle exitkernel/time/tick-sched.c+41 -620 replies
3/7timers/nohz: Protect idle/iowait sleep time under seqcountkernel/time/tick-sched.c kernel/time/tick-sched.h+17 -60 replies
4/7timers/nohz: Add a comment about broken iowait counter update racekernel/time/tick-sched.c+8 -20 replies
5/7timers/nohz: Remove middle-function __tick_nohz_idle_stop_tick()kernel/time/tick-sched.c+8 -120 replies
6/7MAINTAINERS: Remove stale email addressMAINTAINERS+1 -10 replies
7/7selftests/proc: Remove idle time monotonicity assertionstools/testing/selftests/proc/.gitignore tools/testing/selftests/proc/Makefile tools/testing/selftests/proc/proc-uptime-001.c +2 more+0 -1883 replies

Reviews trailers per patch

6 of 7 patches have a Reviewed-by or Acked-by.

PatchPeter Zijlstra (Intel)
1/7A-b
2/7A-b
3/7A-b
4/7A-b
5/7A-b
6/7A-b
7/7

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

Read the v1 thread

Cover letter [PATCH 0/7] timers/nohz: Fixes and cleanups v2

Try to (partially) fix the issue reported in https://lore.kernel.org/lkml/[email protected]/

Changes since v1:

* Fix compute_delta left unused (thanks Hillf)
* Pass directly struct tick_sched to get_cpu_sleep_time_us()
* Add Peterz ack
* Remove selftests with wrong assertions

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
timers/core

HEAD: 0b86fc6ed10742ec8e54cd4d495c1ce9d4c1b4e0

Thanks,
Frederic
---

Frederic Weisbecker (7):
timers/nohz: Restructure and reshuffle struct tick_sched timers/nohz: Only ever update sleeptime from idle exit timers/nohz: Protect idle/iowait sleep time under seqcount timers/nohz: Add a comment about broken iowait counter update race timers/nohz: Remove middle-function __tick_nohz_idle_stop_tick()
MAINTAINERS: Remove stale email address selftests/proc: Remove idle time monotonicity assertions

 MAINTAINERS                                    |   2 +-
 kernel/time/tick-sched.c                       | 135 ++++++++++++-------------
 kernel/time/tick-sched.h                       |  67 +++++++-----
 tools/testing/selftests/proc/.gitignore        |   2 -
 tools/testing/selftests/proc/Makefile          |   2 -
 tools/testing/selftests/proc/proc-uptime-001.c |  45 ---------
 tools/testing/selftests/proc/proc-uptime-002.c |  79 ---------------
 tools/testing/selftests/proc/proc-uptime.h     |  60 -----------
 8 files changed, 106 insertions(+), 286 deletions(-)

---
git range-diff since v1

1: 899f01a80e5b ! 1: 0e7aede86812 timers/nohz: Restructure and reshuffle struct tick_sched
@@ Commit message
@last_jiffies and @idle_expires.

+ Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Yu Liao <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Wei Li <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Mirsad Goran Todorovac <[email protected]>
- Cc: Peter Zijlstra <[email protected]>

## kernel/time/tick-sched.h ##
2: 4ea8a8e98eb0 ! 2: 8e8a18cee3d5 timers/nohz: Only ever update sleeptime from idle exit

    @@ Commit message
         reader VS writer races to handle. A subsequent patch will fix one.
     
         Reported-by: Yu Liao <[email protected]>
    +    Acked-by: Peter Zijlstra (Intel) <[email protected]>
         Cc: Hillf Danton <[email protected]>
         Cc: Yu Liao <[email protected]>
         Cc: Ingo Molnar <[email protected]>
    @@ Commit message
         Cc: Wei Li <[email protected]>
         Cc: Alexey Dobriyan <[email protected]>
         Cc: Mirsad Goran Todorovac <[email protected]>
    -    Cc: Peter Zijlstra <[email protected]>
         Signed-off-by: Frederic Weisbecker <[email protected]>
     
      ## kernel/time/tick-sched.c ##
    @@ kernel/time/tick-sched.c: static void tick_nohz_start_idle(struct tick_sched *ts
      	sched_clock_idle_sleep_event();
      }
      
    -+static u64 get_cpu_sleep_time_us(int cpu, ktime_t *sleeptime,
    ++static u64 get_cpu_sleep_time_us(struct tick_sched *ts, ktime_t *sleeptime,
     +				 bool compute_delta, u64 *last_update_time)
     +{
    -+	struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
     +	ktime_t now, idle;
     +
     +	if (!tick_nohz_active)
    @@ kernel/time/tick-sched.c: static void tick_nohz_start_idle(struct tick_sched *ts
     +	if (last_update_time)
     +		*last_update_time = ktime_to_us(now);
     +
    -+	if (ts->idle_active && !nr_iowait_cpu(cpu)) {
    ++	if (ts->idle_active && compute_delta) {
     +		ktime_t delta = ktime_sub(now, ts->idle_entrytime);
     +
     +		idle = ktime_add(*sleeptime, delta);
    @@ kernel/time/tick-sched.c: static void tick_nohz_start_idle(struct tick_sched *ts
     -
     -	return ktime_to_us(idle);
      
    -+	return get_cpu_sleep_time_us(cpu, &ts->idle_sleeptime,
    ++	return get_cpu_sleep_time_us(ts, &ts->idle_sleeptime,
     +				     !nr_iowait_cpu(cpu), last_update_time);
      }
      EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
    @@ kernel/time/tick-sched.c: EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);
     -	}
      
     -	return ktime_to_us(iowait);
    -+	return get_cpu_sleep_time_us(cpu, &ts->iowait_sleeptime,
    ++	return get_cpu_sleep_time_us(ts, &ts->iowait_sleeptime,
     +				     nr_iowait_cpu(cpu), last_update_time);
      }
      EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);

3: 131b09a345c6 ! 3: 61b56e1d6c33 timers/nohz: Protect idle/iowait sleep time under seqcount
@@ Commit message
can hardly be fixed.

+ Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Yu Liao <[email protected]>
Cc: Ingo Molnar <[email protected]>
@@ Commit message
Cc: Wei Li <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Mirsad Goran Todorovac <[email protected]>
- Cc: Peter Zijlstra <[email protected]>

## kernel/time/tick-sched.c ##
@@ kernel/time/tick-sched.c: static void tick_nohz_stop_idle(struct tick_sched *ts,
sched_clock_idle_sleep_event();
}

-@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(int cpu, ktime_t *sleeptime, +@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(struct tick_sched *ts, ktime_t *sleeptime,
+ bool compute_delta, u64 *last_update_time)
{
- struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
ktime_t now, idle;
+ unsigned int seq;

if (!tick_nohz_active)
return -1;
-@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(int cpu, ktime_t *sleeptime, +@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(struct tick_sched *ts, ktime_t *sleeptime,
if (last_update_time)
*last_update_time = ktime_to_us(now);

-- if (ts->idle_active && !nr_iowait_cpu(cpu)) {
+- if (ts->idle_active && compute_delta) {
- ktime_t delta = ktime_sub(now, ts->idle_entrytime);
+ do {
+ seq = read_seqcount_begin(&ts->idle_sleeptime_seq);
@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(int cpu, ktime_t *sle
- } else {
- idle = *sleeptime;
- }
-+ if (ts->idle_active && !nr_iowait_cpu(cpu)) {
++ if (ts->idle_active && compute_delta) {
+ ktime_t delta = ktime_sub(now, ts->idle_entrytime);
+
+ idle = ktime_add(*sleeptime, delta);
4: 4ff478886c2c ! 4: 9147cd64f3ba timers/nohz: Add a comment about broken iowait counter update race
@@ Commit message
This is unfortunately hardly fixable. Just add a comment about that condition.

+ Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Yu Liao <[email protected]>
Cc: Ingo Molnar <[email protected]>
@@ Commit message
Cc: Wei Li <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Mirsad Goran Todorovac <[email protected]>
- Cc: Peter Zijlstra <[email protected]>

## kernel/time/tick-sched.c ##
-@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(int cpu, ktime_t *sleeptime, +@@ kernel/time/tick-sched.c: static u64 get_cpu_sleep_time_us(struct tick_sched *ts, ktime_t *sleeptime,
* counters if NULL.
*
* Return the cumulative idle time (since boot) for a given
5: 6eb31238e057 ! 5: 4863214a905f timers/nohz: Remove middle-function __tick_nohz_idle_stop_tick()
@@ Commit message
tick_nohz_idle_stop_tick() and its implementation. Remove that
unnecessary step.

+ Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Yu Liao <[email protected]>
Cc: Ingo Molnar <[email protected]>
@@ Commit message
Cc: Wei Li <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Mirsad Goran Todorovac <[email protected]>
- Cc: Peter Zijlstra <[email protected]>

## kernel/time/tick-sched.c ##
6: d1dc3edc39a7 ! 6: 170828be3e96 MAINTAINERS: Remove stale email address
@@ Metadata
## Commit message ##
MAINTAINERS: Remove stale email address

+ Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Hillf Danton <[email protected]>
Cc: Yu Liao <[email protected]>
Cc: Ingo Molnar <[email protected]>
@@ Commit message
Cc: Wei Li <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Mirsad Goran Todorovac <[email protected]>
- Cc: Peter Zijlstra <[email protected]>

## MAINTAINERS ##
-: ------------ > 7: 0b86fc6ed107 selftests/proc: Remove idle time monotonicity assertions