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

RE: [PATCH v3 5/6] xen/arm: unpopulate memory when domain is static


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Wed, 27 Apr 2022 10:19:58 +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=ZIVys0Ko2yB62h5Lv29829teqGadVMHuVqXj9DPbCpM=; b=Uy6yst1yAbTWGqKvwmNqfI72fwmWwH1MUDHMZgXPdCfaYoppYoMJRpC9AT8tzxZYxjRq0C3obLHPr4Rp6TCCsCfkNXctR01QIqZh2IgSsM4YAH+ySsafwi3H5Hfr8/KAvBIwlsmoO+2WJYfIigIJtzgxIn1LgaoSSlkkGmdaTYZlFi0pS4OCD86vHo8it4UoeAOaEy9qVct973N+YDwCYc6EfLeLrE/cL2+MITGVxdUeeiFQqceBeYNhRS0mActlJqtFjtNo4gKXxPR4icPagtTz2MbdqBjbAp/3dFeWBmdt4GbYsqVPy6qyhWu7OUc0A0evevVzTR1hbby3GHI8Xw==
  • 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=ZIVys0Ko2yB62h5Lv29829teqGadVMHuVqXj9DPbCpM=; b=OdmM1QOqA+lJXHj/wt7iI7NXTVf66IL9iUSDZf3gLRpTmPy22VDRUvCGqG8mLFkYkoOHUEbPn8QfdWQ90phFdgmKr8OZxtOJVjLuiLIDxhBWocOKdoYq+0mI3+HfNW4pUPE4B/hpOg9Ih1Y3ZbkOR0K636VozPwEPUN7QUbIsGRD4tMri8Qyn7n0LwQkB3ye/ToFUS+FAemzWtGFSC7O6fPD5g0Sl5ZQrvxjXoIyhBg0retUwtHzaVApdLNvDGOMJiVk3lDUHRtONhxEXRGwgIZfvxgBxtMMG2Vn/75jx9BZRjdWVmMBbSftLcXR8joJ6ThOz55ApALayhr77VTqVA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HfonyERqP8mwV+NGWFPMrW/ZlAnyRpavMMSp6lgd1l1rUJDLJ8MPcQHoI/KsOZ8Iu+vJchkx9ve9UmHSc3if4d74i8RJghqKkWVjgLNyIBHH/2vKGWweoTqg6cxeBDE8dO9/cCC0F1jMmNhtEwDBCTh1CAytUdBvMm1pWvDwFtmewoafQ+kU2/dTBH1+LweuITodCU74pdF50iIx4RYD3tE74+EwA01Tei/PfLStaGDOdBoli3nao+5x2N7aEdR6XcQ+LWb/S2jTSravbawkrT3LbEJYfImm1cIXUDihykzzFOzLmXBid69InAqtyHjq14ry1mc8cJsJkyl2969/vQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMWWvYQJU7l3o4Z7ZyFZJEu5P31faqie/hzgDgqCtAs70Vll52phMu+yVScmw0ESFyuPYq6Z2SG2Sg4NMPUfisMMY7k1cJpNmB9ir/1KmyfxYtM9p+IHwPvS6E8Za5L+tpPF1KljfgLYDK3qJhATixORw8MgWonqAbisJwSczSwFRZdRd4Somj03HSe8GcWqkbFYKXgS4rSsB9Ak2eEZAScSKD1QmO2GAKKTU1Dj+zrvHOXROkbYG61BfjOo3iZStOXKUXjHgwAuXcmOdFCWGfkQ/YwnlIlojsBtTKc+2tMlJ3KxdEEcFaW83MP7+gVVHReTRQXufFsz9TpjPP/0Aw==
  • 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>, Henry Wang <Henry.Wang@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 27 Apr 2022 10:20:19 +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: AQHYWhk9pvmpyYf9yk6PCG0TATWN+q0DifWAgAAAvZA=
  • Thread-topic: [PATCH v3 5/6] xen/arm: unpopulate memory when domain is static

Hi julien

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Wednesday, April 27, 2022 6:11 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Henry Wang <Henry.Wang@xxxxxxx>;
> Stefano Stabellini <sstabellini@xxxxxxxxxx>; Bertrand Marquis
> <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>;
> Jan Beulich <jbeulich@xxxxxxxx>; Wei Liu <wl@xxxxxxx>
> Subject: Re: [PATCH v3 5/6] xen/arm: unpopulate memory when domain is
> static
> 
> Hi Penny,
> 
> On 27/04/2022 10:27, Penny Zheng wrote:
> > Today when a domain unpopulates the memory on runtime, they will
> > always hand the memory back to the heap allocator. And it will be a
> > problem if domain is static.
> >
> > Pages as guest RAM for static domain shall be reserved to only this
> > domain and not be used for any other purposes, so they shall never go
> > back to heap allocator.
> >
> > This commit puts reserved pages on the new list resv_page_list only
> > after having taken them off the "normal" list, when the last ref dropped.
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> > ---
> > v3 changes:
> > - have page_list_del() just once out of the if()
> > - remove resv_pages counter
> > - make arch_free_heap_page be an expression, not a compound statement.
> > ---
> > v2 changes:
> > - put reserved pages on resv_page_list after having taken them off the
> > "normal" list
> > ---
> >   xen/arch/arm/include/asm/mm.h | 12 ++++++++++++
> >   xen/common/domain.c           |  4 ++++
> >   xen/include/xen/sched.h       |  3 +++
> >   3 files changed, 19 insertions(+)
> >
> > diff --git a/xen/arch/arm/include/asm/mm.h
> > b/xen/arch/arm/include/asm/mm.h index 424aaf2823..c6426c1705 100644
> > --- a/xen/arch/arm/include/asm/mm.h
> > +++ b/xen/arch/arm/include/asm/mm.h
> > @@ -358,6 +358,18 @@ void clear_and_clean_page(struct page_info
> > *page);
> >
> >   unsigned int arch_get_dma_bitsize(void);
> >
> > +/*
> > + * Put free pages on the resv page list after having taken them
> > + * off the "normal" page list, when pages from static memory  */
> > +#ifdef CONFIG_STATIC_MEMORY
> > +#define arch_free_heap_page(d, pg) ({                   \
> > +    page_list_del(pg, page_to_list(d, pg));             \
> > +    if ( (pg)->count_info & PGC_reserved )              \
> > +        page_list_add_tail(pg, &(d)->resv_page_list);   \
> > +})
> > +#endif
> 
> I am a bit puzzled how this is meant to work.
> 
> Looking at the code, arch_free_heap_page() will be called from
> free_domheap_pages(). If I am not mistaken, reserved pages are not
> considered as xen heap pages, so we would go in the else which will end up to
> call free_heap_pages().
> 
> free_heap_pages() will end up to add the page in the heap allocator and
> corrupt the d->resv_page_list because there are only one link list.
> 
> What did I miss?
> 

In my first commit "do not free reserved memory into heap", I've changed the 
behavior
for reserved pages in free_heap_pages()
+    if ( pg->count_info & PGC_reserved )
+        /* Reserved page shall not go back to the heap. */
+        return free_staticmem_pages(pg, 1UL << order, need_scrub);
+

> Cheers,
>
> --
> Julien Grall

Cheers,

--
Penny Zheng

 


Rackspace

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