|
[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
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.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |