[Devel] [PATCH RHEL7 COMMIT] sched: Port diff-sched-return-only-virtual-cpus-in-sched_getaffinity

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 4 04:53:38 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.9
------>
commit 3692c1382d83441dcfba46e3b3e677fc7af736ae
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Thu Jun 4 15:53:38 2015 +0400

    sched: Port diff-sched-return-only-virtual-cpus-in-sched_getaffinity
    
    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 d8831c9..0e8c921 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);



More information about the Devel mailing list