From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Ingo Molnar <mingo@kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Brendan Jackman <brendan.jackman@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Morten Rasmussen <morten.rasmussen@arm.com>
Subject: Re: [RFC PATCH 2/5] sched: Add NOHZ_STATS_KICK
Date: Thu, 1 Feb 2018 17:52:49 +0100 [thread overview]
Message-ID: <20180201165249.GC2269@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180115082609.GA6320@linaro.org>
On Mon, Jan 15, 2018 at 09:26:09AM +0100, Vincent Guittot wrote:
Would've probably been easier to read if you'd not included the revert
of that timer patch...
> @@ -9258,21 +9255,11 @@ void nohz_balance_enter_idle(int cpu)
> set_cpu_sd_state_idle(cpu);
>
> /*
> - * implies a barrier such that if the stats_state update is observed
> - * the above updates are also visible. Pairs with stuff in
> - * update_sd_lb_stats() and nohz_idle_balance().
> + * Each time a cpu enter idle, we assume that it has blocked load and
> + * enable the periodic update of the load of idle cpus
> */
> - val = atomic_read(&nohz.stats_state);
> - do {
> - new = val + 2;
> - new |= 1;
> - } while (!atomic_try_cmpxchg(&nohz.stats_state, &val, new));
> + atomic_set(&nohz.stats_state, 1);
>
> @@ -9422,7 +9408,6 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
> return false;
> }
>
> - stats_seq = atomic_read(&nohz.stats_state);
> /*
> * barrier, pairs with nohz_balance_enter_idle(), ensures ...
> */
> @@ -9432,6 +9417,16 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
>
> SCHED_WARN_ON((flags & NOHZ_KICK_MASK) == NOHZ_BALANCE_KICK);
>
> + /*
> + * We assume there will be no idle load after this update and clear
> + * the stats state. If a cpu enters idle in the mean time, it will
> + * set the stats state and trig another update of idle load.
> + * Because a cpu that becomes idle, is added to idle_cpus_mask before
> + * setting the stats state, we are sure to not clear the state and not
> + * check the load of an idle cpu.
> + */
> + atomic_set(&nohz.stats_state, 0);
> +
> for_each_cpu(balance_cpu, nohz.idle_cpus_mask) {
> if (balance_cpu == this_cpu || !idle_cpu(balance_cpu))
> continue;
> @@ -9441,8 +9436,10 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
> * work being done for other cpus. Next load
> * balancing owner will pick it up.
> */
> - if (need_resched())
> + if (need_resched()) {
> + has_blocked_load = true;
> break;
> + }
>
> rq = cpu_rq(balance_cpu);
>
> @@ -9477,12 +9474,12 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
> if (flags & NOHZ_BALANCE_KICK)
> rebalance_domains(this_rq, CPU_IDLE);
>
> - if (has_blocked_load ||
> - !atomic_try_cmpxchg(&nohz.stats_state, &stats_seq, 0)) {
> - WRITE_ONCE(nohz.next_stats,
> - now + msecs_to_jiffies(LOAD_AVG_PERIOD));
> - mod_timer(&nohz.timer, nohz.next_stats);
> - }
> + WRITE_ONCE(nohz.next_stats,
> + now + msecs_to_jiffies(LOAD_AVG_PERIOD));
> +
> + /* There is still blocked load, enable periodic update */
> + if (has_blocked_load)
> + atomic_set(&nohz.stats_state, 1);
>
> /*
> * next_balance will be updated only when there is a need.
After this there is no point for stats_state to be atomic anymore. Also
a better name.
Maybe if I drop the last two patches (and you re-introduce the bits
from: Subject: sched: Optimize nohz stats, that you do need) this all
becomes more readable?
next prev parent reply other threads:[~2018-02-01 16:53 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 10:21 [RFC PATCH 0/5] sched: On remote stats updates Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 1/5] sched: Convert nohz_flags to atomic_t Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 2/5] sched: Add NOHZ_STATS_KICK Peter Zijlstra
2017-12-21 16:23 ` Vincent Guittot
2017-12-21 16:56 ` Vincent Guittot
2017-12-22 7:59 ` Peter Zijlstra
2017-12-22 8:05 ` Vincent Guittot
2017-12-22 8:29 ` Peter Zijlstra
2017-12-22 9:12 ` Peter Zijlstra
2017-12-22 14:31 ` Peter Zijlstra
2017-12-22 14:34 ` Vincent Guittot
2017-12-22 14:32 ` Vincent Guittot
2017-12-22 18:56 ` Peter Zijlstra
2017-12-22 20:42 ` Peter Zijlstra
2018-01-02 15:44 ` Morten Rasmussen
2018-01-15 9:43 ` Peter Zijlstra
2018-01-18 10:32 ` Morten Rasmussen
2018-01-03 9:16 ` Vincent Guittot
2018-01-15 8:26 ` Vincent Guittot
2018-01-18 10:38 ` Morten Rasmussen
2018-01-24 8:25 ` Vincent Guittot
2018-01-29 18:43 ` Dietmar Eggemann
2018-01-30 8:00 ` Vincent Guittot
2018-01-29 19:31 ` Valentin Schneider
2018-01-30 8:32 ` Vincent Guittot
2018-01-30 11:41 ` Valentin Schneider
2018-01-30 13:05 ` Vincent Guittot
2018-02-05 22:18 ` Valentin Schneider
2018-02-06 9:22 ` Vincent Guittot
2018-02-01 18:16 ` Peter Zijlstra
2018-02-01 16:57 ` Peter Zijlstra
2018-02-01 17:26 ` Vincent Guittot
2018-02-01 18:10 ` Peter Zijlstra
2018-02-01 19:11 ` Vincent Guittot
2018-02-06 8:32 ` [PATCH 1/3] sched: Stop nohz stats when decayed Vincent Guittot
2018-02-06 8:32 ` [PATCH 2/3] sched: reduce the periodic update duration Vincent Guittot
2018-02-06 8:32 ` [PATCH 3/3] sched: update blocked load when newly idle Vincent Guittot
2018-02-06 14:32 ` Valentin Schneider
2018-02-06 16:17 ` Vincent Guittot
2018-02-06 16:32 ` Valentin Schneider
2018-02-06 8:55 ` [PATCH 1/3] sched: Stop nohz stats when decayed Vincent Guittot
2018-02-06 14:16 ` Valentin Schneider
2018-02-06 14:31 ` Vincent Guittot
2018-02-01 16:55 ` [RFC PATCH 2/5] sched: Add NOHZ_STATS_KICK Peter Zijlstra
2018-01-22 9:40 ` Dietmar Eggemann
2018-01-22 10:23 ` Vincent Guittot
2018-02-01 16:52 ` Peter Zijlstra [this message]
2018-02-01 17:25 ` Vincent Guittot
2017-12-22 7:56 ` Peter Zijlstra
2017-12-22 8:04 ` Vincent Guittot
2017-12-21 10:21 ` [RFC PATCH 3/5] sched: Restructure nohz_balance_kick Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 4/5] sched: Add nohz stats balancing Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 5/5] sched: Update blocked load from NEWIDLE Peter Zijlstra
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=20180201165249.GC2269@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=brendan.jackman@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=vincent.guittot@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox