]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sched: Add normal_policy()
authorTejun Heo <tj@kernel.org>
Tue, 18 Jun 2024 20:09:17 +0000 (10:09 -1000)
committerTejun Heo <tj@kernel.org>
Tue, 18 Jun 2024 20:09:17 +0000 (10:09 -1000)
A new BPF extensible sched_class will need to dynamically change how a task
picks its sched_class. For example, if the loaded BPF scheduler progs fail,
the tasks will be forced back on CFS even if the task's policy is set to the
new sched_class. To support such mapping, add normal_policy() which wraps
testing for %SCHED_NORMAL. This doesn't cause any behavior changes.

v2: Update the description with more details on the expected use.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: David Vernet <dvernet@meta.com>
Acked-by: Josh Don <joshdon@google.com>
Acked-by: Hao Luo <haoluo@google.com>
Acked-by: Barret Rhoden <brho@google.com>
kernel/sched/fair.c
kernel/sched/sched.h

index 715d7c1f55df3f0ac60ac50b63c07ae9845a6b65..d5953741686533d9a3a9cca77827f1627ba40084 100644 (file)
@@ -8391,7 +8391,7 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
         * Batch and idle tasks do not preempt non-idle tasks (their preemption
         * is driven by the tick):
         */
-       if (unlikely(p->policy != SCHED_NORMAL) || !sched_feat(WAKEUP_PREEMPTION))
+       if (unlikely(!normal_policy(p->policy)) || !sched_feat(WAKEUP_PREEMPTION))
                return;
 
        find_matching_se(&se, &pse);
index a5a4f59151db42d8197217d06d519f093fd1114e..25660dc9f639d1e67de5802b5266705e952b0812 100644 (file)
@@ -192,9 +192,14 @@ static inline int idle_policy(int policy)
        return policy == SCHED_IDLE;
 }
 
+static inline int normal_policy(int policy)
+{
+       return policy == SCHED_NORMAL;
+}
+
 static inline int fair_policy(int policy)
 {
-       return policy == SCHED_NORMAL || policy == SCHED_BATCH;
+       return normal_policy(policy) || policy == SCHED_BATCH;
 }
 
 static inline int rt_policy(int policy)