From nobody Wed Aug 26 12:57:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1782904595; cv=none; d=zohomail.com; s=zohoarc; b=DmV+v+Bop0ycGaRkX+0IHCGHM8jT/jJypylFfpwonX0IZFZW9PbsIfuzuwtVnbWWJ8VVapBmX5bo0eGnud+O64XP3YvBJrGYv4hvWLaUAJhm+9DVZKuKqXKRS5vdU/BMB3A6upEQr7elpfqpJTc2AmoW+oNLvZ2QkIkCvp7DL9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782904595; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eHLTBeGgYNLdb9o5EF92sUCLA1iLOlkHRzk4jz8IGiQ=; b=F/4c74ZkHwdOgcvSm5Roc2/vchE/GTOanmPwwFMWtgfeoMqGC0Qu/wpS+8EnjvlpaIZXQp/yVuVhJMvwtepVvY+7oKIjlXnsZjHOHGCFCKBLyox5SsWvc+wY/As7N91Ca0EYjhe3TbhrLe6DK0vlWpvnJ8Hr3ot0GBgw0b+hwHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1782904595249542.5332883462477; Wed, 1 Jul 2026 04:16:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1349772.1607429 (Exim 4.92) (envelope-from ) id 1wesvX-0001KB-3E; Wed, 01 Jul 2026 11:16:23 +0000 Received: by outflank-mailman (output) from mailman id 1349772.1607429; Wed, 01 Jul 2026 11:16:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wesvW-0001Jx-U2; Wed, 01 Jul 2026 11:16:22 +0000 Received: by outflank-mailman (input) for mailman id 1349772; Wed, 01 Jul 2026 11:16:21 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wesvV-0001IA-9O for xen-devel@lists.xenproject.org; Wed, 01 Jul 2026 11:16:21 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wesvU-008Ib4-MO for xen-devel@lists.xenproject.org; Wed, 01 Jul 2026 13:16:20 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a44f6ff-bab6-0a2a0a5309dd-0a2a45038504-8 for ; Wed, 01 Jul 2026 13:16:20 +0200 Received: from [195.135.223.130] (helo=smtp-out1.suse.de) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a44f704-ec1a-0a2a45030019-c387df82da78-3 for ; Wed, 01 Jul 2026 13:16:20 +0200 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3062C73A63; Wed, 1 Jul 2026 11:16:20 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D9B40779AA; Wed, 1 Jul 2026 11:16:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8F7cMwP3RGrhAQAAD6G6ig (envelope-from ); Wed, 01 Jul 2026 11:16:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1782904580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eHLTBeGgYNLdb9o5EF92sUCLA1iLOlkHRzk4jz8IGiQ=; b=WxgOEtUNI3sdwzFIUTtXShDsriBbBzUldTOXEQxT0sH5yfsbtNS151iYxQJw4wyTY5fSQW 5nqcg5yOupZe9vzqagQDrVOmRMU66WA1FVqoxEcdfGj5MYsadumODIwmR2FnxPWpkamYY1 bQbJW+2PFdIZgeg1XMS4ah3gNsOse8M= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=WxgOEtUN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1782904580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eHLTBeGgYNLdb9o5EF92sUCLA1iLOlkHRzk4jz8IGiQ=; b=WxgOEtUNI3sdwzFIUTtXShDsriBbBzUldTOXEQxT0sH5yfsbtNS151iYxQJw4wyTY5fSQW 5nqcg5yOupZe9vzqagQDrVOmRMU66WA1FVqoxEcdfGj5MYsadumODIwmR2FnxPWpkamYY1 bQbJW+2PFdIZgeg1XMS4ah3gNsOse8M= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Dario Faggioli , George Dunlap , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH 2/3] xen: don't let XEN_DOMCTL_setvcpuaffinity return the new affinities Date: Wed, 1 Jul 2026 13:16:05 +0200 Message-ID: <20260701111606.4063972-3-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260701111606.4063972-1-jgross@suse.com> References: <20260701111606.4063972-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Rspamd-Action: no action X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email,suse.com:dkim,suse.com:mid]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_SEVEN(0.00)[11]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DKIM_TRACE(0.00)[suse.com:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 3062C73A63 X-Spam-Score: -3.01 X-purgate-ID: tlsNG-33051d/1782904580-BDFBB5D1-DAD606B7/0/0 X-purgate-type: clean X-purgate-size: 5760 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1782904597407158500 Content-Type: text/plain; charset="utf-8" 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 --- 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 c= md, { struct vcpu *v; const struct sched_unit *unit; - int ret =3D 0, hret =3D 0; + int ret =3D 0; =20 if ( vcpuaff->vcpu >=3D d->max_vcpus ) return -EINVAL; @@ -1724,12 +1724,11 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t= cmd, if ( cmd =3D=3D XEN_DOMCTL_setvcpuaffinity ) { cpumask_var_t new_affinity, old_affinity; - cpumask_t *online =3D cpupool_domain_master_cpumask(v->domain); =20 /* * 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); =20 - /* - * 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 =3D xenctl_bitmap_to_bitmap(cpumask_bits(new_affinity), + ret =3D xenctl_bitmap_to_bitmap(cpumask_bits(new_affinity), &vcpuaff->cpumap_hard, nr_cpu_i= ds); - if ( !hret ) - hret =3D vcpu_set_hard_affinity(v, new_affinity); - if ( hret ) + if ( !ret ) + ret =3D 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 =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, new_a= ffinity); } 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_affinit= y); - ret =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft, new_af= finity); } =20 setvcpuaffinity_out: @@ -1802,14 +1780,14 @@ int vcpu_affinity_domctl(struct domain *d, uint32_t= cmd, else { if ( vcpuaff->flags & XEN_VCPUAFFINITY_HARD ) - hret =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, + ret =3D 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 =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft, unit->cpu_soft_affinity); } =20 - return hret ?: ret; + return ret; } =20 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 successf= ul - * 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 dur= ing --=20 2.54.0