sched_ext: Fix dsp_local_on selftest on UP systems
Subsystems (2)
Andrea Righi
reviewercover sched_ext: Fix dsp_local_on selftest on UP systems
Introduce a new portable scx helper to check whether a task can migrate and use it in the dsp_local_on selftest, so that it can run also on UP systems.
Andrea Righi (2):
tools/sched_ext: Add helper to check task migration state
sched_ext: selftests/dsp_local_on: Fix selftest on UP systems
tools/sched_ext/include/scx/common.bpf.h | 11 +++++++++++ tools/testing/selftests/sched_ext/dsp_local_on.bpf.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
Andrea Righi
reviewerPATCH 1/2 tools/sched_ext: Add helper to check task migration state
Introduce a new helper for BPF schedulers to determine whether a task can migrate or not (supporting both SMP and UP systems).
--- tools/sched_ext/include/scx/common.bpf.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/sched_ext/include/scx/common.bpf.h +11 -0
@@ -404,6 +404,17 @@ static __always_inline const struct cpumask *cast_mask(struct bpf_cpumask *mask)return (const struct cpumask *)mask; } +/* +* Return true if task @p cannot migrate to a different CPU, false +* otherwise. +*/ +static bool is_migration_disabled (const struct task_struct *p) +{ +if (bpf_core_field_exists (p->migration_disabled)) +return p->migration_disabled; +return false; +} +/* rcu */ void bpf_rcu_read_lock(void) __ksym; void bpf_rcu_read_unlock(void) __ksym;
Signature · 1 line
2.48.1
Andrea Righi
reviewerPATCH v2 1/2 tools/sched_ext: Add helper to check task migration state
Introduce a new helper for BPF schedulers to determine whether a task can migrate or not (supporting both SMP and UP systems).
--- tools/sched_ext/include/scx/common.bpf.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
ChangeLog v1 -> v2:
- add missing inline
tools/sched_ext/include/scx/common.bpf.h +11 -0
@@ -404,6 +404,17 @@ static __always_inline const struct cpumask *cast_mask(struct bpf_cpumask *mask)return (const struct cpumask *)mask; } +/* +* Return true if task @p cannot migrate to a different CPU, false +* otherwise. +*/ +static inline bool is_migration_disabled (const struct task_struct *p) +{ +if (bpf_core_field_exists (p->migration_disabled)) +return p->migration_disabled; +return false; +} +/* rcu */ void bpf_rcu_read_lock(void) __ksym; void bpf_rcu_read_unlock(void) __ksym;
Signature · 1 line
2.48.1
Andrea Righi
reviewerPATCH 2/2 sched_ext: selftests/dsp_local_on: Fix selftest on UP systems
In reply to Andrea RighiIn UP systems p->migration_disabled is not available. Fix this by using the portable helper is_migration_disabled(p).
--- tools/testing/selftests/sched_ext/dsp_local_on.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sched_ext/dsp_local_on.bpf.c +1 -1
@@ -43,7 +43,7 @@ void BPF_STRUCT_OPS(dsp_local_on_dispatch, s32 cpu, struct task_struct *prev)if (!p)return ; -if (p->nr_cpus_allowed == nr_cpus && !p->migration_disabled) +if (p->nr_cpus_allowed == nr_cpus && !is_migration_disabled (p)) target =bpf_get_prandom_u32 () % nr_cpus;else target =scx_bpf_task_cpu (p);
Signature · 1 line
2.48.1
Quoted 6 lines · Andrea Righi
Introduce a new portable scx helper to check whether a task can migrate and use it in the
dsp_local_onselftest, so that it can run also on UP systems.Andrea Righi (2):
tools/sched_ext: Add helper to check task migration state
sched_ext: selftests/dsp_local_on: Fix selftest on UP systems
Ah, you already did.
Applied to sched_ext/for-6.14-fixes.
Thanks.
Signature · 1 line
tejun