linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] timers/nohz: Fixes and cleanups v2
@ 2023-02-20 12:41 Frederic Weisbecker
  2023-02-20 12:41 ` [PATCH 1/7] timers/nohz: Restructure and reshuffle struct tick_sched Frederic Weisbecker
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Frederic Weisbecker @ 2023-02-20 12:41 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Frederic Weisbecker, Alexey Dobriyan, Peter Zijlstra,
	Wei Li, Mirsad Goran Todorovac, Yu Liao, Hillf Danton,
	Ingo Molnar

Try to (partially) fix the issue reported in https://lore.kernel.org/lkml/20230128020051.2328465-1-liaoyu15@huawei.com/

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.
     
         Reported-by: Thomas Gleixner <tglx@linutronix.de>
    +    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
         Cc: Hillf Danton <hdanton@sina.com>
         Cc: Yu Liao <liaoyu15@huawei.com>
         Cc: Ingo Molnar <mingo@kernel.org>
         Cc: Wei Li <liwei391@huawei.com>
         Cc: Alexey Dobriyan <adobriyan@gmail.com>
         Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
    -    Cc: Peter Zijlstra <peterz@infradead.org>
         Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
     
      ## 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 <liaoyu15@huawei.com>
    +    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
         Cc: Hillf Danton <hdanton@sina.com>
         Cc: Yu Liao <liaoyu15@huawei.com>
         Cc: Ingo Molnar <mingo@kernel.org>
    @@ Commit message
         Cc: Wei Li <liwei391@huawei.com>
         Cc: Alexey Dobriyan <adobriyan@gmail.com>
         Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
    -    Cc: Peter Zijlstra <peterz@infradead.org>
         Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
     
      ## 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.
     
         Reported-by: Yu Liao <liaoyu15@huawei.com>
    +    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
         Cc: Hillf Danton <hdanton@sina.com>
         Cc: Yu Liao <liaoyu15@huawei.com>
         Cc: Ingo Molnar <mingo@kernel.org>
    @@ Commit message
         Cc: Wei Li <liwei391@huawei.com>
         Cc: Alexey Dobriyan <adobriyan@gmail.com>
         Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
    -    Cc: Peter Zijlstra <peterz@infradead.org>
         Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
     
      ## 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) <peterz@infradead.org>
         Cc: Hillf Danton <hdanton@sina.com>
         Cc: Yu Liao <liaoyu15@huawei.com>
         Cc: Ingo Molnar <mingo@kernel.org>
    @@ Commit message
         Cc: Wei Li <liwei391@huawei.com>
         Cc: Alexey Dobriyan <adobriyan@gmail.com>
         Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
    -    Cc: Peter Zijlstra <peterz@infradead.org>
         Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
     
      ## 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) <peterz@infradead.org>
         Cc: Hillf Danton <hdanton@sina.com>
         Cc: Yu Liao <liaoyu15@huawei.com>
         Cc: Ingo Molnar <mingo@kernel.org>
    @@ Commit message
         Cc: Wei Li <liwei391@huawei.com>
         Cc: Alexey Dobriyan <adobriyan@gmail.com>
         Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
    -    Cc: Peter Zijlstra <peterz@infradead.org>
         Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
     
      ## 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) <peterz@infradead.org>
         Cc: Hillf Danton <hdanton@sina.com>
         Cc: Yu Liao <liaoyu15@huawei.com>
         Cc: Ingo Molnar <mingo@kernel.org>
    @@ Commit message
         Cc: Wei Li <liwei391@huawei.com>
         Cc: Alexey Dobriyan <adobriyan@gmail.com>
         Cc: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
    -    Cc: Peter Zijlstra <peterz@infradead.org>
         Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
     
      ## MAINTAINERS ##
-:  ------------ > 7:  0b86fc6ed107 selftests/proc: Remove idle time monotonicity assertions

 

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

end of thread, other threads:[~2023-02-22 14:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 12:41 [PATCH 0/7] timers/nohz: Fixes and cleanups v2 Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 1/7] timers/nohz: Restructure and reshuffle struct tick_sched Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 2/7] timers/nohz: Only ever update sleeptime from idle exit Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 3/7] timers/nohz: Protect idle/iowait sleep time under seqcount Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 4/7] timers/nohz: Add a comment about broken iowait counter update race Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 5/7] timers/nohz: Remove middle-function __tick_nohz_idle_stop_tick() Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 6/7] MAINTAINERS: Remove stale email address Frederic Weisbecker
2023-02-20 12:41 ` [PATCH 7/7] selftests/proc: Remove idle time monotonicity assertions Frederic Weisbecker
2023-02-20 20:16   ` Alexey Dobriyan
2023-02-20 21:53   ` Thomas Gleixner
2023-02-22 14:48     ` Frederic Weisbecker

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).