LKML Archive on
help / color / mirror / Atom feed
From: Valentin Schneider <>
Subject: [PATCH v2 2/2] sched/fair: Don't increase sd->balance_interval on newidle balance
Date: Wed, 26 Sep 2018 16:12:07 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

When load_balance() fails to move some load because of task affinity,
we end up increasing sd->balance_interval to delay the next periodic
balance in the hopes that next time we look, that annoying pinned
task(s) will be gone.

However, idle_balance() pays no attention to sd->balance_interval, yet
it will still lead to an increase in balance_interval in case of
pinned tasks.

If we're going through several newidle balances (e.g. we have a
periodic task), this can lead to a huge increase of the
balance_interval in a very small amount of time.

To prevent that, don't increase the balance interval when going
through a newidle balance.

This is a similar approach to what is done in commit 58b26c4c0257
("sched: Increment cache_nice_tries only on periodic lb"), where we
disregard newidle balance and rely on periodic balance for more stable

Signed-off-by: Valentin Schneider <>
 kernel/sched/fair.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9cf93ba..4c33283 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8782,13 +8782,22 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 	sd->nr_balance_failed = 0;
+	ld_moved = 0;
+	/*
+	 * idle_balance() disregards balance intervals, so we could repeatedly
+	 * reach this code, which would lead to balance_interval skyrocketting
+	 * in a short amount of time. Skip the balance_interval increase logic
+	 * to avoid that.
+	 */
+	if (env.idle == CPU_NEWLY_IDLE)
+		goto out;
 	/* tune up the balancing interval */
 	if ((env.flags & LBF_ALL_PINNED &&
 	     sd->balance_interval < MAX_PINNED_INTERVAL) ||
 	    sd->balance_interval < sd->max_interval)
 		sd->balance_interval *= 2;
-	ld_moved = 0;
 	return ld_moved;

  reply	other threads:[~2018-09-26 15:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 15:12 [PATCH v2 1/2] sched/fair: Cleanup load_balance() condition Valentin Schneider
2018-09-26 15:12 ` Valentin Schneider [this message]
2018-11-04  0:13   ` [tip:sched/core] sched/fair: Don't increase sd->balance_interval on newidle balance tip-bot for Valentin Schneider
2018-10-30 10:27 ` [PATCH v2 1/2] sched/fair: Cleanup load_balance() condition Valentin Schneider
2018-10-30 12:41   ` Peter Zijlstra
2018-11-04  0:13 ` [tip:sched/core] sched/fair: Clean up " tip-bot for Valentin Schneider

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:

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

  git send-email \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v2 2/2] sched/fair: Don'\''t increase sd->balance_interval on newidle balance' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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