From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>
Subject: [PATCH] sched/fair: fix calc_cfs_shares fixed point arithmetics
Date: Mon, 19 Dec 2016 23:40:14 +0100 [thread overview]
Message-ID: <20161219224014.GA28238@var.home> (raw)
2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels")
exposed yet another miscalculation in calc_cfs_shares: MIN_SHARES is unscaled,
and must thus be scaled before being manipulated against "shares" amounts.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Fixes: 2159197d6677 ("sched/core: Enable increased load resolution on 64-bit kernels")
---
This should be backported to 4.7 and 4.8 to fix scheduling priorities
miscalculations
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6559d19..be84f72 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2657,8 +2657,8 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg)
if (tg_weight)
shares /= tg_weight;
- if (shares < MIN_SHARES)
- shares = MIN_SHARES;
+ if (shares < scale_load(MIN_SHARES))
+ shares = scale_load(MIN_SHARES);
if (shares > tg->shares)
shares = tg->shares;
next reply other threads:[~2016-12-19 22:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-19 22:40 Samuel Thibault [this message]
2016-12-19 22:44 ` [PATCH] sched/fair: fix calc_cfs_shares fixed point arithmetics Paul Turner
2016-12-19 23:07 ` Samuel Thibault
2016-12-19 23:26 ` Paul Turner
2016-12-19 23:29 ` Samuel Thibault
2016-12-19 23:32 ` Paul Turner
2016-12-19 23:45 ` Samuel Thibault
2016-12-20 13:04 ` Dietmar Eggemann
2016-12-20 13:15 ` Peter Zijlstra
2017-01-11 11:29 ` Dietmar Eggemann
2017-01-14 12:48 ` [tip:sched/core] sched/fair: Explain why MIN_SHARES isn't scaled in calc_cfs_shares() tip-bot for Dietmar Eggemann
2016-12-20 13:22 ` [PATCH] sched/fair: fix calc_cfs_shares fixed point arithmetics Samuel Thibault
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=20161219224014.GA28238@var.home \
--to=samuel.thibault@ens-lyon.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--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 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).