Skip to content

Commit b903363

Browse files
arighigregkh
authored andcommitted
tools/sched_ext: Add helper to check task migration state
commit 5f52bbf upstream. 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 <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f52913f commit b903363

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
@@ -333,6 +333,17 @@ static __always_inline const struct cpumask *cast_mask(struct bpf_cpumask *mask)
333333
return (const struct cpumask *)mask;
334334
}
335335

336+
/*
337+
* Return true if task @p cannot migrate to a different CPU, false
338+
* otherwise.
339+
*/
340+
static inline bool is_migration_disabled(const struct task_struct *p)
341+
{
342+
if (bpf_core_field_exists(p->migration_disabled))
343+
return p->migration_disabled;
344+
return false;
345+
}
346+
336347
/* rcu */
337348
void bpf_rcu_read_lock(void) __ksym;
338349
void bpf_rcu_read_unlock(void) __ksym;

0 commit comments

Comments
 (0)