Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1527655 > unrolled thread

RFC: documentation of the autogroup feature

Started by"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
First post2016-11-22 17:20 +0100
Last post2016-11-29 14:50 +0100
Articles 20 on this page of 38 — 5 participants

Back to article view | Back to linux.kernel


Contents

  RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-22 17:20 +0100
    [patch] sched/autogroup: Fix 64bit kernel nice adjustment Mike Galbraith <efault@gmx.de> - 2016-11-23 11:40 +0100
      Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-23 14:50 +0100
        Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment Mike Galbraith <efault@gmx.de> - 2016-11-23 15:20 +0100
          Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-23 15:30 +0100
            Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment Mike Galbraith <efault@gmx.de> - 2016-11-23 17:00 +0100
      [tip:sched/urgent] sched/autogroup: Fix 64-bit kernel nice level  adjustment tip-bot for Mike Galbraith <tipbot@zytor.com> - 2016-11-24 07:30 +0100
    Re: RFC: documentation of the autogroup feature Mike Galbraith <efault@gmx.de> - 2016-11-23 12:50 +0100
      Re: RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-23 15:00 +0100
        Re: RFC: documentation of the autogroup feature Mike Galbraith <efault@gmx.de> - 2016-11-23 16:40 +0100
          Re: RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-23 17:10 +0100
            Re: RFC: documentation of the autogroup feature Mike Galbraith <efault@gmx.de> - 2016-11-23 18:20 +0100
              Re: RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-23 23:50 +0100
          Re: RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-23 17:10 +0100
            Re: RFC: documentation of the autogroup feature Mike Galbraith <efault@gmx.de> - 2016-11-23 18:20 +0100
              RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-24 22:50 +0100
                Re: RFC: documentation of the autogroup feature [v2] Afzal Mohammed <afzal.mohd.ma@gmail.com> - 2016-11-25 14:00 +0100
                  Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 14:10 +0100
                Re: RFC: documentation of the autogroup feature [v2] Mike Galbraith <efault@gmx.de> - 2016-11-25 14:30 +0100
                  Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 16:30 +0100
                    Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 16:50 +0100
                    Re: RFC: documentation of the autogroup feature [v2] Mike Galbraith <efault@gmx.de> - 2016-11-25 17:00 +0100
                      Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 17:20 +0100
                        Re: RFC: documentation of the autogroup feature [v2] Peter Zijlstra <peterz@infradead.org> - 2016-11-25 17:20 +0100
                          Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 17:40 +0100
                            Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 22:00 +0100
                              Re: RFC: documentation of the autogroup feature [v2] Peter Zijlstra <peterz@infradead.org> - 2016-11-25 22:50 +0100
                                Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-29 08:50 +0100
                                  Re: RFC: documentation of the autogroup feature [v2] Peter Zijlstra <peterz@infradead.org> - 2016-11-29 12:50 +0100
                                    Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-29 14:50 +0100
                    Re: RFC: documentation of the autogroup feature [v2] Peter Zijlstra <peterz@infradead.org> - 2016-11-25 17:10 +0100
                      Re: RFC: documentation of the autogroup feature [v2] Peter Zijlstra <peterz@infradead.org> - 2016-11-25 17:20 +0100
                      Re: RFC: documentation of the autogroup feature [v2] "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-25 17:40 +0100
                        Re: RFC: documentation of the autogroup feature [v2] Peter Zijlstra <peterz@infradead.org> - 2016-11-25 23:50 +0100
          Re: RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-27 22:20 +0100
            Re: RFC: documentation of the autogroup feature Mike Galbraith <efault@gmx.de> - 2016-11-28 02:50 +0100
              Re: RFC: documentation of the autogroup feature "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> - 2016-11-29 10:20 +0100
                Re: RFC: documentation of the autogroup feature Mike Galbraith <efault@gmx.de> - 2016-11-29 14:50 +0100

Page 1 of 2  [1] 2  Next page →


#1527655 — RFC: documentation of the autogroup feature

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-22 17:20 +0100
SubjectRFC: documentation of the autogroup feature
Message-ID<sGlXA-18B-37@gated-at.bofh.it>
Hello Mike and others,

The autogroup feature that you added in 2.6.38 remains poorly 
documented, so I took a stab at adding some text to the sched(7) 
manual page. There are still a few pieces to be fixed, and you 
may also see some other pieces that should be added. Could I 
ask you to take a look at the text below?

Cheers,

