From: Valentin Schneider <valentin.schneider@arm.com>
To: Vincent Guittot <vincent.guittot@linaro.org>,
peterz@infradead.org, mingo@kernel.org,
linux-kernel@vger.kernel.org
Cc: morten.rasmussen@foss.arm.com, brendan.jackman@arm.com,
dietmar.eggemann@arm.com
Subject: Re: [PATCH v5 1/3] sched: Stop nohz stats when decayed
Date: Fri, 16 Feb 2018 12:53:36 +0000 [thread overview]
Message-ID: <c4909c7e-e11b-8886-db15-ba82a331b89e@arm.com> (raw)
In-Reply-To: <1518622006-16089-2-git-send-email-vincent.guittot@linaro.org>
On 02/14/2018 03:26 PM, Vincent Guittot wrote:
> Stopped the periodic update of blocked load when all idle CPUs have fully
> decayed. We introduce a new nohz.has_blocked that reflect if some idle
> CPUs has blocked load that have to be periodiccally updated. nohz.has_blocked
> is set everytime that a Idle CPU can have blocked load and it is then clear
> when no more blocked load has been detected during an update. We don't need
> atomic operation but only to make cure of the right ordering when updating
> nohz.idle_cpus_mask and nohz.has_blocked.
>
> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/fair.c | 122 ++++++++++++++++++++++++++++++++++++++++++---------
> kernel/sched/sched.h | 1 +
> 2 files changed, 102 insertions(+), 21 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 7af1fa9..5a6835e 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
>
> [...]
>
> -static void update_nohz_stats(struct rq *rq)
> +static bool update_nohz_stats(struct rq *rq)
> {
> #ifdef CONFIG_NO_HZ_COMMON
> unsigned int cpu = rq->cpu;
>
> + if (!rq->has_blocked_load)
> + return false;
> +
> if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
> - return;
> + return false;
>
> if (!time_after(jiffies, rq->last_blocked_load_update_tick))
> - return;
> + return true;
>
> update_blocked_averages(cpu);
> +
> + return rq->has_blocked_load;
> +#else
> + return false;
> #endif
> }
>
(Wrongly thought that this bit was in a different patch, comment should have
been squashed in previous reply...)
I've been thinking about this, and it's a messy one if we want to
skip CPUs in idle_balance() / clear the nohz.has_blocked_flag.
AFAICT, the rq->has_blocked_load flag can be wrongly cleared: if we're
calling update_nohz_stats() for CPU A, but CPU A got out/in of
idle really quickly in that same timeframe, I'm not sure you can guarantee
the clearing of rq->has_blocked_load done in update_blocked_averages() will
always end up in memory before the setting of the flag in
nohz_balance_enter_idle().
I was going to say we don't have this problem in _nohz_idle_balance() but
actually I think we do. We have the checking of nohz.idle_cpus_mask after the
smp_mb(), which makes sure the clear of nohz.has_blocked will never
overwrite the set in nohz_balance_enter_idle(), but it doesn't
guarantee the same for the rq flag. So we can have nohz CPUs with blocked
load but with rq->has_blocked_load set to false. Which isn't a problem now
but it is if we want to use the flag to skip CPUs.
Am I correct or am I going crazy ? There's a comment about this in
nohz_balance_enter_idle() but I'm confused now:
/*
* Can be set safely without rq->lock held
* If a clear happens, it will have evaluated last additions because
* rq->lock is held during the check and the clear
*/
rq->has_blocked_load = 1;
next prev parent reply other threads:[~2018-02-16 12:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 15:26 [PATCH v5 0/3] sched: Update blocked load Vincent Guittot
2018-02-14 15:26 ` [PATCH v5 1/3] sched: Stop nohz stats when decayed Vincent Guittot
2018-02-15 15:22 ` Patrick Bellasi
2018-02-15 16:50 ` Peter Zijlstra
2018-02-15 16:59 ` Patrick Bellasi
2018-02-15 17:06 ` Vincent Guittot
2018-02-16 12:13 ` Valentin Schneider
2018-02-16 13:44 ` Vincent Guittot
2018-02-21 13:13 ` Valentin Schneider
2018-02-21 13:48 ` Valentin Schneider
2018-02-22 8:37 ` Vincent Guittot
2018-02-22 10:04 ` Valentin Schneider
2018-02-16 12:53 ` Valentin Schneider [this message]
2018-02-16 17:02 ` Vincent Guittot
2018-02-16 19:23 ` Valentin Schneider
2018-02-14 15:26 ` [PATCH v5 2/3] sched: reduce the periodic update duration Vincent Guittot
2018-02-14 15:26 ` [PATCH v5 3/3] sched: update blocked load when newly idle Vincent Guittot
2018-02-20 11:59 ` Peter Zijlstra
2018-03-09 9:06 ` [tip:sched/core] sched/fair: Update " tip-bot for Vincent Guittot
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=c4909c7e-e11b-8886-db15-ba82a331b89e@arm.com \
--to=valentin.schneider@arm.com \
--cc=brendan.jackman@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@foss.arm.com \
--cc=peterz@infradead.org \
--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;
as well as URLs for NNTP newsgroup(s).