[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 9 Aug 2022 07:53:20 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=wkPwy5AHKadMyIA+8uZGWZz5T9fExyiEnD2PJqoRzf0=; b=C+y4fB4SPT4CMf/MDcVStYcyHPaWUzuJsG99W4M5tJSHc/1SzBdgVyLoCajIz7702PGUryi95qLOMpeNn519172ZJWNFerMSeYNGcHwnmW+BHYm837zxvIrNW0t+6hCW2/jHJ+g02Jsu8v/OlvvJzD0TA9t0u0RhJzJa5x2T+AnRwCM9KQ9TQ2Hxs2eG7xsXpCU3HAhpILC8G6eXBEqrvvcJhnt7wRwfZU/Y+zkeoeJNU8TsFudNhlyScEj4zLNt0iRwzRBLIO0tkMkwATur2kED0BqN4gHt/h0RtveC2hUMIpg0pfHxd6FYnFGmCKBbZGXvIVoAZBrIz33rAkDmVg==
  • 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=wkPwy5AHKadMyIA+8uZGWZz5T9fExyiEnD2PJqoRzf0=; b=Z22zeeyMJf7RYBL8xQ5rwMEvauzPip23h4U9WZuZH8bOVJRWqM+Lu1TacvdcOgdYW3bYZ83O3oDobOrWfd0doGHM5McbOjuaaNK397oQmfIDGDH+24w7r8GvNOoYCwdnEGRpZbzOv9fkHmVf8GGrJgUYtTZ5b4vPubp9aBlyO0hfE4h/iVBhL9WVBGoAx8NM2XCeJPHWjWm+WMHgymeOJ92TGsqGIkamGkYPzot/O8lgOf+FvmASJe9WRuJ0XKUqjBHEjnUegvs1LIiYl0vNnEZFwUMJ/QC9o9NtcOxdoDm8zuDb62ihTpPGdtLmqisLVa6nXWCeSTgFqI82atFAdA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=KcTQc12QpQCchVBfxM2YX9tkQlOF1UkSbOJg69kBO2iA7wT6KCMBmsHLrh5mrm0COJY5JouH+7YBALmfmRks8TtA4RyFhqdI/uLx4ApfljqVUWASULsJb/7JHueK7VcQOZ7WHebZXu+NpMD8NeUyxsHBoghKgC3L44hAHW4Ci3Ov5PnaPmUrqCKrBeScqqWF5Puc+S1wuJAG+GWalPh5bXo8Fe3mpeTTwkfHjLnxDSZSrQuoWNZ8jjZ5AoeDWsZjK3g6mhFYUfJGeiLpGdnwykIvQUcgsdxeKHb0kIJ9dzB5HqxYStxhccSaQ5jP4WZgT0zXk2iIUQ1uz1O83Fb81Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CBaEUriQ/a2DfDsj58h8ZMSvrfjCK6NX/NNbtKoeiYqleQTwSSdNddVXNZunJz3NuHLFW2NBOaSfyPq7W3oUkVsw+Fd/Z8YzgyBk1IofBC1U7v2zhbBy9JY+IIeRpbb7xeA3wWLQqlYOEol3kGRFcjrIi83kW3Op/QTWglKyUS9+hWpuw0LVWQnaHo31JIYYDrqaZrhde7CAfX6lrkK91DqN13S3CERMg6QZx2FyxpryB41Y/20hdubMaiMnSd/F48hXkmEY4Cz4xwBdF2jnxnZRCJCbIbYC37uHA1SUaTktvEZAw2wYsXis1ruSBRSm0K3/9DeetjjWz3j0KrkdxA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Wei Chen <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" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 09 Aug 2022 07:53:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYm/wqv1nrEHMOJUyQDyAePQJHla2PQtqAgBcOCRA=
  • Thread-topic: [PATCH v9 8/8] xen: retrieve reserved pages on populate_physmap

Hi Jan

Sorry for the delayed response.

> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of Jan
> Beulich
> Sent: Monday, July 25, 2022 11:44 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>
> Cc: Wei Chen <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
> Subject: Re: [PATCH v9 8/8] xen: retrieve reserved pages on
> populate_physmap
> 
> 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.
> 

How about change the name "prepare_staticmem_pages" to 
"allocate_staticmem_pages"?

> > +/*
> > + * 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?
> 

Right, locking is needed here too:
fail:
   spin_lock(&d->page_alloc_lock);
   page_list_add_tail(page, &d->resv_page_list);
   spin_unlock(&d->page_alloc_lock);

> Jan


 


Rackspace

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