Re: [RFC PATCH v1] sched/uclamp: Introduce SCHED_FLAG_RESET_UCLAMP_ON_FORK flag

From: Saravana Kannan
Date: Fri Apr 28 2023 - 14:13:20 EST


On Fri, Apr 28, 2023 at 4:57 AM Qais Yousef <qyousef@xxxxxxxxxxx> wrote:
>
> On 04/19/23 18:54, Qais Yousef wrote:
>
> [...]
>
> > I was considering to have something a bit more generic that allows selecting
> > which attributes to reset.
> >
> > For example a syscall with SCHED_FLAG_RESET_ON_FORK_SEL combined with
> > SCHED_FLAG_UCLAMP_MIN/MAX will only reset those. This should make it extensible
> > if we have other similar use cases in the future. The downside it *might*
> > require to be done in a separate syscall to the one that sets these parameter.
> > But it should be done once.
> >
> > Maybe there's a better interface, but I think it makes sense to do it in a way
> > that we won't have to do this again. Would be good to hear from maintainers
> > first before you take my word for it ;-)
>
> Actually I think we can do a better and simpler generic interface. We don't
> need a new flag. We can just add a new parameter for what to reset on fork.
> When this value is 0 (which it should be by default), it means reset
> everything.

Isn't he default NOT to reset everything?

> // pseudo code
>
> #define RESET_ON_FORK_ALL 0
> #define RESET_ON_FORK_POLICY BIT(1) // implies resetting priority
> #define RESET_ON_FORK_PRIORITY BIT(2)
> #define RESET_ON_FORK_UCLAMP BIT(3)
>
> struct sched_attr {
> ...
> __u64 sched_reset_on_fork_flags;
> };
>

Also, honestly I think this is over designing for a hypothetical. We
have approximately 53 unused bits. By the time we run out of those,
we'd have added at least 20-50 more fields. At that point, we can
always add a flags2 field if we need it. I like David's patch as is --
it's clear and simple. Add a flag for explicitly what we are trying to
do and extend as needed.

-Saravana