Michael

   The autogroup feature
       Since Linux 2.6.38, the kernel  provides  a  feature  known  as
       autogrouping  to improve interactive desktop performance in the
       face of multiprocess CPU-intensive workloads such  as  building
       the Linux kernel with large numbers of parallel build processes
       (i.e., the make(1) -j flag).

       This feature operates in conjunction with the CFS scheduler and
       requires  a  kernel  that is configured with CONFIG_SCHED_AUTO‐
       GROUP.  On a running system, this feature is  enabled  or  dis‐
       abled  via the file /proc/sys/kernel/sched_autogroup_enabled; a
       value of 0 disables the feature, while a value of 1 enables it.
       The  default  value  in  this  file is 1, unless the kernel was
       booted with the noautogroup parameter.

       When  autogrouping  is  enabled,  processes  are  automatically
       placed  into  "task groups" for the purposes of scheduling.  In
       the current implementation, a new task group is created when  a
       new  session is created via setsid(2), as happens, for example,
       when a new terminal window is created.  A task group  is  auto‐
       matically  destroyed  when the last process in the group termi‐
       nates.



       ┌─────────────────────────────────────────────────────┐
       │FIXME                                                │
       ├─────────────────────────────────────────────────────┤
       │The following is a little vague. Does it need to  be │
       │made more precise?                                   │
       └─────────────────────────────────────────────────────┘
       The CFS scheduler employs an algorithm that distributes the CPU
       across task groups.  As a result of this  algorithm,  the  pro‐
       cesses  in task groups that contain multiple CPU-intensive pro‐
       cesses are in effect disfavored by the scheduler.

       A process's autogroup (task group) membership can be viewed via
       the file /proc/[pid]/autogroup:

           $ cat /proc/1/autogroup
           /autogroup-1 nice 0

       This  file  can  also be used to modify the CPU bandwidth allo‐
       cated to a task group.  This is done by writing a number in the
       "nice"  range  to  the file to set the task group's nice value.
       The allowed range is from +19 (low priority) to -20 (high  pri‐
       ority).   Note that all values in this range cause a task group
       to be further disfavored by the scheduler, with  -20  resulting
       in  the  scheduler  mildy  disfavoring  the  task group and +19
       greatly disfavoring it.


       ┌─────────────────────────────────────────────────────┐
       │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 │
       │somewhat surprised me, since I assumed (based on the │
       │parallel with the process nice(2) value) that  nega‐ │
       │tive  values  might  boost the task group's priority │
       │above a task group whose autogroup file had not been │
       │touched.                                             │
       │                                                     │
       │Is this the expected behavior? I presume it is...    │
       │                                                     │
       │But  then there's a small surprise in the interface. │
       │Suppose that the value 0 is written to the autogroup │
       │file, then this results in the task group being sig‐ │
       │nificantly disfavored. But, the nice  value  *shown* │
       │in  the  autogroup  file  will be the same as if the │
       │file had not been modified. So, the user has no  way │
       │of discovering the difference. That seems odd.  Am I │
       │missing something?                                   │
       └─────────────────────────────────────────────────────┘



       ┌─────────────────────────────────────────────────────┐
       │FIXME                                                │
       ├─────────────────────────────────────────────────────┤
       │Is the following correct? Does the statement need to │
       │be  more  precise? (E.g., in precisely which circum‐ │
       │stances does the use of cgroups override autogroup?) │
       └─────────────────────────────────────────────────────┘
       The use of the cgroups(7) CPU controller overrides  the  effect
       of autogrouping.


       ┌─────────────────────────────────────────────────────┐
       │FIXME                                                │
       ├─────────────────────────────────────────────────────┤
       │What  needs to be said about autogroup and real-time │
       │tasks?                                               │
       └─────────────────────────────────────────────────────┘


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [next] | [standalone]


#1528301 — [patch] sched/autogroup: Fix 64bit kernel nice adjustment

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 11:40 +0100
Subject[patch] sched/autogroup: Fix 64bit kernel nice adjustment
Message-ID<sGD86-3GY-35@gated-at.bofh.it>
In reply to#1527655
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()...


Autogroup nice level adjustment has been broken ever since load
resolution was increased for 64bit kernels.  Use scale_load() to
scale group weight.

Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Reported-by: Michael Kerrisk <mtk.manpages@gmail.com>
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);

[toc] | [prev] | [next] | [standalone]


#1528428 — Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-23 14:50 +0100
SubjectRe: [patch] sched/autogroup: Fix 64bit kernel nice adjustment
Message-ID<sGG5Y-5zw-39@gated-at.bofh.it>
In reply to#1528301
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 <mtk.manpages@gmail.com>

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 <umgwanakikbuti@gmail.com>
> Reported-by: Michael Kerrisk <mtk.manpages@gmail.com>
> 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/

[toc] | [prev] | [next] | [standalone]


#1528437 — Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 15:20 +0100
SubjectRe: [patch] sched/autogroup: Fix 64bit kernel nice adjustment
Message-ID<sGGz0-5Zq-23@gated-at.bofh.it>
In reply to#1528428
On Wed, 2016-11-23 at 14:47 +0100, Michael Kerrisk (man-pages) wrote:
> 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?

Yeah, that gave it teeth.

	-Mike

[toc] | [prev] | [next] | [standalone]


#1528445 — Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-23 15:30 +0100
SubjectRe: [patch] sched/autogroup: Fix 64bit kernel nice adjustment
Message-ID<sGGIF-62A-19@gated-at.bofh.it>
In reply to#1528437
On 11/23/2016 03:12 PM, Mike Galbraith wrote:
> On Wed, 2016-11-23 at 14:47 +0100, Michael Kerrisk (man-pages) wrote:
>> 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?
> 
> Yeah, that gave it teeth.

