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

Re: [PATCH v8 9/9] xen: retrieve reserved pages on populate_physmap


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 8 Jul 2022 15:06:26 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=AabFokN8GS/5Jif5f7ekO232MOoTvFwR/R6Y90bjom0=; b=IN2vhQf7+vIJznRMuJ2XsFIjRO3eRMCyAoCTKHbKhRgIvpAeblQDCwvu2VFEV77emQrMNwV9QsJ0q1bUUEidPI3p8E0O64t0yweD9qnioBS8Cu0wUSQJiR8O7TJ2VsdGlCsIuXW5HyX26DaOqyVJ2GDCJnSdDmrpPrWFTKjYOqK+NxW8bRIlJROs8xws7Dfq4ybb3Nja+D9NmnngVk7FF+7TmLZd3Xjsek/NSF5GT2mZv2JYR47AE7glcDgo94C0lcEmlQx/iG8ycL98oDwVeYDZagqvBcoHEFQvbcxvh+D7vmgVnRkBM5PNG5MClK76eHysVXa8v8nTQG7IlodFWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TGQG2/TF5h0iq7jFABgcbN6ioI2mCcTWtJ5GkWGRJMeQ6GkxIrcFegOt6o7RbmwDukcN28eh4Eqq0UxoLt5Gex5O/Ix/BO7ttvL8+2zDuMxdo42xxW3zDH8YhHChsUSVVjbTkH9c3jnK4TD9cOfyd1IX0ZoW6/KVsxges5tChUrLvZaMza9/r27EZCpoBEvzud3LpCCZik25PTxgqw2MD0izSgB7BN3Ebng5/JZrQC88Ayl6oEUU/TQeQ84skzCRHP8s/BASvC9CmuXc8rlwG3jUA+aT/CjOsNMyaSBm0sM7+agTLrKfO/NrjtJaKwCwfohP/CyZTeZvIZgEO6K5+g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: wei.chen@xxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 08 Jul 2022 13:06:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.07.2022 11:22, Penny Zheng wrote:
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -245,6 +245,29 @@ static void populate_physmap(struct memop_args *a)
>  
>                  mfn = _mfn(gpfn);
>              }
> +            else if ( is_domain_using_staticmem(d) )
> +            {
> +                /*
> +                 * No easy way to guarantee the retrieved pages are 
> contiguous,
> +                 * so forbid non-zero-order requests here.
> +                 */
> +                if ( a->extent_order != 0 )
> +                {
> +                    gdprintk(XENLOG_WARNING,
> +                             "Cannot allocate static order-%u pages for 
> static %pd\n",
> +                             a->extent_order, d);

I'm probably wrong in thinking that I did point out before that there's
no real reason to have "static" twice in the message. Or am I mistaken
in my understanding that only static domains can ever have static pages?

> @@ -2818,6 +2805,55 @@ int __init acquire_domstatic_pages(struct domain *d, 
> mfn_t smfn,
>  
>      return 0;
>  }
> +
> +/*
> + * Acquire nr_mfns contiguous pages, starting at #smfn, of static memory,
> + * then assign them to one specific domain #d.
> + */
> +int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn,
> +                                   unsigned int nr_mfns, unsigned int 
> memflags)
> +{
> +    struct page_info *pg;
> +
> +    ASSERT_ALLOC_CONTEXT();
> +
> +    pg = acquire_staticmem_pages(smfn, nr_mfns, memflags);
> +    if ( !pg )
> +        return -ENOENT;
> +
> +    if ( assign_domstatic_pages(d, pg, nr_mfns, memflags) )
> +        return -EINVAL;
> +
> +    return 0;
> +}
> +
> +/*
> + * Acquire a page from reserved page list(resv_page_list), when populating
> + * memory for static domain on runtime.
> + */
> +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags)
> +{
> +    struct page_info *page;

Use ASSERT_ALLOC_CONTEXT() here as well?

> +    /* Acquire a page from reserved page list(resv_page_list). */
> +    spin_lock(&d->page_alloc_lock);
> +    page = page_list_remove_head(&d->resv_page_list);
> +    spin_unlock(&d->page_alloc_lock);
> +    if ( unlikely(!page) )
> +        return INVALID_MFN;
> +
> +    if ( !prepare_staticmem_pages(page, 1, memflags) )
> +        goto fail;

Don't you need to undo what this did if ...

> +    if ( assign_domstatic_pages(d, page, 1, memflags) )
> +        goto fail;

... this fails?

Jan



 


Rackspace

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