
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICA1GK -------------------------------- Add a helper to get all the CPUs that a task can run onto. Signed-off-by: GONG Ruiqi <gongruiqi1@huawei.com> --- include/linux/cpuset.h | 11 +++++++++++ kernel/cgroup/cpuset.c | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 64d602e7219f..407178c86b1e 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -75,6 +75,9 @@ extern void dec_dl_tasks_cs(struct task_struct *task); extern void cpuset_lock(void); extern void cpuset_unlock(void); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask); +#ifdef CONFIG_BPF_RVI +extern void task_effective_cpumask(struct task_struct *p, struct cpumask *mask); +#endif extern bool cpuset_cpus_allowed_fallback(struct task_struct *p); extern nodemask_t cpuset_mems_allowed(struct task_struct *p); #define cpuset_current_mems_allowed (current->mems_allowed) @@ -199,6 +202,14 @@ static inline void cpuset_cpus_allowed(struct task_struct *p, cpumask_copy(mask, task_cpu_possible_mask(p)); } +#ifdef CONFIG_BPF_RVI +static inline void task_effective_cpumask(struct task_struct *p, + struct cpumask *mask) +{ + cpuset_cpus_allowed(p, mask); +} +#endif + static inline bool cpuset_cpus_allowed_fallback(struct task_struct *p) { return false; diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 992433114ed2..1c587e5e34c1 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -5208,6 +5208,19 @@ void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task) } #ifdef CONFIG_BPF_RVI +void task_effective_cpumask(struct task_struct *tsk, struct cpumask *pmask) +{ + struct cpuset *cs; + + if (!tsk) + cpumask_clear(pmask); + + rcu_read_lock(); + cs = task_cs(tsk); + cpumask_copy(pmask, cs->effective_cpus); + rcu_read_unlock(); +} + __bpf_kfunc struct cpuset *bpf_cpuset_from_task(struct task_struct *task) { if (!task) -- 2.25.1