Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753319AbcKXGZe (ORCPT ); Thu, 24 Nov 2016 01:25:34 -0500 Received: from terminus.zytor.com ([198.137.202.10]:52738 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750762AbcKXGZb (ORCPT ); Thu, 24 Nov 2016 01:25:31 -0500 Date: Wed, 23 Nov 2016 22:24:48 -0800 From: tip-bot for Mike Galbraith Message-ID: Cc: efault@gmx.de, linux-kernel@vger.kernel.org, peterz@infradead.org, mtk.manpages@gmail.com, umgwanakikbuti@gmail.com, torvalds@linux-foundation.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, hpa@zytor.com, linux-man@vger.kernel.org, mingo@kernel.org Reply-To: torvalds@linux-foundation.org, umgwanakikbuti@gmail.com, efault@gmx.de, mtk.manpages@gmail.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, linux-man@vger.kernel.org, hpa@zytor.com In-Reply-To: <1479897217.4306.6.camel@gmx.de> References: <1479897217.4306.6.camel@gmx.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/urgent] sched/autogroup: Fix 64-bit kernel nice level adjustment Git-Commit-ID: 83929cce95251cc77e5659bf493bd424ae0e7a67 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2963 Lines: 78 Commit-ID: 83929cce95251cc77e5659bf493bd424ae0e7a67 Gitweb: http://git.kernel.org/tip/83929cce95251cc77e5659bf493bd424ae0e7a67 Author: Mike Galbraith AuthorDate: Wed, 23 Nov 2016 11:33:37 +0100 Committer: Ingo Molnar CommitDate: Thu, 24 Nov 2016 05:45:02 +0100 sched/autogroup: Fix 64-bit kernel nice level adjustment Michael Kerrisk reported: > Regarding the previous paragraph... My tests indicate > that writing *any* value to the autogroup [nice priority level] > file causes the task group to get a lower priority. Because autogroup didn't call the then meaningless scale_load()... Autogroup nice level adjustment has been broken ever since load resolution was increased for 64-bit kernels. Use scale_load() to scale group weight. Michael Kerrisk tested this patch to fix the problem: > Applied and tested against 4.9-rc6 on an Intel u7 (4 cores). > Test setup: > > Terminal window 1: running 40 CPU burner jobs > Terminal window 2: running 40 CPU burner jobs > Terminal window 1: running 1 CPU burner job > > Demonstrated that: > * Writing "0" to the autogroup file for TW1 now causes no change > to the rate at which the process on the terminal consume CPU. > * Writing -20 to the autogroup file for TW1 caused those processes > to get the lion's share of CPU while TW2 TW3 get a tiny amount. > * Writing -20 to the autogroup files for TW1 and TW3 allowed the > process on TW3 to get as much CPU as it was getting as when > the autogroup nice values for both terminals were 0. Reported-by: Michael Kerrisk Tested-by: Michael Kerrisk Signed-off-by: Mike Galbraith Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-man Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1479897217.4306.6.camel@gmx.de Signed-off-by: Ingo Molnar --- kernel/sched/auto_group.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c index f1c8fd5..da39489 100644 --- a/kernel/sched/auto_group.c +++ b/kernel/sched/auto_group.c @@ -212,6 +212,7 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice) { static unsigned long next = INITIAL_JIFFIES; struct autogroup *ag; + unsigned long shares; int err; if (nice < MIN_NICE || nice > MAX_NICE) @@ -230,9 +231,10 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice) next = HZ / 10 + jiffies; ag = autogroup_task_get(p); + shares = scale_load(sched_prio_to_weight[nice + 20]); down_write(&ag->lock); - err = sched_group_set_shares(ag->tg, sched_prio_to_weight[nice + 20]); + err = sched_group_set_shares(ag->tg, shares); if (!err) ag->nice = nice; up_write(&ag->lock);