Thanks for the confirmation. Are you aiming to see the fix 
merged for 4.9, or will this wait for 4.10?

Cheers,

Michael



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1528532 — Re: [patch] sched/autogroup: Fix 64bit kernel nice adjustment

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 17:00 +0100
SubjectRe: [patch] sched/autogroup: Fix 64bit kernel nice adjustment
Message-ID<sGI7M-6KY-5@gated-at.bofh.it>
In reply to#1528445
On Wed, 2016-11-23 at 15:20 +0100, Michael Kerrisk (man-pages) wrote:

> Thanks for the confirmation. Are you aiming to see the fix 
> merged for 4.9, or will this wait for 4.10?

Dunno, that's up to Peter/Ingo.  It's unlikely that anyone other than
we two will notice a thing either way :) 

	-Mike

[toc] | [prev] | [next] | [standalone]


#1529022 — [tip:sched/urgent] sched/autogroup: Fix 64-bit kernel nice level adjustment

Fromtip-bot for Mike Galbraith <tipbot@zytor.com>
Date2016-11-24 07:30 +0100
Subject[tip:sched/urgent] sched/autogroup: Fix 64-bit kernel nice level adjustment
Message-ID<sGVHH-7nD-11@gated-at.bofh.it>
In reply to#1528301
Commit-ID:  83929cce95251cc77e5659bf493bd424ae0e7a67
Gitweb:     http://git.kernel.org/tip/83929cce95251cc77e5659bf493bd424ae0e7a67
Author:     Mike Galbraith <efault@gmx.de>
AuthorDate: Wed, 23 Nov 2016 11:33:37 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
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 <mtk.manpages@gmail.com>
Tested-by: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-man <linux-man@vger.kernel.org>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1479897217.4306.6.camel@gmx.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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);

[toc] | [prev] | [next] | [standalone]


#1528342

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 12:50 +0100
Message-ID<sGEdQ-4jn-3@gated-at.bofh.it>
In reply to#1527655
On Tue, 2016-11-22 at 16:59 +0100, Michael Kerrisk (man-pages) wrote:

>        ┌─────────────────────────────────────────────────────┐
>        │FIXME                                                │
>        ├─────────────────────────────────────────────────────┤
>        │The following is a little vague. Does it need to  be │
>        │made more precise?                                   │
>        └─────────────────────────────────────────────────────┘
>        The CFS scheduler employs an algorithm that distributes the CPU
>        across task groups.  As a result of this  algorithm,  the  pro‐
>        cesses  in task groups that contain multiple CPU-intensive pro‐
>        cesses are in effect disfavored by the scheduler.

Mmmm, they're actually equalized (modulo smp fairness goop), but I see
what you mean.

>        A process's autogroup (task group) membership can be viewed via
>        the file /proc/[pid]/autogroup:
> 
>            $ cat /proc/1/autogroup
>            /autogroup-1 nice 0
> 
>        This  file  can  also be used to modify the CPU bandwidth allo‐
>        cated to a task group.  This is done by writing a number in the
>        "nice"  range  to  the file to set the task group's nice value.
>        The allowed range is from +19 (low priority) to -20 (high  pri‐
>        ority).   Note that all values in this range cause a task group
>        to be further disfavored by the scheduler, with  -20  resulting
>        in  the  scheduler  mildy  disfavoring  the  task group and +19
>        greatly disfavoring it.

Group nice levels exactly work the same as task nice levels, ie
negative nice increases share, positive nice decreases it relative to
the default nice 0.

>        ┌─────────────────────────────────────────────────────┐
>        │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.

