Messages in this thread Patch in this message | | | From | JaeJoon Jung <> | Date | Wed, 21 Sep 2022 17:12:20 +0900 | Subject | [core-scheduling] Modify prio_less() with in CONFIG_SCHED_CORE on v5.19.x |
| |
Hello, Since the priority of sched_class can be determined by pointer operation, the prio_less() function can be modified as follows. With this fix, the __task_prio() function is not needed. Please review.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ee28253c9ac0..24b86773da04 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -154,21 +154,6 @@ __read_mostly int scheduler_running;
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) @@ -179,22 +164,18 @@ static inline int __task_prio(struct task_struct *p) /* real prio, less is less */ static inline bool prio_less(struct task_struct *a, struct task_struct *b, bool in_fi) { - - int pa = __task_prio(a), pb = __task_prio(b); - - if (-pa < -pb) - return true; - - if (-pb < -pa) - return false; - - if (pa == -1) /* dl_prio() doesn't work because of stop_class above */ - return !dl_time_before(a->dl.deadline, b->dl.deadline); - - if (pa == MAX_RT_PRIO + MAX_NICE) /* fair */ - return cfs_prio_less(a, b, in_fi); - - return false; + int less = a->sched_class - b->sched_class; + + if (less) { + return (less > 0) ? true : false; + } else { + if (a->sched_class == &fair_sched_class) + return cfs_prio_less(a, b, in_fi); + else if (a->sched_class == &dl_sched_class) + return !dl_time_before(a->dl.deadline, b->dl.deadline); + else + return (a->prio - b->prio > 0) ? true : false; + } }
Thanks, JaeJoon Jung.
| |