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

Re: [PATCH v9 8/8] xen: retrieve reserved pages on populate_physmap


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 25 Jul 2022 17:44:23 +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=7s0/1qJhReTgi4aCjoGoWe2iBVyXGcIRpJJdx8BiEvk=; b=MpfvyJAribaGS2jUGPwSujjZDvHKeBZVj/LV+5GWX69edlDvvrtw/hlgFX0/HpGl7XPNJPZ43gIsOEB2/4wVNCRLEWMBUqFF3BMpkJiXEmb2g028kN3toNmzu2FQBFYaWRr8FSjG6VnwnxPkmfqUZYHLafhkWj7lZI64Vv0EmvFQwuwlxYcgQaGFavZQW914naLToK0klakk36tR8vs5P2MexTvHo8GDT4+YR2avAcTzO5UuyxnGv6teYcFtkf0yOX+iogDZ09Odg6KZlmJHqJoGOEncMosXh4AaWlspWUhgqQo092qHc9QJ5YElTqcVtUdmCEGbAxpnNElUQCp3CA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ksdsU8/GehGDV5K7ScbwQ5vePzF8GrJoGPL3wJvJJ+xEKtmrgP+zwFkk588mAazzJizVhM4Rou7vFJ6oplJjDTIkukLVxkQBHRLBmqXSbjOQ0Jyj8IXfDFbV4paioCTKuePULWkFYmOjKf2L95x813Nt52UmF/DwlL8kGN+zNhwHfDP8Fwvg/onsL5R4YDX3UydW7m+jOAhetorykHOrTo1eoAeo00coZW4PHtrJuQZ7CbQMPmcIGkPb6LSY2ZMUu0sKroekElZk2krW3MXuUNXZQvjUnKFuc6OGTjGLy56L7bD8FlbLe+GTzGsMxy8wL7coqG32C0FhnNkEvo96Xw==
  • 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: Mon, 25 Jul 2022 15:44:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.07.2022 07:46, Penny Zheng wrote:
> When a static domain populates memory through populate_physmap at runtime,
> it shall retrieve reserved pages from resv_page_list to make sure that
> guest RAM is still restricted in statically configured memory regions.
> This commit also introduces a new helper acquire_reserved_page to make it 
> work.
> 
> Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> ---
> v9 changes:
> - Use ASSERT_ALLOC_CONTEXT() in acquire_reserved_page
> - Add free_staticmem_pages to undo prepare_staticmem_pages when
> assign_domstatic_pages fails

May I suggest to re-consider naming of the various functions? Undoing
what "prepare" did by "free" is, well, counterintuitive.

> +/*
> + * 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;
> +
> +    ASSERT_ALLOC_CONTEXT();
> +
> +    /* 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;
> +
> +    if ( assign_domstatic_pages(d, page, 1, memflags) )
> +        goto fail_assign;
> +
> +    return page_to_mfn(page);
> +
> + fail_assign:
> +    free_staticmem_pages(page, 1, memflags & MEMF_no_scrub);
> + fail:
> +    page_list_add_tail(page, &d->resv_page_list);
> +    return INVALID_MFN;
> +}

What about locking on this error path?

Jan



 


Rackspace

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