(patchlet.. I'd prefer to whack the knob, but like the on/off switch,
it may be in use, so I guess we're stuck with it)

>        ┌─────────────────────────────────────────────────────┐
>        │FIXME                                                │
>        ├─────────────────────────────────────────────────────┤
>        │Is the following correct? Does the statement need to │
>        │be  more  precise? (E.g., in precisely which circum‐ │
>        │stances does the use of cgroups override autogroup?) │
>        └─────────────────────────────────────────────────────┘
>        The use of the cgroups(7) CPU controller overrides  the  effect
>        of autogrouping.

Correct, autogroup defers to cgroups.  Perhaps mention that moving a
task back to the root task group will result in the autogroup again
taking effect.

>        ┌─────────────────────────────────────────────────────┐
>        │FIXME                                                │
>        ├─────────────────────────────────────────────────────┤
>        │What  needs to be said about autogroup and real-time │
>        │tasks?                                               │
>        └─────────────────────────────────────────────────────┘

That it does not group realtime tasks, they are auto-deflected to the
root task group.

	-Mike

[toc] | [prev] | [next] | [standalone]


#1528430

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-23 15:00 +0100
Message-ID<sGGfD-5CK-3@gated-at.bofh.it>
In reply to#1528342
Hi Mike,

First off, I better say that I'm not at all intimate with the details
of the scheduler, so bear with me...

On 11/23/2016 12:39 PM, Mike Galbraith wrote:
> On Tue, 2016-11-22 at 16:59 +0100, Michael Kerrisk (man-pages) wrote:
> 
>>        ┌─────────────────────────────────────────────────────┐
>>        │FIXME                                                │
>>        ├─────────────────────────────────────────────────────┤
>>        │The following is a little vague. Does it need to  be │
>>        │made more precise?                                   │
>>        └─────────────────────────────────────────────────────┘
>>        The CFS scheduler employs an algorithm that distributes the CPU
>>        across task groups.  As a result of this  algorithm,  the  pro‐
>>        cesses  in task groups that contain multiple CPU-intensive pro‐
>>        cesses are in effect disfavored by the scheduler.
> 
> Mmmm, they're actually equalized (modulo smp fairness goop), but I see
> what you mean.

I couldn't quite grok that sentence. My problem is resolving "they".
Do you mean: "the CPU scheduler equalizes the distribution of
CPU cycles across task groups"?

> 
>>        A process's autogroup (task group) membership can be viewed via
>>        the file /proc/[pid]/autogroup:
>>
>>            $ cat /proc/1/autogroup
>>            /autogroup-1 nice 0
>>
>>        This  file  can  also be used to modify the CPU bandwidth allo‐
>>        cated to a task group.  This is done by writing a number in the
>>        "nice"  range  to  the file to set the task group's nice value.
>>        The allowed range is from +19 (low priority) to -20 (high  pri‐
>>        ority).   Note that all values in this range cause a task group
>>        to be further disfavored by the scheduler, with  -20  resulting
>>        in  the  scheduler  mildy  disfavoring  the  task group and +19
>>        greatly disfavoring it.
> 
> Group nice levels exactly work the same as task nice levels, ie
> negative nice increases share, positive nice decreases it relative to
> the default nice 0.

Yes, got it now.

>>        ┌─────────────────────────────────────────────────────┐
>>        │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.
> 
> (patchlet.. 

Writing documentation finds bugs. Who knew? ;-)

> I'd prefer to whack the knob, but like the on/off switch,
> it may be in use, so I guess we're stuck with it)
> 
>>        ┌─────────────────────────────────────────────────────┐
>>        │FIXME                                                │
>>        ├─────────────────────────────────────────────────────┤
>>        │Is the following correct? Does the statement need to │
>>        │be  more  precise? (E.g., in precisely which circum‐ │
>>        │stances does the use of cgroups override autogroup?) │
>>        └─────────────────────────────────────────────────────┘
>>        The use of the cgroups(7) CPU controller overrides  the  effect
>>        of autogrouping.
> 
> Correct, autogroup defers to cgroups.  Perhaps mention that moving a
> task back to the root task group will result in the autogroup again
> taking effect.

In what circumstances does a process get moved back to the root 
task group? 

Actually, can you define for me what the root task group is, and 
why it exists? That may be worth some words in this man page.

>>        ┌─────────────────────────────────────────────────────┐
>>        │FIXME                                                │
>>        ├─────────────────────────────────────────────────────┤
>>        │What  needs to be said about autogroup and real-time │
>>        │tasks?                                               │
>>        └─────────────────────────────────────────────────────┘
> 
> That it does not group realtime tasks, they are auto-deflected to the
> root task group.

Okay. Thanks.

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1528517

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 16:40 +0100
Message-ID<sGHOq-6Ev-33@gated-at.bofh.it>
In reply to#1528430
On Wed, 2016-11-23 at 14:54 +0100, Michael Kerrisk (man-pages) wrote:
> Hi Mike,
> 
> First off, I better say that I'm not at all intimate with the details
> of the scheduler, so bear with me...
> 
> On 11/23/2016 12:39 PM, Mike Galbraith wrote:
> > On Tue, 2016-11-22 at 16:59 +0100, Michael Kerrisk (man-pages) wrote:
> > 
> > >        ┌─────────────────────────────────────────────────────┐
> > >        │FIXME                                                │
> > >        ├─────────────────────────────────────────────────────┤
> > >        │The following is a little vague. Does it need to  be │
> > >        │made more precise?                                   │
> > >        └─────────────────────────────────────────────────────┘
> > >        The CFS scheduler employs an algorithm that distributes the CPU
> > >        across task groups.  As a result of this  algorithm,  the  pro‐
> > >        cesses  in task groups that contain multiple CPU-intensive pro‐
> > >        cesses are in effect disfavored by the scheduler.
> > 
> > Mmmm, they're actually equalized (modulo smp fairness goop), but I see
> > what you mean.
> 
> I couldn't quite grok that sentence. My problem is resolving "they".
> Do you mean: "the CPU scheduler equalizes the distribution of
> CPU cycles across task groups"?

Sort of.  "They" are scheduler entities, runqueue (group) or task.  The
scheduler equalizes entity vruntimes.
 
> > >        │FIXME                                                │
> > >        ├─────────────────────────────────────────────────────┤
> > >        │Is the following correct? Does the statement need to │
> > >        │be  more  precise? (E.g., in precisely which circum‐ │
> > >        │stances does the use of cgroups override autogroup?) │
> > >        └─────────────────────────────────────────────────────┘
> > >        The use of the cgroups(7) CPU controller overrides  the  effect
> > >        of autogrouping.
> > 
> > Correct, autogroup defers to cgroups.  Perhaps mention that moving a
> > task back to the root task group will result in the autogroup again
> > taking effect.
> 
> In what circumstances does a process get moved back to the root 
> task group?

Userspace actions, tool or human fingers.
 
 
> Actually, can you define for me what the root task group is, and 
> why it exists? That may be worth some words in this man page.

I don't think we need group scheduling details, there's plenty of
documentation elsewhere for those who want theory.  Autogroup is for
those who don't want to have to care (which is also why it should have
never grown nice knob).

	-Mike

