Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964952AbcKWNsz (ORCPT ); Wed, 23 Nov 2016 08:48:55 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:34663 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964938AbcKWNsw (ORCPT ); Wed, 23 Nov 2016 08:48:52 -0500 From: "Michael Kerrisk (man-pages)" Subject: Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment To: Mike Galbraith References: <41d802dc-873a-ff02-17ff-93ce50f3e925@gmail.com> <1479897217.4306.6.camel@gmx.de> Cc: mtk.manpages@gmail.com, Peter Zijlstra , Ingo Molnar , linux-man , lkml , Thomas Gleixner Message-ID: Date: Wed, 23 Nov 2016 14:47:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1479897217.4306.6.camel@gmx.de> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2927 Lines: 79 Hello Mike, On 11/23/2016 11:33 AM, Mike Galbraith wrote: > On Tue, 2016-11-22 at 16:59 +0100, Michael Kerrisk (man-pages) wrote: > >> ┌─────────────────────────────────────────────────────┐ >> │FIXME │ >> ├─────────────────────────────────────────────────────┤ >> │Regarding the previous paragraph... My tests indi‐ │ >> │cate that writing *any* value to the autogroup file │ >> │causes the task group to get a lower priority. This │ > > Because autogroup didn't call the then meaningless scale_load()... So, does that mean that this buglet kicked in starting (only) in Linux 4.7 with commit 2159197d66770ec01f75c93fb11dc66df81fd45b? > Autogroup nice level adjustment has been broken ever since load > resolution was increased for 64bit kernels. Use scale_load() to > scale group weight. Tested-by: Michael Kerrisk 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. Thanks, Michael > Signed-off-by: Mike Galbraith > Reported-by: Michael Kerrisk > Cc: stable@vger.kernel.org > --- > kernel/sched/auto_group.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > --- a/kernel/sched/auto_group.c > +++ b/kernel/sched/auto_group.c > @@ -192,6 +192,7 @@ int proc_sched_autogroup_set_nice(struct > { > static unsigned long next = INITIAL_JIFFIES; > struct autogroup *ag; > + unsigned long shares; > int err; > > if (nice < MIN_NICE || nice > MAX_NICE) > @@ -210,9 +211,10 @@ int proc_sched_autogroup_set_nice(struct > > 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); > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/