sched_ext: Standardize preprocessor comment markers
cover sched_ext: Standardize preprocessor comment markers
This series standardizes #if/#else/#endif comment markers in the sched/ext*.{c,h} files for consistency and readability.
It follows the direction of Ingo Molnar's recent cleanup
("[PATCH 00/43] sched: Use the SMP scheduler on UP too"), which reduced CONFIG_SMP complexity and removed many #ifdef blocks across the scheduler.
No functional change.
Thanks.
-chengyang
---
Cheng-Yang Chou (4):
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext.c
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext.h
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext_idle.c
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext_idle.h
kernel/sched/ext.c | 26 +------------------------- kernel/sched/ext.h | 2 +- kernel/sched/ext_idle.c | 25 +------------------------ kernel/sched/ext_idle.h | 10 ---------- 4 files changed, 3 insertions(+), 60 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 sched_ext: Clean up and standardize #if/#else/#endif markers in sched/ext.c
Simplify the scheduler by making formerly SMP-only primitives and data structures unconditional.
--- kernel/sched/ext.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-)
kernel/sched/ext.c +1 -25
@@ -1792,12 +1792,10 @@ static void run_deferred(struct rq *rq)process_ddsp_deferred_locals (rq); } -#ifdef CONFIG_SMP static void deferred_bal_cb_workfn (struct rq *rq) {run_deferred (rq); } -#endif static void deferred_irq_workfn (struct irq_work *irq_work) {
@@ -1820,7 +1818,6 @@ static void schedule_deferred(struct rq *rq) {lockdep_assert_rq_held (rq); -#ifdef CONFIG_SMP /* * If in the middle of waking up a task, task_woken_scx() will be called * afterwards which will then run the deferred actions, no need to
@@ -1838,7 +1835,7 @@ static void schedule_deferred(struct rq *rq) deferred_bal_cb_workfn);return ; } -#endif +/* * No scheduler hooks available. Queue an irq work. They are executed on * IRQ re-enable which may take a bit longer than the scheduler hooks.
@@ -2542,7 +2539,6 @@ static void move_local_task_to_local_dsq(struct task_struct *p, u64 enq_flags, p->scx.dsq = dst_dsq; } -#ifdef CONFIG_SMP /** * move_remote_task_to_local_dsq - Move a task from a foreign rq to a local DSQ * @p: task to move
@@ -2709,11 +2705,6 @@ static bool consume_remote_task(struct rq *this_rq, struct task_struct *p,return false; } } -#else /* CONFIG_SMP */ -static inline void move_remote_task_to_local_dsq (struct task_struct *p,u64 enq_flags,struct rq *src_rq,struct rq *dst_rq) {WARN_ON_ONCE (1 ); } -static inline bool task_can_run_on_remote_rq (struct scx_sched *sch,struct task_struct *p,struct rq *rq,bool enforce) {return false; } -static inline bool consume_remote_task (struct rq *this_rq,struct task_struct *p,struct scx_dispatch_q *dsq,struct rq *task_rq) {return false; } -#endif /* CONFIG_SMP */ /** * move_task_between_dsqs() - Move a task from one DSQ to another
@@ -2886,9 +2877,7 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq, {struct rq *src_rq =task_rq (p); struct rq *dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq); -#ifdef CONFIG_SMP struct rq *locked_rq = rq; -#endif /* * We're synchronized against dequeue through DISPATCHING. As @p can't
@@ -2902,7 +2891,6 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,return ; } -#ifdef CONFIG_SMP if (src_rq != dst_rq &&unlikely (!task_can_run_on_remote_rq (sch, p, dst_rq, true))) { dispatch_enqueue(sch, find_global_dsq(p), p,
@@ -2962,9 +2950,6 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,raw_spin_rq_unlock (locked_rq);raw_spin_rq_lock (rq); } -#else /* CONFIG_SMP */ -BUG ();/* control can not reach here on UP */ -#endif /* CONFIG_SMP */ }/**
@@ -3288,10 +3273,8 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, bool first)static enum scx_cpu_preempt_reason preempt_reason_from_class (const struct sched_class *class) { -#ifdef CONFIG_SMP if (class == &stop_sched_class)return SCX_CPU_PREEMPT_STOP ; -#endif if (class == &dl_sched_class)return SCX_CPU_PREEMPT_DL ;if (class == &rt_sched_class)
@@ -3304,14 +3287,12 @@ static void switch_class(struct rq *rq, struct task_struct *next)struct scx_sched *sch = scx_root;const struct sched_class *next_class = next->sched_class; -#ifdef CONFIG_SMP /* * Pairs with the smp_load_acquire() issued by a CPU in * kick_cpus_irq_workfn() who is waiting for this CPU to perform a * resched. */ smp_store_release (&rq->scx.pnt_seq, rq->scx.pnt_seq +1 ); -#endif if (!(sch->ops.flags &SCX_OPS_HAS_CPU_PREEMPT ))return ;
@@ -3508,8 +3489,6 @@ bool scx_prio_less(const struct task_struct *a, const struct task_struct *b, }#endif /* CONFIG_SCHED_CORE */ -#ifdef CONFIG_SMP -static int select_task_rq_scx (struct task_struct *p,int prev_cpu,int wake_flags) {struct scx_sched *sch = scx_root;
@@ -3639,7 +3618,6 @@ static void rq_offline_scx(struct rq *rq) rq->scx.flags &= ~SCX_RQ_ONLINE ; } -#endif /* CONFIG_SMP */ static bool check_rq_for_timeouts (struct rq *rq) {
@@ -4299,14 +4277,12 @@ DEFINE_SCHED_CLASS(ext) = { .put_prev_task = put_prev_task_scx, .set_next_task = set_next_task_scx, -#ifdef CONFIG_SMP .select_task_rq = select_task_rq_scx, .task_woken = task_woken_scx, .set_cpus_allowed = set_cpus_allowed_scx, .rq_online = rq_online_scx, .rq_offline = rq_offline_scx, -#endif .task_tick = task_tick_scx,
Signature · 1 line
2.43.0
PATCH 2/4 sched_ext: Clean up and standardize #if/#else/#endif markers in sched/ext.h
In reply to Cheng-Yang ChouSimplify the scheduler by making formerly SMP-only primitives and data structures unconditional.
--- kernel/sched/ext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/ext.h +1 -1
@@ -65,7 +65,7 @@ static inline void init_sched_ext_class(void) {}#endif /* CONFIG_SCHED_CLASS_EXT */ -#if defined(CONFIG_SCHED_CLASS_EXT ) && defined(CONFIG_SMP ) +#if defined(CONFIG_SCHED_CLASS_EXT )void __scx_update_idle (struct rq *rq,bool idle,bool do_notify);static inline void scx_update_idle (struct rq *rq,bool idle,bool do_notify)
Signature · 1 line
2.43.0
PATCH 3/4 sched_ext: Clean up and standardize #if/#else/#endif markers in sched/ext_idle.c
In reply to Cheng-Yang ChouSimplify the scheduler by making formerly SMP-only primitives and data structures unconditional.
--- kernel/sched/ext_idle.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
kernel/sched/ext_idle.c +1 -24
@@ -17,7 +17,6 @@ static DEFINE_STATIC_KEY_FALSE(scx_builtin_idle_enabled);/* Enable/disable per-node idle cpumasks */ static DEFINE_STATIC_KEY_FALSE (scx_builtin_idle_per_node); -#ifdef CONFIG_SMP /* Enable/disable LLC aware optimizations */ static DEFINE_STATIC_KEY_FALSE (scx_selcpu_topo_llc);
@@ -794,7 +793,6 @@ static void reset_idle_masks(struct sched_ext_ops *ops)cpumask_and (idle_cpumask (node)->smt, cpu_online_mask, node_mask); } } -#endif /* CONFIG_SMP */ void scx_idle_enable (struct sched_ext_ops *ops) {
@@ -808,9 +806,7 @@ void scx_idle_enable(struct sched_ext_ops *ops)else static_branch_disable_cpuslocked (&scx_builtin_idle_per_node); -#ifdef CONFIG_SMP reset_idle_masks (ops); -#endif }void scx_idle_disable (void )
@@ -896,7 +892,6 @@ s32 select_cpu_from_kfunc(struct task_struct *p, s32 prev_cpu, u64 wake_flags,if (!rq)lockdep_assert_held (&p->pi_lock); -#ifdef CONFIG_SMP /* * This may also be called from ops.enqueue(), so we need to handle * per-CPU tasks as well. For these tasks, we can skip all idle CPU
@@ -913,9 +908,7 @@ s32 select_cpu_from_kfunc(struct task_struct *p, s32 prev_cpu, u64 wake_flags, cpu =scx_select_cpu_dfl (p, prev_cpu, wake_flags, allowed ?: p->cpus_ptr, flags); } -#else - cpu = -EBUSY ; -#endif +if (scx_kf_allowed_if_unlocked ())task_rq_unlock (rq, p, &rf);
@@ -1010,11 +1003,7 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask_node(int node)if (node <0 )return cpu_none_mask; -#ifdef CONFIG_SMP return idle_cpumask (node)->cpu; -#else -return cpu_none_mask; -#endif }/**
@@ -1034,11 +1023,7 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask(void)if (!check_builtin_idle_enabled ())return cpu_none_mask; -#ifdef CONFIG_SMP return idle_cpumask (NUMA_NO_NODE )->cpu; -#else -return cpu_none_mask; -#endif }/**
@@ -1057,14 +1042,10 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_smtmask_node(int node)if (node <0 )return cpu_none_mask; -#ifdef CONFIG_SMP if (sched_smt_active ())return idle_cpumask (node)->smt;else return idle_cpumask (node)->cpu; -#else -return cpu_none_mask; -#endif }/**
@@ -1085,14 +1066,10 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_smtmask(void)if (!check_builtin_idle_enabled ())return cpu_none_mask; -#ifdef CONFIG_SMP if (sched_smt_active ())return idle_cpumask (NUMA_NO_NODE )->smt;else return idle_cpumask (NUMA_NO_NODE )->cpu; -#else -return cpu_none_mask; -#endif }/**
Signature · 1 line
2.43.0
Re: [PATCH 3/4] sched_ext: Clean up and standardize #if/#else/#endif markers in sched/ext_idle.c
The following is the updated version that got applied to sched_ext/for-6.17.
Thanks.
------ 8< ------
From 8834ace4a86db0a85cb003c2efd98e6a4389243c Mon Sep 17 00:00:00 2001
From: Cheng-Yang Chou <[email protected]>
Date: Wed, 11 Jun 2025 21:54:03 +0800
Subject: [PATCH] sched_ext: Always use SMP versions in kernel/sched/ext_idle.c
Simplify the scheduler by making formerly SMP-only primitives and data structures unconditional.
tj: Updated subject for clarity. Fixed stray #else block which wasn't
removed causing build failure.
--- kernel/sched/ext_idle.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-)
kernel/sched/ext_idle.c +1 -34
@@ -17,7 +17,6 @@ static DEFINE_STATIC_KEY_FALSE(scx_builtin_idle_enabled);/* Enable/disable per-node idle cpumasks */ static DEFINE_STATIC_KEY_FALSE (scx_builtin_idle_per_node); -#ifdef CONFIG_SMP /* Enable/disable LLC aware optimizations */ static DEFINE_STATIC_KEY_FALSE (scx_selcpu_topo_llc);
@@ -794,17 +793,6 @@ static void reset_idle_masks(struct sched_ext_ops *ops)cpumask_and (idle_cpumask (node)->smt, cpu_online_mask, node_mask); } } -#else /* !CONFIG_SMP */ -static bool scx_idle_test_and_clear_cpu (int cpu) -{ -return -EBUSY ; -} - -static s32 scx_pick_idle_cpu (const struct cpumask *cpus_allowed,int node,u64 flags) -{ -return -EBUSY ; -} -#endif /* CONFIG_SMP */ void scx_idle_enable (struct sched_ext_ops *ops) {
@@ -818,9 +806,7 @@ void scx_idle_enable(struct sched_ext_ops *ops)else static_branch_disable_cpuslocked (&scx_builtin_idle_per_node); -#ifdef CONFIG_SMP reset_idle_masks (ops); -#endif }void scx_idle_disable (void )
@@ -906,7 +892,6 @@ static s32 select_cpu_from_kfunc(struct task_struct *p, s32 prev_cpu, u64 wake_fif (!rq)lockdep_assert_held (&p->pi_lock); -#ifdef CONFIG_SMP /* * This may also be called from ops.enqueue(), so we need to handle * per-CPU tasks as well. For these tasks, we can skip all idle CPU
@@ -923,9 +908,7 @@ static s32 select_cpu_from_kfunc(struct task_struct *p, s32 prev_cpu, u64 wake_f cpu =scx_select_cpu_dfl (p, prev_cpu, wake_flags, allowed ?: p->cpus_ptr, flags); } -#else - cpu = -EBUSY ; -#endif +if (scx_kf_allowed_if_unlocked ())task_rq_unlock (rq, p, &rf);
@@ -1016,11 +999,7 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask_node(int node)if (node <0 )return cpu_none_mask; -#ifdef CONFIG_SMP return idle_cpumask (node)->cpu; -#else -return cpu_none_mask; -#endif }/**
@@ -1040,11 +1019,7 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_cpumask(void)if (!check_builtin_idle_enabled ())return cpu_none_mask; -#ifdef CONFIG_SMP return idle_cpumask (NUMA_NO_NODE )->cpu; -#else -return cpu_none_mask; -#endif }/**
@@ -1063,14 +1038,10 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_smtmask_node(int node)if (node <0 )return cpu_none_mask; -#ifdef CONFIG_SMP if (sched_smt_active ())return idle_cpumask (node)->smt;else return idle_cpumask (node)->cpu; -#else -return cpu_none_mask; -#endif }/**
@@ -1091,14 +1062,10 @@ __bpf_kfunc const struct cpumask *scx_bpf_get_idle_smtmask(void)if (!check_builtin_idle_enabled ())return cpu_none_mask; -#ifdef CONFIG_SMP if (sched_smt_active ())return idle_cpumask (NUMA_NO_NODE )->smt;else return idle_cpumask (NUMA_NO_NODE )->cpu; -#else -return cpu_none_mask; -#endif }/**
Signature · 1 line
2.49.0
PATCH 4/4 sched_ext: Clean up and standardize #if/#else/#endif markers in sched/ext_idle.h
In reply to Cheng-Yang ChouSimplify the scheduler by making formerly SMP-only primitives and data structures unconditional.
--- kernel/sched/ext_idle.h | 10 ---------- 1 file changed, 10 deletions(-)
kernel/sched/ext_idle.h +0 -10
@@ -12,20 +12,10 @@struct sched_ext_ops ; -#ifdef CONFIG_SMP void scx_idle_update_selcpu_topology (struct sched_ext_ops *ops);void scx_idle_init_masks (void );bool scx_idle_test_and_clear_cpu (int cpu);s32 scx_pick_idle_cpu (const struct cpumask *cpus_allowed,int node,u64 flags); -#else /* !CONFIG_SMP */ -static inline void scx_idle_update_selcpu_topology (struct sched_ext_ops *ops) {} -static inline void scx_idle_init_masks (void ) {} -static inline bool scx_idle_test_and_clear_cpu (int cpu) {return false; } -static inline s32 scx_pick_idle_cpu (const struct cpumask *cpus_allowed,int node,u64 flags) -{ -return -EBUSY ; -} -#endif /* CONFIG_SMP */ s32 scx_select_cpu_dfl (struct task_struct *p,s32 prev_cpu,u64 wake_flags,const struct cpumask *cpus_allowed,u64 flags);
Signature · 1 line
2.43.0
Quoted 9 lines · Cheng-Yang Chou
Cheng-Yang Chou (4):
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext.c
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext.h
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext_idle.c
sched_ext: Clean up and standardize #if/#else/#endif markers in
sched/ext_idle.h
Applied with subject line update. Patch 3 left a stray #else block causing a build failure. Will post the updated patch as a reply to the patch. For this sort of changes, please at least do build testing.
Thanks.
Signature · 1 line
tejun
Quoted 3 lines · Tejun Heo
Applied with subject line update. Patch 3 left a stray #else block causing a build failure. Will post the updated patch as a reply to the patch. For this sort of changes, please at least do build testing.
Thanks for pointing that out and for fixing it.
-chengyang