[toc] | [prev] | [next] | [standalone]


#1528542

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-23 17:10 +0100
Message-ID<sGIhr-71P-17@gated-at.bofh.it>
In reply to#1528517
> I don't think we need group scheduling details, there's plenty of
> documentation elsewhere for those who want theory.  

Actually, which documentation were you referring to here?

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1528609

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 18:20 +0100
Message-ID<sGJnb-7Id-15@gated-at.bofh.it>
In reply to#1528542
On Wed, 2016-11-23 at 17:05 +0100, Michael Kerrisk (man-pages) wrote:
> > I don't think we need group scheduling details, there's plenty of
> > documentation elsewhere for those who want theory.  
> 
> Actually, which documentation were you referring to here?

Documentation/scheduler/*

[toc] | [prev] | [next] | [standalone]


#1528821

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-23 23:50 +0100
Message-ID<sGOwy-2sG-25@gated-at.bofh.it>
In reply to#1528609
On 11/23/2016 06:19 PM, Mike Galbraith wrote:
> On Wed, 2016-11-23 at 17:05 +0100, Michael Kerrisk (man-pages) wrote:
>>> I don't think we need group scheduling details, there's plenty of
>>> documentation elsewhere for those who want theory.  
>>
>> Actually, which documentation were you referring to here?
> 
> Documentation/scheduler/*

I think there's a lot less information in there than you think...
Certainly, I can't get any big picture from reading those docs.

Cheers

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1528545

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-23 17:10 +0100
Message-ID<sGIhs-71P-35@gated-at.bofh.it>
In reply to#1528517
Hi Mike,

On 11/23/2016 04:33 PM, Mike Galbraith wrote:
> On Wed, 2016-11-23 at 14:54 +0100, Michael Kerrisk (man-pages) wrote:
>> Hi Mike,
>>
>> First off, I better say that I'm not at all intimate with the details
>> of the scheduler, so bear with me...
>>
>> On 11/23/2016 12:39 PM, Mike Galbraith wrote:
>>> On Tue, 2016-11-22 at 16:59 +0100, Michael Kerrisk (man-pages) wrote:
>>>
>>>>        ┌─────────────────────────────────────────────────────┐
>>>>        │FIXME                                                │
>>>>        ├─────────────────────────────────────────────────────┤
>>>>        │The following is a little vague. Does it need to  be │
>>>>        │made more precise?                                   │
>>>>        └─────────────────────────────────────────────────────┘
>>>>        The CFS scheduler employs an algorithm that distributes the CPU
>>>>        across task groups.  As a result of this  algorithm,  the  pro‐
>>>>        cesses  in task groups that contain multiple CPU-intensive pro‐
>>>>        cesses are in effect disfavored by the scheduler.
>>>
>>> Mmmm, they're actually equalized (modulo smp fairness goop), but I see
>>> what you mean.
>>
>> I couldn't quite grok that sentence. My problem is resolving "they".
>> Do you mean: "the CPU scheduler equalizes the distribution of
>> CPU cycles across task groups"?
> 
> Sort of.  "They" are scheduler entities, runqueue (group) or task.  The
> scheduler equalizes entity vruntimes.

Okay -- I'll see if I can come up with some wording there.

>  
>>>>        │FIXME                                                │
>>>>        ├─────────────────────────────────────────────────────┤
>>>>        │Is the following correct? Does the statement need to │
>>>>        │be  more  precise? (E.g., in precisely which circum‐ │
>>>>        │stances does the use of cgroups override autogroup?) │
>>>>        └─────────────────────────────────────────────────────┘
>>>>        The use of the cgroups(7) CPU controller overrides  the  effect
>>>>        of autogrouping.
>>>
>>> Correct, autogroup defers to cgroups.  Perhaps mention that moving a
>>> task back to the root task group will result in the autogroup again
>>> taking effect.
>>
>> In what circumstances does a process get moved back to the root 
>> task group?
> 
> Userspace actions, tool or human fingers.

Could you say a little more please. What Kernel-user-space 
APIs/system calls/etc. cause this to happen?

>> Actually, can you define for me what the root task group is, and 
>> why it exists? That may be worth some words in this man page.
> 
> I don't think we need group scheduling details, there's plenty of
> documentation elsewhere for those who want theory.  

Well, you suggested above 

    Perhaps mention that moving a task back to the root task
    group will result in the autogroup again taking effect.

So, that inevitable would lead me and the reader of the man page
to ask: what's the root task group?

> Autogroup is for
> those who don't want to have to care (which is also why it should have
> never grown nice knob).

Yes, that I understand that much :-).

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1528610

FromMike Galbraith <efault@gmx.de>
Date2016-11-23 18:20 +0100
Message-ID<sGJnb-7Id-17@gated-at.bofh.it>
In reply to#1528545
On Wed, 2016-11-23 at 17:04 +0100, Michael Kerrisk (man-pages) wrote:

> > > In what circumstances does a process get moved back to the root 
> > > task group?
> > 
> > Userspace actions, tool or human fingers.
> 
> Could you say a little more please. What Kernel-user-space 
> APIs/system calls/etc. cause this to happen?

Well, the system call would be write(), scribbling in the cgroups vfs
interface.. not all that helpful without ever more technical detail.

> > > Actually, can you define for me what the root task group is, and 
> > > why it exists? That may be worth some words in this man page.
> > 
> > I don't think we need group scheduling details, there's plenty of
> > documentation elsewhere for those who want theory.  
> 
> Well, you suggested above 
> 
>     Perhaps mention that moving a task back to the root task
>     group will result in the autogroup again taking effect.

Dang, evolution doesn't have an unsend button :)

	-Mike

[toc] | [prev] | [next] | [standalone]


#1529715 — RFC: documentation of the autogroup feature [v2]

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-24 22:50 +0100
SubjectRFC: documentation of the autogroup feature [v2]
Message-ID<sHa41-8qT-7@gated-at.bofh.it>
In reply to#1528610
Hi Mike,

I reworked the text on autogroups, and in the process learned
something/have another question. Could you tell me if anything 
in the below needs fixing/improving, and also let me know about
the FIXME?

Thanks,

Michael

   The autogroup feature
       Since Linux 2.6.38, the kernel  provides  a  feature  known  as
       autogrouping  to improve interactive desktop performance in the
       face of multiprocess, CPU-intensive workloads such as  building
       the Linux kernel with large numbers of parallel build processes
       (i.e., the make(1) -j flag).

       This feature operates in conjunction with the CFS scheduler and
       requires  a  kernel  that is configured with CONFIG_SCHED_AUTO‐
       GROUP.  On a running system, this feature is  enabled  or  dis‐
       abled  via the file /proc/sys/kernel/sched_autogroup_enabled; a
       value of 0 disables the feature, while a value of 1 enables it.
       The  default  value  in  this  file is 1, unless the kernel was
       booted with the noautogroup parameter.

       A new autogroup is created created when a new session  is  cre‐
       ated  via setsid(2); this happens, for example, when a new ter‐
       minal window is started.  A  new  process  created  by  fork(2)
       inherits  its  parent's autogroup membership.  Thus, all of the
       processes in a session are members of the same  autogroup.   An
       autogroup  is  automatically destroyed when the last process in
       the group terminates.

       When autogrouping is enabled, all of the members  of  an  auto‐
       group  are  placed  in  the same kernel scheduler "task group".
       The CFS scheduler employs an algorithm that equalizes the  dis‐
       tribution  of  CPU  cycles across task groups.  The benefits of
       this for interactive desktop performance can be  described  via
       the following example.

       Suppose  that  there  are two autogroups competing for the same
       CPU.  The first group contains ten CPU-bound processes  from  a
       kernel build started with make -j10.  The other contains a sin‐
       gle CPU-bound process: a video player.   The  effect  of  auto‐
       grouping  is  that the two groups will each receive half of the
       CPU cycles.  That is, the video player will receive 50% of  the
       CPU  cycles,  rather  just 9% of the cycles, which would likely
       lead to degraded video playback.  Or to put things another way:
       an  autogroup  that  contains  a large number of CPU-bound pro‐
       cesses does not end up overwhelming the CPU at the  expense  of
       the other jobs on the system.

       A process's autogroup (task group) membership can be viewed via
       the file /proc/[pid]/autogroup:

           $ cat /proc/1/autogroup
           /autogroup-1 nice 0

       This file can also be used to modify the  CPU  bandwidth  allo‐
       cated to an autogroup.  This is done by writing a number in the
       "nice" range to the file to set  the  autogroup's  nice  value.
       The  allowed range is from +19 (low priority) to -20 (high pri‐
       ority), and the setting has the same effect  as  modifying  the
       nice  level  via getpriority(2).  (For a discussion of the nice
       value, see getpriority(2).)


       ┌─────────────────────────────────────────────────────┐
       │FIXME                                                │
       ├─────────────────────────────────────────────────────┤
       │How do the nice value of  a  process  and  the  nice │
       │value of an autogroup interact? Which has priority?  │
       │                                                     │
       │It  *appears*  that the autogroup nice value is used │
       │for CPU distribution between task groups,  and  that │
       │the  process nice value has no effect there.  (I.e., │
       │suppose two  autogroups  each  contain  a  CPU-bound │
       │process,  with  one  process  having nice==0 and the │
       │other having nice==19.  It appears  that  they  each │
       │get  50%  of  the CPU.)  It appears that the process │
       │nice value has effect only with respect to  schedul‐ │
       │ing  relative to other processes in the *same* auto‐ │
       │group.  Is this correct?                             │
       └─────────────────────────────────────────────────────┘

       The use of the cgroups(7) CPU controller overrides  the  effect
       of autogrouping.

       The  autogroup feature does not group processes that are sched‐
       uled under a real-time and deadline policies.  Those  processes
       are scheduled according to the rules described earlier.


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1530202 — Re: RFC: documentation of the autogroup feature [v2]

FromAfzal Mohammed <afzal.mohd.ma@gmail.com>
Date2016-11-25 14:00 +0100
SubjectRe: RFC: documentation of the autogroup feature [v2]
Message-ID<sHogG-FW-21@gated-at.bofh.it>
In reply to#1529715
Hi,

On Thu, Nov 24, 2016 at 10:41:29PM +0100, Michael Kerrisk (man-pages) wrote:

>        Suppose  that  there  are two autogroups competing for the same
>        CPU.  The first group contains ten CPU-bound processes  from  a
>        kernel build started with make -j10.  The other contains a sin‐
>        gle CPU-bound process: a video player.   The  effect  of  auto‐
>        grouping  is  that the two groups will each receive half of the
>        CPU cycles.  That is, the video player will receive 50% of  the
>        CPU  cycles,  rather  just 9% of the cycles, which would likely
                            ^^^^
                            than ?

Regards
afzal

>        lead to degraded video playback.  Or to put things another way:
>        an  autogroup  that  contains  a large number of CPU-bound pro‐
>        cesses does not end up overwhelming the CPU at the  expense  of
>        the other jobs on the system.

[toc] | [prev] | [next] | [standalone]


#1530217 — Re: RFC: documentation of the autogroup feature [v2]

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-25 14:10 +0100
SubjectRe: RFC: documentation of the autogroup feature [v2]
Message-ID<sHoqm-YR-61@gated-at.bofh.it>
In reply to#1530202
On 11/25/2016 01:52 PM, Afzal Mohammed wrote:
> Hi,
> 
> On Thu, Nov 24, 2016 at 10:41:29PM +0100, Michael Kerrisk (man-pages) wrote:
> 
>>        Suppose  that  there  are two autogroups competing for the same
>>        CPU.  The first group contains ten CPU-bound processes  from  a
>>        kernel build started with make -j10.  The other contains a sin‐
>>        gle CPU-bound process: a video player.   The  effect  of  auto‐
>>        grouping  is  that the two groups will each receive half of the
>>        CPU cycles.  That is, the video player will receive 50% of  the
>>        CPU  cycles,  rather  just 9% of the cycles, which would likely
>                             ^^^^
>                             than ?
> 
> Regards
> afzal

Thanks, Afzal. Fixed!

Cheers,

Michael

> 
>>        lead to degraded video playback.  Or to put things another way:
>>        an  autogroup  that  contains  a large number of CPU-bound pro‐
>>        cesses does not end up overwhelming the CPU at the  expense  of
>>        the other jobs on the system.
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


#1530238 — Re: RFC: documentation of the autogroup feature [v2]

FromMike Galbraith <efault@gmx.de>
Date2016-11-25 14:30 +0100
SubjectRe: RFC: documentation of the autogroup feature [v2]
Message-ID<sHoJH-15u-7@gated-at.bofh.it>
In reply to#1529715
On Thu, 2016-11-24 at 22:41 +0100, Michael Kerrisk (man-pages) wrote:

>        Suppose  that  there  are two autogroups competing for the same
>        CPU.  The first group contains ten CPU-bound processes  from  a
>        kernel build started with make -j10.  The other contains a sin‐
>        gle CPU-bound process: a video player.   The  effect  of  auto‐
>        grouping  is  that the two groups will each receive half of the
>        CPU cycles.  That is, the video player will receive 50% of  the
>        CPU  cycles,  rather  just 9% of the cycles, which would likely
>        lead to degraded video playback.  Or to put things another way:
>        an  autogroup  that  contains  a large number of CPU-bound pro‐
>        cesses does not end up overwhelming the CPU at the  expense  of
>        the other jobs on the system.

I'd say something more wishy-washy here, like cycles are distributed
fairly across groups and leave it at that, as your detailed example is
incorrect due to SMP fairness (which I don't like much because [very
unlikely] worst case scenario renders a box sized group incapable of
utilizing more that a single CPU total).  For example, if a group of
NR_CPUS size competes with a singleton, load balancing will try to give
the singleton a full CPU of its very own.  If groups intersect for
whatever reason on say my quad lappy, distribution is 80/20 in favor of
the singleton.

>        ┌─────────────────────────────────────────────────────┐
>        │FIXME                                                │
>        ├─────────────────────────────────────────────────────┤
>        │How do the nice value of  a  process  and  the  nice │
>        │value of an autogroup interact? Which has priority?  │
>        │                                                     │
>        │It  *appears*  that the autogroup nice value is used │
>        │for CPU distribution between task groups,  and  that │
>        │the  process nice value has no effect there.  (I.e., │
>        │suppose two  autogroups  each  contain  a  CPU-bound │
>        │process,  with  one  process  having nice==0 and the │
>        │other having nice==19.  It appears  that  they  each │
>        │get  50%  of  the CPU.)  It appears that the process │
>        │nice value has effect only with respect to  schedul‐ │
>        │ing  relative to other processes in the *same* auto‐ │
>        │group.  Is this correct?                             │
>        └─────────────────────────────────────────────────────┘

Yup, entity nice level affects distribution among peer entities.

	-Mike

[toc] | [prev] | [next] | [standalone]


#1530354 — Re: RFC: documentation of the autogroup feature [v2]

From"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Date2016-11-25 16:30 +0100
SubjectRe: RFC: documentation of the autogroup feature [v2]
Message-ID<sHqBQ-2hw-27@gated-at.bofh.it>
In reply to#1530238
Hi Mike,

On 11/25/2016 02:02 PM, Mike Galbraith wrote:
> On Thu, 2016-11-24 at 22:41 +0100, Michael Kerrisk (man-pages) wrote:
> 
>>        Suppose  that  there  are two autogroups competing for the same
>>        CPU.  The first group contains ten CPU-bound processes  from  a
>>        kernel build started with make -j10.  The other contains a sin‐
>>        gle CPU-bound process: a video player.   The  effect  of  auto‐
>>        grouping  is  that the two groups will each receive half of the
>>        CPU cycles.  That is, the video player will receive 50% of  the
>>        CPU  cycles,  rather  just 9% of the cycles, which would likely
>>        lead to degraded video playback.  Or to put things another way:
>>        an  autogroup  that  contains  a large number of CPU-bound pro‐
>>        cesses does not end up overwhelming the CPU at the  expense  of
>>        the other jobs on the system.
> 
> I'd say something more wishy-washy here, like cycles are distributed
> fairly across groups and leave it at that, 

I see where you want to go, but the problem is that the word "fair"
will invoke different interpretations for different people. So, I
think one does need to be a little more concrete.

> as your detailed example is
> incorrect due to SMP fairness 

Well, I was trying to exclude SMP from the discussion by saying
"competing for the same CPU". Here I was meaning that we involve
taskset(1) to confine everyone to the same CPU. Then, I think
my example is correct. (I did some light testing before writing
that text.) But I guess my meaning wasn't clear enough, and
it is a slightly contrived scenario anyway. I'll add some words
to clarify my example, and also add something to say that the
situation is more complex on an SMP system. Something like
the following:

       Suppose that there are two autogroups competing for the  same  CPU
       (i.e., presume either a single CPU system or the use of taskset(1)
       to confine all the processes to the same CPU on  an  SMP  system).
       The  first  group  contains  ten CPU-bound processes from a kernel
       build started with make -j10.  The other contains  a  single  CPU-
       bound process: a video player.  The effect of autogrouping is that
       the two groups will each receive half of the CPU cycles.  That is,
       the  video  player will receive 50% of the CPU cycles, rather than
       just 9% of the cycles, which would likely lead to  degraded  video
       playback.  The situation on an SMP system is more complex, but the
       general effect is the same: the scheduler distributes  CPU  cycles
       across  task  groups  such that an autogroup that contains a large
       number of CPU-bound processes does not end up hoffing  CPU  cycles
       at the expense of the other jobs on the system.

> (which I don't like much because [very
> unlikely] worst case scenario renders a box sized group incapable of
> utilizing more that a single CPU total).  For example, if a group of
> NR_CPUS size competes with a singleton, load balancing will try to give
> the singleton a full CPU of its very own.  If groups intersect for
> whatever reason on say my quad lappy, distribution is 80/20 in favor of
> the singleton.

Thanks for the additional info. Good for educating me, but I think
you'll agree it's more than we need for the man page.

>>        ┌─────────────────────────────────────────────────────┐
>>        │FIXME                                                │
>>        ├─────────────────────────────────────────────────────┤
>>        │How do the nice value of  a  process  and  the  nice │
>>        │value of an autogroup interact? Which has priority?  │
>>        │                                                     │
>>        │It  *appears*  that the autogroup nice value is used │
>>        │for CPU distribution between task groups,  and  that │
>>        │the  process nice value has no effect there.  (I.e., │
>>        │suppose two  autogroups  each  contain  a  CPU-bound │
>>        │process,  with  one  process  having nice==0 and the │
>>        │other having nice==19.  It appears  that  they  each │
>>        │get  50%  of  the CPU.)  It appears that the process │
>>        │nice value has effect only with respect to  schedul‐ │
>>        │ing  relative to other processes in the *same* auto‐ │
>>        │group.  Is this correct?                             │
>>        └─────────────────────────────────────────────────────┘
> 
> Yup, entity nice level affects distribution among peer entities.

Huh! I only just learned about this via my experiments while
investigating autogroups. 

How long have things been like this? Always? (I don't think
so.) Since the arrival of CFS? Since the arrival of
autogrouping? (I'm guessing not.) Since some other point?
(When?)

It seems to me that this renders the traditional process
nice pretty much useless. (I bet I'm not the only one who'd 
be surprised by the current behavior.)

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.kernel


csiph-web