All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-4.22?] domctl: correct return value of XEN_DOMCTL_[gs]etvcpuaffinity
@ 2026-06-15 12:00 Jan Beulich
  2026-06-16 17:12 ` Roger Pau Monné
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2026-06-15 12:00 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Dario Faggioli, Juergen Gross, George Dunlap, Oleksii Kurochko

cpumask_to_xenctl_bitmap() may return errors. Clearing the error indicator
of an earlier such call by a (successful) later call is misleading the
caller. For "set", keep setting soft affinity if the hard affinity copy-
back fails; only accumulate respective errors.

While fiddling with return values, also drop a redundant clearing of
"ret". This eliminates a Misra C:2012 rule 2.2 ("There shall be no dead
code") violation.

Fixes: 6e4ecc6d5884 ("sched: DOMCTL_*vcpuaffinity works with hard and soft affinity")
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1705,6 +1705,7 @@ int vcpu_affinity_domctl(struct domain *
     {
         cpumask_var_t new_affinity, old_affinity;
         cpumask_t *online = cpupool_domain_master_cpumask(v->domain);
+        int hret = 0;
 
         /*
          * We want to be able to restore hard affinity if we are trying
@@ -1726,8 +1727,6 @@ int vcpu_affinity_domctl(struct domain *
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_FORCE )
             vcpu_temporary_affinity(v, NR_CPUS, VCPU_AFFINITY_OVERRIDE);
 
-        ret = 0;
-
         /*
          * We both set a new affinity and report back to the caller what
          * the scheduler will be effectively using.
@@ -1746,7 +1745,7 @@ int vcpu_affinity_domctl(struct domain *
              * cpupool's online mask and the new hard affinity.
              */
             cpumask_and(new_affinity, online, unit->cpu_hard_affinity);
-            ret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, new_affinity);
+            hret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, new_affinity);
         }
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_SOFT )
         {
@@ -1777,6 +1776,8 @@ int vcpu_affinity_domctl(struct domain *
             ret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft, new_affinity);
         }
 
+        ret = hret ?: ret;
+
  setvcpuaffinity_out:
         free_cpumask_var(new_affinity);
         free_cpumask_var(old_affinity);
@@ -1788,7 +1789,7 @@ int vcpu_affinity_domctl(struct domain *
                                            unit->cpu_hard_affinity);
         if ( vcpuaff->flags & XEN_VCPUAFFINITY_SOFT )
             ret = cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft,
-                                           unit->cpu_soft_affinity);
+                                           unit->cpu_soft_affinity) ?: ret;
     }
 
     return ret;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-16 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 12:00 [PATCH for-4.22?] domctl: correct return value of XEN_DOMCTL_[gs]etvcpuaffinity Jan Beulich
2026-06-16 17:12 ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.