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

Re: [PATCH] libs/xg: allow caller to provide extra memflags for populate physmap


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 19 Dec 2025 09:20:49 +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=ZoezJyPHiC0tSiF44WOen1wvN8vgB8Dkei2Rn7ufFwI=; b=Ynrszex0vJ705q7KggE5LK/ini2+gjKnnqj7n231H1QrmrXjQVLwKBOU7JpjgtDUD+QVX19iR8UgEAMUBhON+5zdWb5bd7Dscv6CJOQI9li/m8Dym7wb5kVcBtdiGtjnQlrThoq75CfK0cXqqu4CPpkPduhp2VsoNwjqL0ye61Gr2dki9DBD42qNFEceOCKBHnATIPrESNcFN6dWebqm8PUUIRjVS3Frf+2FOi8KJcShSTYlm2k230eKyV6vgOvhwkG1s0W1StOb29khHx8WHelWH8Y9s8qutyUlCuXZNVUp0rPGd2yysPCW5D2onbtolrUGXl8+NHd+og/JpcsqIw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GMMNvIfE+ThMgCL1XwP1UPZkDcL2/M9OdHZUshWhcYslJkf6zH9Jg8YH/YctFPitVGe3sCBaAmIb8okFasErJ4k5R18/hPGFDjmB6shOCTK8+oPM6S2NIqyUC8GaVMk03pfYKOCZvDAPpcAOA6gfDIx64IJoA6WzgqezrkJM/oN/fzBI4kl7L1BSxhVyYOUHbTiLtozSF3/IfKU9TIyGpj4IYIoRAZoCEgMdIx2FZpE2dwDLdD+ArUEP+wvKobN7i6f3+E3BJnXCU3EpzsKDzkgAIZqheC/FfrGBaLK+kVn0YJ4O6DCdr/knt1HpSogAG+RfVD/1hGT9v5EgDxfLIQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 19 Dec 2025 08:21:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Dec 19, 2025 at 07:59:59AM +0100, Jan Beulich wrote:
> On 18.12.2025 22:34, Andrew Cooper wrote:
> > On 18/12/2025 3:27 pm, Jan Beulich wrote:
> >> On 18.12.2025 16:17, Roger Pau Monne wrote:
> >>> --- a/tools/libs/guest/xg_dom_x86.c
> >>> +++ b/tools/libs/guest/xg_dom_x86.c
> >>> @@ -1260,14 +1260,15 @@ static int meminit_pv(struct xc_dom_image *dom)
> >>>      /* allocate guest memory */
> >>>      for ( i = 0; i < nr_vmemranges; i++ )
> >>>      {
> >>> -        unsigned int memflags;
> >>> +        unsigned int memflags = dom->memflags;
> >>>          uint64_t pages, super_pages;
> >>>          unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
> >>>          xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
> >>>          xen_pfn_t pfn_base_idx;
> >>>  
> >>> -        memflags = 0;
> >>> -        if ( pnode != XC_NUMA_NO_NODE )
> >>> +        if ( pnode != XC_NUMA_NO_NODE &&
> >>> +             /* Only set the node if the caller hasn't done so. */
> >>> +             XENMEMF_get_node(memflags) == 0xFFU )
> >>>              memflags |= XENMEMF_exact_node(pnode);
> >> I'd like to suggest to avoid open-coding the 0xff here and elsewhere.
> >> XENMEMF_get_node(0) will be less fragile overall, imo.
> > 
> > XENMEMF_get_node(0) is even more meaningless than 0xFF, which is at
> > least obviously a sentinel value.
> 
> How that? XENMEMF_get_node(0) is the node that is used when no flags (0)
> were specified. I.e. the equivalent of NUMA_NO_NODE. The underlying
> (pretty abstract) point being that if we ever made a binary-incompatible,
> but source-compatible change to how wide the node representation is in
> the flags (e.g. by the consumer defining some manifest constant to
> engage the alternate behavior), XENMEMF_get_node(0) will continue to
> work while 0xFF won't.

I didn't use XENMEMF_get_node(0) because I found it confusing to read.
When I read that construct I internally associate with node 0, while
it's actually no node set, as the value passed to XENMEMF_get_node()
is the memflags, not a node ID.

> Otherwise at the very least I would strongly suggest libxg to make itself
> a #define for this (repeatedly used) 0xFFU.

I didn't want to introduce that because there's already a define
in libxc for no NUMA node ID, which is wider than 0xff.

Anyway, will do the change and send v2.

Thanks, Roger.



 


Rackspace

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