Check if a cpu is in the cpuset of current task, not guaranteed that
cpu is online.
Signed-off-by: Hao Xu <redacted>
---
include/linux/cpuset.h | 7 +++++++
kernel/cgroup/cpuset.c | 11 +++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 04c20de66afc..fad77c91bc1f 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -116,6 +116,8 @@ static inline int cpuset_do_slab_mem_spread(void)
extern bool current_cpuset_is_being_rebound(void);
+extern bool test_cpu_in_current_cpuset(int cpu);
+
extern void rebuild_sched_domains(void);
extern void cpuset_print_current_mems_allowed(void);
@@ -257,6 +259,11 @@ static inline bool current_cpuset_is_being_rebound(void)
return false;
}
+static inline bool test_cpu_in_current_cpuset(int cpu)
+{
+ return false;
+}
+
static inline void rebuild_sched_domains(void)
{
partition_sched_domains(1, NULL, NULL);diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index adb5190c4429..a63c27e9430e 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1849,6 +1849,17 @@ bool current_cpuset_is_being_rebound(void)
return ret;
}
+bool test_cpu_in_current_cpuset(int cpu)
+{
+ bool ret;
+
+ rcu_read_lock();
+ ret = cpumask_test_cpu(cpu, task_cs(current)->effective_cpus);
+ rcu_read_unlock();
+
+ return ret;
+}
+
static int update_relax_domain_level(struct cpuset *cs, s64 val)
{
#ifdef CONFIG_SMP--
2.24.4