[PATCH v2] man/man7/sched.7: Mention autogroup disabled behavior

Phil Auld posted 1 patch 11 months ago
man/man7/sched.7 | 2 ++
1 file changed, 2 insertions(+)
[PATCH v2] man/man7/sched.7: Mention autogroup disabled behavior
Posted by Phil Auld 11 months ago
The autogroup feature can be contolled at runtime when
built into the kernel. Disabling it in this case still
creates autogroups and still shows the autogroup membership
for the task in /proc.  The scheduler code will just not
use the the autogroup task group.  This can be confusing
to users. Add a sentence to this effect to sched.7 to
point this out.

The kernel code shows how this is used. The
sched_autogroup_enabled toggle is only used in one place.

kernel/sched/autogroup.h:

static inline struct task_group *
autogroup_task_group(struct task_struct *p, struct task_group *tg)
{
        extern unsigned int sysctl_sched_autogroup_enabled;
        int enabled = READ_ONCE(sysctl_sched_autogroup_enabled);

        if (enabled && task_wants_autogroup(p, tg))
                return p->signal->autogroup->tg;

        return tg;
}

task_wants_autogroup() is in kernel/sched/autogroup.c:

bool task_wants_autogroup(struct task_struct *p, struct task_group *tg)
{
        if (tg != &root_task_group)
                return false;
    ...

        return true;
}

One can see that any group set other than root also bypasses the use of
the autogroup.

All of the machinery around the creation of the autogroup is not
effected by the toggle.

From userspace:
0
/autogroup-112 nice 0

Note, systemd based system these days is not really using autogroups at all
anyway because any task in a non-root cgroup bypasses the autogroup as
well.

Signed-off-by: Phil Auld <pauld@redhat.com>
Cc: Alejandro Colomar <alx@kernel.org>
Cc: <linux-man@vger.kernel.org>
---
 man/man7/sched.7 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/man/man7/sched.7 b/man/man7/sched.7
index 71f098e48..f0a708cd7 100644
--- a/man/man7/sched.7
+++ b/man/man7/sched.7
@@ -724,6 +724,8 @@ in the group terminates.
 .P
 When autogrouping is enabled, all of the members of an autogroup
 are placed in the same kernel scheduler "task group".
+When disabled the group creation happens as above, and autogroup membership
+is still visible in /proc, but the autogroups are not used.
 The CFS scheduler employs an algorithm that equalizes the
 distribution of CPU cycles across task groups.
 The benefits of this for interactive desktop performance
-- 
2.47.1
Re: [PATCH v2] man/man7/sched.7: Mention autogroup disabled behavior
Posted by Alejandro Colomar 10 months, 2 weeks ago
Hi Phil,

On Thu, Jan 16, 2025 at 02:37:47PM +0000, Phil Auld wrote:
> The autogroup feature can be contolled at runtime when
> built into the kernel. Disabling it in this case still
> creates autogroups and still shows the autogroup membership
> for the task in /proc.  The scheduler code will just not
> use the the autogroup task group.  This can be confusing
> to users. Add a sentence to this effect to sched.7 to
> point this out.
> 
> The kernel code shows how this is used. The
> sched_autogroup_enabled toggle is only used in one place.
> 
> kernel/sched/autogroup.h:
> 
> static inline struct task_group *
> autogroup_task_group(struct task_struct *p, struct task_group *tg)
> {
>         extern unsigned int sysctl_sched_autogroup_enabled;
>         int enabled = READ_ONCE(sysctl_sched_autogroup_enabled);
> 
>         if (enabled && task_wants_autogroup(p, tg))
>                 return p->signal->autogroup->tg;
> 
>         return tg;
> }
> 
> task_wants_autogroup() is in kernel/sched/autogroup.c:
> 
> bool task_wants_autogroup(struct task_struct *p, struct task_group *tg)
> {
>         if (tg != &root_task_group)
>                 return false;
>     ...
> 
>         return true;
> }
> 
> One can see that any group set other than root also bypasses the use of
> the autogroup.
> 
> All of the machinery around the creation of the autogroup is not
> effected by the toggle.
> 
> From userspace:
> 0
> /autogroup-112 nice 0
> 
> Note, systemd based system these days is not really using autogroups at all
> anyway because any task in a non-root cgroup bypasses the autogroup as
> well.
> 
> Signed-off-by: Phil Auld <pauld@redhat.com>
> Cc: Alejandro Colomar <alx@kernel.org>
> Cc: <linux-man@vger.kernel.org>

