All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Wei Li <liwei391@huawei.com>,
	Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>,
	Yu Liao <liaoyu15@huawei.com>, Hillf Danton <hdanton@sina.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: [PATCH 0/7] timers/nohz: Fixes and cleanups v2
Date: Mon, 20 Feb 2023 13:41:22 +0100	[thread overview]
Message-ID: <20230220124129.519477-1-frederic@kernel.org> (raw)

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

 

             reply	other threads:[~2023-02-20 12:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 12:41 Frederic Weisbecker [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230220124129.519477-1-frederic@kernel.org \
    --to=frederic@kernel.org \
    --cc=adobriyan@gmail.com \
    --cc=hdanton@sina.com \
    --cc=liaoyu15@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=mingo@kernel.org \
    --cc=mirsad.todorovac@alu.unizg.hr \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.