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

Re: [PATCH v2] domain: skip more stuff for idle's vCPU-s in vcpu_create()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 17 Feb 2026 12:46:29 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pfJtv+7XdWLCg/34XrCgwfQjiDHKj1mcC2sdr0a+cjw=; b=Fbzzxz+8KOQBFa40xzzQPCSsxgWlefoWtMXvh79egXMrNfWSb+An1d4u0EKTIHGapvmmSGbgd99PFDViE6uwjTk/mgDKdh3So/kQ4uaB1ipmOgtOE7eXMBhu2X64cSHS2xIHGuqLVb3SJXQiProeueJ7oHotRATCZPeZAm4ZENSDk2cBOnHBVPvZ0/3bNggBYpYjPBNw2DrIKfrVhFSCjPbvEyakD5knMyHG+O0a6PaT3qUDbNN+7pfOfNkG82xc/kmlY9l/hB5N7Pv3x31gEs3nWngmtIywE1JRK5wI1jHPgcGoQ3dz6QW5OhIPiDIXZAGYue5sSfAce/glpNT6KQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K3pRQ7/4M7GZqdtAnGF7JSlIZEV5KH3QgrGZyyNqpT5VeDgoIy4r/D+EOdZRS2sikDS2BY5ZuVDqJVhgdHkj4JRSKxxTLPQe67UPIi0sjXqsKdTQKdQoCRdwAjmWltYb1I5kHzFsmb/F7D/3Iovrmogl75JwBrgoi5H1+USgLetP9fEAECLiLmBOC0KdhJ6Qg1MOmohBkseCdMeuV1nmeKCr8XrtusmwFZpTi8q1ZY9ikkFauRmFhSIind7whBe7fAvwkZUO3z7+TeruQpHvogyLHfWyxWBSFVt4sC4qscPWs+gTxCL9k7ewCmP2QUNyusK6dPn1/KVeVNH2eJ0WtQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Tue, 17 Feb 2026 11:46:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Feb 17, 2026 at 12:17:35PM +0100, Jan Beulich wrote:
> On 17.02.2026 12:04, Roger Pau Monné wrote:
> > On Mon, Feb 16, 2026 at 04:54:30PM +0100, Jan Beulich wrote:
> >> Nothing hypercall-related needs setting up there. Nor do we need to
> >> check whether the idle domain is shutting down - it never will.
> >>
> >> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> > 
> > Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Thanks.
> 
> >> @@ -516,7 +516,8 @@ struct vcpu *vcpu_create(struct domain *
> >>      }
> >>  
> >>      /* Must be called after making new vcpu visible to for_each_vcpu(). */
> >> -    vcpu_check_shutdown(v);
> >> +    if ( !is_idle_domain(d) )
> >> +        vcpu_check_shutdown(v);
> > 
> > I would possibly leave this as-is.  I agree that the idle domain will
> > never shut down, but it's possibly best to needlessly call into
> > vcpu_check_shutdown() for the idle domain rather than adding the extra
> > conditional for the common case?
> 
> I'd prefer to keep it conditional: Calling the function for the idle
> domain gives a wrong impression, plus it may be the only one where the
> shutdown lock is used for that domain. We may want to make lock init
> conditional in domain_create() as well (possibly with other things we
> needlessly do for idle or more generally system domains).

I've been thinking about this, and I'm not sure whether it's the best
approach to avoid initializing locks or lists for the idle
vCPUs/domain.

It's certainly good to avoid initializing stuff that consumes memory
or other resources, but skipping plain initialization (iow: setting of
values) of fields that are in the respective structs seems dangerous
to a certain degree.  If for whatever reason we end up with stray
calls from the idle vCPUs/domain into functions that use those fields
it's likely safer to have them initialized, rather than tripping into
some uninitialized pointer or deadlock trying to acquire and
uninitiated lock.

Thanks, Roger.



 


Rackspace

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