Thanks!  I've applied the patch.
<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=ca69daf45f94fda061f796efcc4f24ca76d8e380>


Have a lovely day!
Alex

> ---
>  man/man7/sched.7 | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/man/man7/sched.7 b/man/man7/sched.7
> index 71f098e48..f0a708cd7 100644
> --- a/man/man7/sched.7
> +++ b/man/man7/sched.7
> @@ -724,6 +724,8 @@ in the group terminates.
>  .P
>  When autogrouping is enabled, all of the members of an autogroup
>  are placed in the same kernel scheduler "task group".
> +When disabled the group creation happens as above, and autogroup membership
> +is still visible in /proc, but the autogroups are not used.
>  The CFS scheduler employs an algorithm that equalizes the
>  distribution of CPU cycles across task groups.
>  The benefits of this for interactive desktop performance
> -- 
> 2.47.1
> 
> 

-- 
<https://www.alejandro-colomar.es/>
Re: [PATCH v2] man/man7/sched.7: Mention autogroup disabled behavior
Posted by Phil Auld 10 months, 1 week ago
On Sun, Feb 02, 2025 at 02:02:21PM +0100 Alejandro Colomar wrote:
> Hi Phil,
> 
> On Thu, Jan 16, 2025 at 02:37:47PM +0000, Phil Auld wrote:
> > The autogroup feature can be contolled at runtime when
> > built into the kernel. Disabling it in this case still
> > creates autogroups and still shows the autogroup membership
> > for the task in /proc.  The scheduler code will just not
> > use the the autogroup task group.  This can be confusing
> > to users. Add a sentence to this effect to sched.7 to
> > point this out.
> > 
> > The kernel code shows how this is used. The
> > sched_autogroup_enabled toggle is only used in one place.
> > 
> > kernel/sched/autogroup.h:
> > 
> > static inline struct task_group *
> > autogroup_task_group(struct task_struct *p, struct task_group *tg)
> > {
> >         extern unsigned int sysctl_sched_autogroup_enabled;
> >         int enabled = READ_ONCE(sysctl_sched_autogroup_enabled);
> > 
> >         if (enabled && task_wants_autogroup(p, tg))
> >                 return p->signal->autogroup->tg;
> > 
> >         return tg;
> > }
> > 
> > task_wants_autogroup() is in kernel/sched/autogroup.c:
> > 
> > bool task_wants_autogroup(struct task_struct *p, struct task_group *tg)
> > {
> >         if (tg != &root_task_group)
> >                 return false;
> >     ...
> > 
> >         return true;
> > }
> > 
> > One can see that any group set other than root also bypasses the use of
> > the autogroup.
> > 
> > All of the machinery around the creation of the autogroup is not
> > effected by the toggle.
> > 
> > From userspace:
> > 0
> > /autogroup-112 nice 0
> > 
> > Note, systemd based system these days is not really using autogroups at all
> > anyway because any task in a non-root cgroup bypasses the autogroup as
> > well.
> > 
> > Signed-off-by: Phil Auld <pauld@redhat.com>
> > Cc: Alejandro Colomar <alx@kernel.org>
> > Cc: <linux-man@vger.kernel.org>
> 
> Thanks!  I've applied the patch.
> <https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=ca69daf45f94fda061f796efcc4f24ca76d8e380>
> 
> 
> Have a lovely day!

Thanks!

You too :)


Cheers,
Phil


> Alex
> 
> > ---
> >  man/man7/sched.7 | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/man/man7/sched.7 b/man/man7/sched.7
> > index 71f098e48..f0a708cd7 100644
> > --- a/man/man7/sched.7
> > +++ b/man/man7/sched.7
> > @@ -724,6 +724,8 @@ in the group terminates.
> >  .P
> >  When autogrouping is enabled, all of the members of an autogroup
> >  are placed in the same kernel scheduler "task group".
> > +When disabled the group creation happens as above, and autogroup membership
> > +is still visible in /proc, but the autogroups are not used.
> >  The CFS scheduler employs an algorithm that equalizes the
> >  distribution of CPU cycles across task groups.
> >  The benefits of this for interactive desktop performance
> > -- 
> > 2.47.1
> > 
> > 
> 
> -- 
> <https://www.alejandro-colomar.es/>



--