[Devel] [PATCH RH9 12/12] sched: Return only virtual cpus in sched_getaffinity()
Alexander Mikhalitsyn
alexander.mikhalitsyn at virtuozzo.com
Thu Sep 23 14:31:36 MSK 2021
From: Kirill Tkhai <ktkhai at virtuozzo.com>
Fill mask using virtual cpus which are enumerated
from 0 to num_online_vcpus()-1.
Just in pair to /proc/cpuinfo and sched_setaffinity().
https://jira.sw.ru/browse/PSBM-25367
Signed-off-by: Kirill Tkhai <ktkhai at parallels.com>
Acked-by: Vladimir Davydov <vdavydov at parallels.com>
An addition by khorenko@:
"nproc" utility works via sched_getaffinity().
Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
https://jira.sw.ru/browse/PSBM-133986
(cherry picked from commit 83352c7f8f4b98fd4dbf5f0de00681b6cdc11d7c)
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
---
kernel/sched/core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 064482744ac7..291f293fb00a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7848,6 +7848,12 @@ long sched_getaffinity(pid_t pid, struct cpumask *mask)
if (retval)
goto out_unlock;
+ if (!ve_is_super(get_exec_env())) {
+ cpumask_clear(mask);
+ bitmap_fill(cpumask_bits(mask), num_online_vcpus());
+ goto out_unlock;
+ }
+
raw_spin_lock_irqsave(&p->pi_lock, flags);
cpumask_and(mask, &p->cpus_mask, cpu_active_mask);
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
--
2.31.1
More information about the Devel
mailing list