Re: [RFC PATCH 01/23] sched/task_struct: Introduce classes of tasks

From: Ricardo Neri
Date: Fri Sep 16 2022 - 10:35:34 EST


On Wed, Sep 14, 2022 at 03:46:34PM +0200, Peter Zijlstra wrote:
> On Fri, Sep 09, 2022 at 04:11:43PM -0700, Ricardo Neri wrote:
>
> > include/linux/sched.h | 7 +++++++
> > init/Kconfig | 9 +++++++++
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/include/linux/sched.h b/include/linux/sched.h
> > index e7b2f8a5c711..acc33dbaa47c 100644
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -117,6 +117,8 @@ struct task_group;
> > __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \
> > TASK_PARKED)
> >
> > +#define TASK_CLASS_UNCLASSIFIED -1
>
> > +#ifdef CONFIG_SCHED_TASK_CLASSES
> > + /* Class of task that the scheduler uses for task placement decisions */
> > + short class;
> > +#endif

Thanks for your feedback Peter!
>
> You're missing a hunk for init/init_task.c for this non-zero init value.

Ah, yes. I'll add it.
>
> Does we really have to use a signed type and non-zero init value?

At least on Intel processors, class 0 is a valid class. The scheduler needs to
have a notion of unclassified tasks and decide how to handle them, IMO.

Intel processors currently support 8-bit, unsigned classes. I doubt other
architectures will ever support more than 256 classes. Short can handle all the
possible classification values and also the unclassified case.

On the other hand, class 0 could be the default classification unless hardware
classifies differently. 0 would be special and need to be documented clearly.
This would work for Intel processors.

Thanks and BR,
Ricardo