[Devel] [PATCH rh7] Port diff-sched-return-only-virtual-cpus-in-sched_getaffinity

Vladimir Davydov vdavydov at parallels.com
Fri May 29 06:18:45 PDT 2015


And diff-sched-fix-sched_getaffinity-on-unexisting-tasks-inside-VE,
which is a quickfix for the original patch.

Author: Kirill Tkhai
Email: ktkhai at parallels.com
Subject: sched: Return only virtual cpus in sched_getaffinity()
Date: Mon, 28 Apr 2014 12:45:38 +0400

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

v2: Simplification

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().
=============================================================================

Author: Kirill Tkhai
Email: ktkhai at parallels.com
Subject: sched: Fix sched_getaffinity() on unexisting tasks
Date: Wed, 4 Jun 2014 14:33:26 +0400

Move !ve0 block after process search to be able to fail if
there is no process with the given pid inside CT.

https://jira.sw.ru/browse/PSBM-27200

Signed-off-by: Kirill Tkhai <ktkhai at parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
=============================================================================

Related to https://jira.sw.ru/browse/PSBM-33642

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 kernel/sched/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d8831c91bebb..0e8c92152cb9 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4644,6 +4644,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_allowed, cpu_active_mask);
 	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-- 
2.1.4




More information about the Devel mailing list