diff options
author | Andrea Righi <arighi@nvidia.com> | 2025-01-25 18:14:12 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-22 12:54:28 -0700 |
commit | ee06d5c81041ead5269a3c17595211d3e7c10183 (patch) | |
tree | 831e2800b8a853bbab7dc78783dd049a982cbf12 | |
parent | 46db29a2c8b1bbc55f01e5c8b801ae5b4ead4c6a (diff) |
tools/sched_ext: Add helper to check task migration state
commit 5f52bbf2f6e0997394cf9c449d44e1c80ff4282c upstream.
Introduce a new helper for BPF schedulers to determine whether a task
can migrate or not (supporting both SMP and UP systems).
Fixes: e9fe182772dc ("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>
-rw-r--r-- | tools/sched_ext/include/scx/common.bpf.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h index f7206374a73d..75d6d61279d6 100644 --- a/tools/sched_ext/include/scx/common.bpf.h +++ b/tools/sched_ext/include/scx/common.bpf.h @@ -333,6 +333,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; |