On Wed, May 29, 2019 at 08:36:47PM +0000, Vineeth Remanan Pillai wrote: > From: Peter Zijlstra <pet...@infradead.org> > > Introduce task_struct::core_cookie as an opaque identifier for core > scheduling. When enabled; core scheduling will only allow matching > task to be on the core; where idle matches everything. > > When task_struct::core_cookie is set (and core scheduling is enabled) > these tasks are indexed in a second RB-tree, first on cookie value > then on scheduling function, such that matching task selection always > finds the most elegible match. > > NOTE: *shudder* at the overhead... > > NOTE: *sigh*, a 3rd copy of the scheduling function; the alternative > is per class tracking of cookies and that just duplicates a lot of > stuff for no raisin (the 2nd copy lives in the rt-mutex PI code). s/raisen/reason
> > Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org> > Signed-off-by: Vineeth Remanan Pillai <vpil...@digitalocean.com> > Signed-off-by: Julien Desfossez <jdesfos...@digitalocean.com> > --- > > Changes in v3 > ------------- > - Refactored priority comparison code > - Fixed a comparison logic issue in sched_core_find > - Aaron Lu > > Changes in v2 > ------------- > - Improves the priority comparison logic between processes in > different cpus. > - Peter Zijlstra > - Aaron Lu > > --- > include/linux/sched.h | 8 ++- > kernel/sched/core.c | 146 ++++++++++++++++++++++++++++++++++++++++++ > kernel/sched/fair.c | 46 ------------- > kernel/sched/sched.h | 55 ++++++++++++++++ > 4 files changed, 208 insertions(+), 47 deletions(-) > > diff --git a/include/linux/sched.h b/include/linux/sched.h > index 1549584a1538..a4b39a28236f 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -636,10 +636,16 @@ struct task_struct { > const struct sched_class *sched_class; > struct sched_entity se; > struct sched_rt_entity rt; > + struct sched_dl_entity dl; > + > +#ifdef CONFIG_SCHED_CORE > + struct rb_node core_node; > + unsigned long core_cookie; > +#endif > + > #ifdef CONFIG_CGROUP_SCHED > struct task_group *sched_task_group; > #endif > - struct sched_dl_entity dl; > > #ifdef CONFIG_PREEMPT_NOTIFIERS > /* List of struct preempt_notifier: */ > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index b1ce33f9b106..112d70f2b1e5 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -64,6 +64,141 @@ int sysctl_sched_rt_runtime = 950000; > > DEFINE_STATIC_KEY_FALSE(__sched_core_enabled); > > +/* kernel prio, less is more */ > +static inline int __task_prio(struct task_struct *p) > +{ > + if (p->sched_class == &stop_sched_class) /* trumps deadline */ > + return -2; > + > + if (rt_prio(p->prio)) /* includes deadline */ > + return p->prio; /* [-1, 99] */ > + > + if (p->sched_class == &idle_sched_class) > + return MAX_RT_PRIO + NICE_WIDTH; /* 140 */ > + > + return MAX_RT_PRIO + MAX_NICE; /* 120, squash fair */ > +} > + > +/* > + * l(a,b) > + * le(a,b) := !l(b,a) > + * g(a,b) := l(b,a) > + * ge(a,b) := !l(a,b) why does this truth table comment exist? maybe inline comments at the confusing inequalities would be better. --mark