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

Re: [PATCH for-4.22 v2] xen/x86: Change stub page allocation/free


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 12 Jun 2026 09:44:27 +0200
  • 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=cMHCHFothwqvXToNggJKNvceNejLS4zazL1dXsDL2I4=; b=p34Afm+F+cTlR3EXYSKq03u6h/R8EE+RZoFv1JZJ7tZyuHqkfyfMvCfHevceEXwIKWrzJhtXtEzepPMst4Soe+cmzZ+5X+w6ve9HWo6dKqb2um+GvOBdR/E7AkbbCKc8wtQgL84UEGYdwMlomTjiq06NTl+Uv29KgbxUCHf2Ie8CVrQ+cgrSHyII9Xpze/bSHtup/405EhgMwLu4yXLLVpu6eYRB5LKl7qGB/y+xTPRBuH+JLAZPoGkNcVGSC+/8KWp9BqnYl7gkG5p/XjVX/IzJctZNJZN0+QuKba9Y+5JcIGEeWdbjvunojzgNO1pdoOe7/Z+Z8I2gsainhTEhTQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JA76dbQ79mY/yJA6ycckWAt6saxhb7b9IqTOvi9+321UZG5gG1HUoRqDaEmUFqAisusBw7th+275+RWSV4A7I4cpY51Me6CQ2ycNMlclNaUeCipiPmspyK2oXbXZAwgDWV5sro66+Muxeo9Y1JJwAFUtHKdogBDIeVDlBwm10dff2SZJYRnN3vN9xO7vCVVzw0hH9lBMOySm3Wf5Sedh5ovtDiLA8kycF2pvQH44/FQfT1sjNOG2/wJWonE0pIIJp23jttDAXQnhAEXbA9MChC9pdq6AwqH3KXVYC7zywDsvYKRgdxXw6m0V0aOdyUyP03htkwZMqOApCf7sh3VPAQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 12 Jun 2026 07:44:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Jun 12, 2026 at 09:40:03AM +0200, Jan Beulich wrote:
> On 11.06.2026 16:21, Roger Pau Monne wrote:
> > @@ -641,41 +642,62 @@ static int do_boot_cpu(int apicid, int cpu)
> >      return rc;
> >  }
> >  
> > -#define STUB_BUF_CPU_OFFS(cpu) (((cpu) & (STUBS_PER_PAGE - 1)) * 
> > STUB_BUF_SIZE)
> > +/* Dynamically allocated, indexed by CPU.  Store physical address of 
> > stubs. */
> > +static paddr_t *__ro_after_init stubs;
> >  
> > -unsigned long alloc_stub_page(unsigned int cpu, unsigned long *mfn)
> > +static bool assign_stub_page(unsigned int cpu)
> >  {
> >      unsigned long stub_va;
> > -    struct page_info *pg;
> > +    paddr_t addr = stubs[cpu];
> >  
> > -    BUILD_BUG_ON(STUBS_PER_PAGE & (STUBS_PER_PAGE - 1));
> > -
> > -    if ( *mfn )
> > -        pg = mfn_to_page(_mfn(*mfn));
> > -    else
> > +    if ( addr == INVALID_PADDR )
> >      {
> > -        nodeid_t node = cpu_to_node(cpu);
> > -        unsigned int memflags = node != NUMA_NO_NODE ? MEMF_node(node) : 0;
> > +        nodeid_t nid = cpu_to_node(cpu);
> >  
> > -        pg = alloc_domheap_page(NULL, memflags);
> > -        if ( !pg )
> > -            return 0;
> > +        /*
> > +         * Attempt to use the same page as the previous CPU if possible,
> > +         * otherwise allocate a new one.
> > +         */
> > +        if ( cpu && nid == cpu_to_node(cpu - 1) &&
> > +             PAGE_OFFSET(stubs[cpu - 1] + STUB_BUF_SIZE) )
> > +            addr = stubs[cpu - 1] + STUB_BUF_SIZE;
> 
> Isn't this path also going to be taken if stubs[cpu - 1] is still 
> INVALID_PADDR?
> That may be a purely hypothetical case right now, but imo would better be
> covered right away.

Yes, indeed I was assuming that stubs[cpu - 1] would always be
populated, which it's the case currently, but you are right that it's
trivial to also take this scenario into account here.

Thanks, Roger.



 


Rackspace

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