* [PATCH v2] sched/fair: fix nohz next idle balance
@ 2020-06-09 12:37 Vincent Guittot
2020-06-10 12:49 ` Peter Zijlstra
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Vincent Guittot @ 2020-06-09 12:37 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
mgorman, linux-kernel, iwtbavbm
Cc: valentin.schneider, Vincent Guittot
With commit:
'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")'
rebalance_domains of the local cfs_rq happens before others idle cpus have
updated nohz.next_balance and its value is overwritten.
Move the update of nohz.next_balance for other idles cpus before balancing
and updating the next_balance of local cfs_rq.
Also, the nohz.next_balance is now updated only if all idle cpus got a
chance to rebalance their domains and the idle balance has not been aborted
because of new activities on the CPU. In case of need_resched, the idle
load balance will be kick the next jiffie in order to address remaining
ilb.
Reported-by: Peng Liu <iwtbavbm@gmail.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
- Changes v2:
- use jiffies instead of incrementing nohz.next_balance to be sure of the
value. The change slipped out of the previous version.
kernel/sched/fair.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0ed04d2a8959..832164d441dd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10017,7 +10017,12 @@ static void kick_ilb(unsigned int flags)
{
int ilb_cpu;
- nohz.next_balance++;
+ /*
+ * Increase nohz.next_balance only when if full ilb is triggered but
+ * not if we only update stats.
+ */
+ if (flags & NOHZ_BALANCE_KICK)
+ nohz.next_balance = jiffies+1;
ilb_cpu = find_new_ilb();
@@ -10338,6 +10343,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
}
}
+ /*
+ * next_balance will be updated only when there is a need.
+ * When the CPU is attached to null domain for ex, it will not be
+ * updated.
+ */
+ if (likely(update_next_balance))
+ nohz.next_balance = next_balance;
+
/* Newly idle CPU doesn't need an update */
if (idle != CPU_NEWLY_IDLE) {
update_blocked_averages(this_cpu);
@@ -10358,14 +10371,6 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
if (has_blocked_load)
WRITE_ONCE(nohz.has_blocked, 1);
- /*
- * next_balance will be updated only when there is a need.
- * When the CPU is attached to null domain for ex, it will not be
- * updated.
- */
- if (likely(update_next_balance))
- nohz.next_balance = next_balance;
-
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2] sched/fair: fix nohz next idle balance
2020-06-09 12:37 [PATCH v2] sched/fair: fix nohz next idle balance Vincent Guittot
@ 2020-06-10 12:49 ` Peter Zijlstra
2020-06-11 14:12 ` Valentin Schneider
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2020-06-10 12:49 UTC (permalink / raw)
To: Vincent Guittot
Cc: mingo, juri.lelli, dietmar.eggemann, rostedt, bsegall, mgorman,
linux-kernel, iwtbavbm, valentin.schneider
On Tue, Jun 09, 2020 at 02:37:48PM +0200, Vincent Guittot wrote:
> With commit:
> 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")'
> rebalance_domains of the local cfs_rq happens before others idle cpus have
> updated nohz.next_balance and its value is overwritten.
>
> Move the update of nohz.next_balance for other idles cpus before balancing
> and updating the next_balance of local cfs_rq.
>
> Also, the nohz.next_balance is now updated only if all idle cpus got a
> chance to rebalance their domains and the idle balance has not been aborted
> because of new activities on the CPU. In case of need_resched, the idle
> load balance will be kick the next jiffie in order to address remaining
> ilb.
>
> Reported-by: Peng Liu <iwtbavbm@gmail.com>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] sched/fair: fix nohz next idle balance
2020-06-09 12:37 [PATCH v2] sched/fair: fix nohz next idle balance Vincent Guittot
2020-06-10 12:49 ` Peter Zijlstra
@ 2020-06-11 14:12 ` Valentin Schneider
2020-06-11 14:28 ` Peter Zijlstra
2020-06-11 14:43 ` Mel Gorman
2020-06-16 12:21 ` [tip: sched/core] sched/fair: Fix NOHZ " tip-bot2 for Vincent Guittot
3 siblings, 1 reply; 6+ messages in thread
From: Valentin Schneider @ 2020-06-11 14:12 UTC (permalink / raw)
To: Vincent Guittot
Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
mgorman, linux-kernel, iwtbavbm
On 09/06/20 13:37, Vincent Guittot wrote:
> With commit:
> 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")'
> rebalance_domains of the local cfs_rq happens before others idle cpus have
> updated nohz.next_balance and its value is overwritten.
>
> Move the update of nohz.next_balance for other idles cpus before balancing
> and updating the next_balance of local cfs_rq.
>
> Also, the nohz.next_balance is now updated only if all idle cpus got a
> chance to rebalance their domains and the idle balance has not been aborted
> because of new activities on the CPU. In case of need_resched, the idle
> load balance will be kick the next jiffie in order to address remaining
> ilb.
>
> Reported-by: Peng Liu <iwtbavbm@gmail.com>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
FWIW:
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Do we want a Fixes: tag for this? I'm thinking
b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] sched/fair: fix nohz next idle balance
2020-06-11 14:12 ` Valentin Schneider
@ 2020-06-11 14:28 ` Peter Zijlstra
0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2020-06-11 14:28 UTC (permalink / raw)
To: Valentin Schneider
Cc: Vincent Guittot, mingo, juri.lelli, dietmar.eggemann, rostedt,
bsegall, mgorman, linux-kernel, iwtbavbm
On Thu, Jun 11, 2020 at 03:12:11PM +0100, Valentin Schneider wrote:
>
> On 09/06/20 13:37, Vincent Guittot wrote:
> > With commit:
> > 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")'
> > rebalance_domains of the local cfs_rq happens before others idle cpus have
> > updated nohz.next_balance and its value is overwritten.
> >
> > Move the update of nohz.next_balance for other idles cpus before balancing
> > and updating the next_balance of local cfs_rq.
> >
> > Also, the nohz.next_balance is now updated only if all idle cpus got a
> > chance to rebalance their domains and the idle balance has not been aborted
> > because of new activities on the CPU. In case of need_resched, the idle
> > load balance will be kick the next jiffie in order to address remaining
> > ilb.
> >
> > Reported-by: Peng Liu <iwtbavbm@gmail.com>
> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
>
> FWIW:
> Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
>
> Do we want a Fixes: tag for this? I'm thinking
> b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")
Done, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] sched/fair: fix nohz next idle balance
2020-06-09 12:37 [PATCH v2] sched/fair: fix nohz next idle balance Vincent Guittot
2020-06-10 12:49 ` Peter Zijlstra
2020-06-11 14:12 ` Valentin Schneider
@ 2020-06-11 14:43 ` Mel Gorman
2020-06-16 12:21 ` [tip: sched/core] sched/fair: Fix NOHZ " tip-bot2 for Vincent Guittot
3 siblings, 0 replies; 6+ messages in thread
From: Mel Gorman @ 2020-06-11 14:43 UTC (permalink / raw)
To: Vincent Guittot
Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
linux-kernel, iwtbavbm, valentin.schneider
On Tue, Jun 09, 2020 at 02:37:48PM +0200, Vincent Guittot wrote:
> With commit:
> 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")'
> rebalance_domains of the local cfs_rq happens before others idle cpus have
> updated nohz.next_balance and its value is overwritten.
>
> Move the update of nohz.next_balance for other idles cpus before balancing
> and updating the next_balance of local cfs_rq.
>
> Also, the nohz.next_balance is now updated only if all idle cpus got a
> chance to rebalance their domains and the idle balance has not been aborted
> because of new activities on the CPU. In case of need_resched, the idle
> load balance will be kick the next jiffie in order to address remaining
> ilb.
>
> Reported-by: Peng Liu <iwtbavbm@gmail.com>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Acked-by: Mel Gorman <mgorman@suse.de>
--
Mel Gorman
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread* [tip: sched/core] sched/fair: Fix NOHZ next idle balance
2020-06-09 12:37 [PATCH v2] sched/fair: fix nohz next idle balance Vincent Guittot
` (2 preceding siblings ...)
2020-06-11 14:43 ` Mel Gorman
@ 2020-06-16 12:21 ` tip-bot2 for Vincent Guittot
3 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Vincent Guittot @ 2020-06-16 12:21 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peng Liu, Vincent Guittot, Peter Zijlstra (Intel),
Valentin Schneider, Mel Gorman, x86, LKML
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 3ea2f097b17e13a8280f1f9386c331b326a3dbef
Gitweb: https://git.kernel.org/tip/3ea2f097b17e13a8280f1f9386c331b326a3dbef
Author: Vincent Guittot <vincent.guittot@linaro.org>
AuthorDate: Tue, 09 Jun 2020 14:37:48 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 15 Jun 2020 14:10:04 +02:00
sched/fair: Fix NOHZ next idle balance
With commit:
'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")'
rebalance_domains of the local cfs_rq happens before others idle cpus have
updated nohz.next_balance and its value is overwritten.
Move the update of nohz.next_balance for other idles cpus before balancing
and updating the next_balance of local cfs_rq.
Also, the nohz.next_balance is now updated only if all idle cpus got a
chance to rebalance their domains and the idle balance has not been aborted
because of new activities on the CPU. In case of need_resched, the idle
load balance will be kick the next jiffie in order to address remaining
ilb.
Fixes: b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")
Reported-by: Peng Liu <iwtbavbm@gmail.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Link: https://lkml.kernel.org/r/20200609123748.18636-1-vincent.guittot@linaro.org
---
kernel/sched/fair.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a785a9b..295c9ff 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10022,7 +10022,12 @@ static void kick_ilb(unsigned int flags)
{
int ilb_cpu;
- nohz.next_balance++;
+ /*
+ * Increase nohz.next_balance only when if full ilb is triggered but
+ * not if we only update stats.
+ */
+ if (flags & NOHZ_BALANCE_KICK)
+ nohz.next_balance = jiffies+1;
ilb_cpu = find_new_ilb();
@@ -10343,6 +10348,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
}
}
+ /*
+ * next_balance will be updated only when there is a need.
+ * When the CPU is attached to null domain for ex, it will not be
+ * updated.
+ */
+ if (likely(update_next_balance))
+ nohz.next_balance = next_balance;
+
/* Newly idle CPU doesn't need an update */
if (idle != CPU_NEWLY_IDLE) {
update_blocked_averages(this_cpu);
@@ -10363,14 +10376,6 @@ abort:
if (has_blocked_load)
WRITE_ONCE(nohz.has_blocked, 1);
- /*
- * next_balance will be updated only when there is a need.
- * When the CPU is attached to null domain for ex, it will not be
- * updated.
- */
- if (likely(update_next_balance))
- nohz.next_balance = next_balance;
-
return ret;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-06-16 12:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-09 12:37 [PATCH v2] sched/fair: fix nohz next idle balance Vincent Guittot
2020-06-10 12:49 ` Peter Zijlstra
2020-06-11 14:12 ` Valentin Schneider
2020-06-11 14:28 ` Peter Zijlstra
2020-06-11 14:43 ` Mel Gorman
2020-06-16 12:21 ` [tip: sched/core] sched/fair: Fix NOHZ " tip-bot2 for Vincent Guittot
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.