Skip to content

Commit 5f52bbf

Browse files
arighihtejun
authored andcommitted
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). Fixes: e9fe182 ("sched_ext: selftests/dsp_local_on: Fix sporadic failures") Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent d6f3e7d commit 5f52bbf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/sched_ext/include/scx/common.bpf.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@ static __always_inline const struct cpumask *cast_mask(struct bpf_cpumask *mask)
404404
return (const struct cpumask *)mask;
405405
}
406406

407+
/*
408+
* Return true if task @p cannot migrate to a different CPU, false
409+
* otherwise.
410+
*/
411+
static inline bool is_migration_disabled(const struct task_struct *p)
412+
{
413+
if (bpf_core_field_exists(p->migration_disabled))
414+
return p->migration_disabled;
415+
return false;
416+
}
417+
407418
/* rcu */
408419
void bpf_rcu_read_lock(void) __ksym;
409420
void bpf_rcu_read_unlock(void) __ksym;

0 commit comments

Comments
 (0)