[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] xen: don't let XEN_DOMCTL_setvcpuaffinity return the new affinities



There is no in-tree user of XEN_DOMCTL_setvcpuaffinity left relying on
the returned effective affinity settings.

Drop returning the new affinities, as any error occurring for that
will be reported to the user, while the affinities won't be changed
back to what they were. This would result in the caller believing
that the affinity was not modified, while it might have been.

Fix a comment typo while modifying vcpu_affinity_domctl().

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/common/sched/core.c     | 40 +++++++++----------------------------
 xen/include/public/domctl.h |  9 ++-------
 2 files changed, 11 insertions(+), 38 deletions(-)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 3609721426..1611e60020 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1708,7 +1708,7 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
 {
     struct vcpu *v;
     const struct sched_unit *unit;
-    int ret = 0, hret = 0;
+    int ret = 0;
 
     if ( vcpuaff->vcpu >= d->max_vcpus )
         return -EINVAL;
@@ -1724,12 +1724,11 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
     if ( cmd == XEN_DOMCTL_setvcpuaffinity )
     {
         cpumask_var_t new_affinity, old_affinity;
-        cpumask_t *online = cpupool_domain_master_cpumask(v->domain);
 
         /*
          * We want to be able to restore hard affinity if we are trying
          * setting both and changing soft affinity (which happens later,
-         * when hard affinity has been succesfully chaged already) fails.
+         * when hard affinity has been successfully changed already) fails.
          */
         if ( !alloc_cpumask_var(&old_affinity) )
             return -ENOMEM;
@@ -1746,25 +1745,14 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_FORCE )
             vcpu_temporary_affinity(v, NR_CPUS, VCPU_AFFINITY_OVERRIDE);
 
-        /*
-         * We both set a new affinity and report back to the caller what
-         * the scheduler will be effectively using.
-         */
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_HARD )
         {
-            hret = xenctl_bitmap_to_bitmap(cpumask_bits(new_affinity),
+            ret = xenctl_bitmap_to_bitmap(cpumask_bits(new_affinity),
                                            &vcpuaff->cpumap_hard, nr_cpu_ids);
-            if ( !hret )
-                hret = vcpu_set_hard_affinity(v, new_affinity);
-            if ( hret )
+            if ( !ret )
+                ret = vcpu_set_hard_affinity(v, new_affinity);
+            if ( ret )
                 goto setvcpuaffinity_out;
-
-            /*
-             * For hard affinity, what we return is the intersection of
-             * cpupool's online mask and the new hard affinity.
-             */
-            cpumask_and(new_affinity, online, unit->cpu_hard_affinity);
-            hret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, 
new_affinity);
         }
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_SOFT )
         {
@@ -1782,17 +1770,7 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
                  */
                 if ( vcpuaff->flags & XEN_VCPUAFFINITY_HARD )
                     vcpu_set_hard_affinity(v, old_affinity);
-                goto setvcpuaffinity_out;
             }
-
-            /*
-             * For soft affinity, we return the intersection between the
-             * new soft affinity, the cpupool's online map and the (new)
-             * hard affinity.
-             */
-            cpumask_and(new_affinity, new_affinity, online);
-            cpumask_and(new_affinity, new_affinity, unit->cpu_hard_affinity);
-            ret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft, 
new_affinity);
         }
 
  setvcpuaffinity_out:
@@ -1802,14 +1780,14 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
     else
     {
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_HARD )
-            hret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard,
+            ret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard,
                                             unit->cpu_hard_affinity);
-        if ( vcpuaff->flags & XEN_VCPUAFFINITY_SOFT )
+        if ( !ret && vcpuaff->flags & XEN_VCPUAFFINITY_SOFT )
             ret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft,
                                            unit->cpu_soft_affinity);
     }
 
-    return hret ?: ret;
+    return ret;
 }
 
 bool alloc_affinity_masks(struct affinity_masks *affinity)
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index cdf350a290..906d2c59d0 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -357,13 +357,8 @@ struct xen_domctl_vcpuaffinity {
     /*
      * IN/OUT variables.
      *
-     * Both are IN/OUT for XEN_DOMCTL_setvcpuaffinity, in which case they
-     * contain effective hard or/and soft affinity. That is, upon successful
-     * return, cpumap_soft, contains the intersection of the soft affinity,
-     * hard affinity and the cpupool's online CPUs for the domain (if
-     * XEN_VCPUAFFINITY_SOFT was set in flags). cpumap_hard contains the
-     * intersection between hard affinity and the cpupool's online CPUs (if
-     * XEN_VCPUAFFINITY_HARD was set in flags).
+     * Both are IN-only for XEN_DOMCTL_setvcpuaffinity, in which case they
+     * contain effective hard or/and soft affinity.
      *
      * Both are OUT-only for XEN_DOMCTL_getvcpuaffinity, in which case they
      * contain the plain hard and/or soft affinity masks that were set during
-- 
2.54.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.