From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: "Juergen Gross" <jgross@suse.com>,
"Dario Faggioli" <dfaggioli@suse.com>,
"George Dunlap" <gwd@xenproject.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: [PATCH 2/3] xen: don't let XEN_DOMCTL_setvcpuaffinity return the new affinities
Date: Wed, 1 Jul 2026 13:16:05 +0200 [thread overview]
Message-ID: <20260701111606.4063972-3-jgross@suse.com> (raw)
In-Reply-To: <20260701111606.4063972-1-jgross@suse.com>
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@suse.com>
---
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
next prev parent reply other threads:[~2026-07-01 11:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 11:16 [PATCH 0/3] Change XEN_DOMCTL_setvcpuaffinity interface Juergen Gross
2026-07-01 11:16 ` [PATCH 1/3] tools/libxl: don't rely on xc_vcpu_setaffinity() returned cpumaps Juergen Gross
2026-07-01 11:16 ` Juergen Gross [this message]
2026-07-01 11:16 ` [PATCH 3/3] tools/libxenctrl: rename parameters of xc_vcpu_setaffinity() Juergen Gross
2026-07-01 11:39 ` [PATCH 0/3] Change XEN_DOMCTL_setvcpuaffinity interface Jan Beulich
2026-07-01 11:45 ` Andrew Cooper
2026-07-01 13:00 ` Jürgen Groß
2026-07-01 13:08 ` Jürgen Groß
2026-07-01 13:48 ` Jan Beulich
2026-07-01 14:19 ` Jürgen Groß
2026-07-01 15:34 ` Juergen Gross
2026-07-02 5:54 ` Jan Beulich
2026-07-02 6:13 ` Jürgen Groß
2026-07-02 6:25 ` Jan Beulich
2026-07-02 6:30 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701111606.4063972-3-jgross@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=dfaggioli@suse.com \
--cc=gwd@xenproject.org \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.