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

RE: [PATCH v5 2/9] xen: do not free reserved memory into heap


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Thu, 2 Jun 2022 02:18:31 +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=7f7fpUrKH8MgG0mcY6KWXtg8YpxTMk9tH5sCFADrNfs=; b=PjNIMtvzjifw832BgLpO/h27hTXKiOzPX9OeO3pR43+XwWXmqswPT/ObQmaU2Qg/QVqLbIqkb5wIolW8ju/9jg7ZSGC9n0Z+7g9pbZjGuA0YxAK79e9BXtYMsLMyC1qCGvasEx1JH3Z4Ey4w/VXPlIsL3p11YwkGkQ8/D1SFxvC9tb9wQ3sEzNZsApP4NA8sZ1+jrGlt5vdIpt0mxJclMHHfqA+H4lZEBcPmicDSKr4Oyv9MtsltniwdaYJGhV4Ih28vLj4CfCzYM2pD/Y6DjuILp5bn16v4ju7411a4Q8QCz4GyGSEwQO8Y3xwoB9fDzbcKv5OlTcQZoqtd4Cpwng==
  • 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=7f7fpUrKH8MgG0mcY6KWXtg8YpxTMk9tH5sCFADrNfs=; b=bKQVX1l88EZmohkfdqG67HfMrSyty2wwEbcpTwm6oSUKZkXYQ1rCkJ4S7PV8DMshkmFU8WNl1MICodh3qkJdCp3pDQaYqPGhbjeHtuBuOXMHbQFF9h1pH0pLcXIRTwVZz5x9+VMWkk9FNweyvfBDUEeip3H8IDctCTKoM8hJ44FYSJYEPbkV2Mx2xfWA3z7ExlU3LaMwy/UUIWqJm01Z98TUOGZahxLMTQutHvYmbkoGlnLg9S8Oa6bfscvtaTnf19/O7V1SW72THNE5E/oKZcASbWgvVd1ZyIxkLoGSV4DW3gYqAHwaBpGG/QzAeE0PH+CocYgl3mtn2jFbuOSCZw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=nPB2BJYWdFQT5pi+7NxcY6XUzI2IQ4unNxd4QXB9Ydz36v6myuuIS0pyd9qtLK85ZLeOtxMglmkctYLdRO6LlqadCdD1xLJ4qDFWm/VkeLC2gGh8rcI5z59vrHtrbW7LmPLSqhK6ORzImmG/TtwGinkw0YeMCMktF9p1ZUmV9YnC4gSyIF2pcwk/YlCSneb7KwrtpuwfM6KSHXfDaWjfb/L6w9Fl/clu33Au98JFyY7b5VrYdGL3UwBjpzHnGiu6jG0zTRtIZao+El2Qu/S/r0kb/Bi3lPr0sZZgAn5muI6597DEV3Ox+QtzidaUN66HyMcfo9cjBviSu9w3uF5V6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oYeh31fCwMRUjTDK+qybMYqfmn08Nmu2Qhn5aQCaCfkWgtRQH3pmqNxvsJaWN1sQjEUiBeVWdbkFOR3dFn+oH9xaXHBKpxhst6A7VFu1eBG5Od76/QTF0Qbo1YyZwCL8En6+QkEk58dugWkH7e9Zd/KIB7VXvhaf0Cl8VyIutkK2auNi0n6AwNBdJeKDi1Dcvlom4lfMVecbdkOT+sOQJYoT1ggUiIjsTeWiP1HifOdl6mhfa2LwZgApZ/9Seq0Vkik1qRy2FtIpW7DTMGCfhya32MH0ZRyF/tPxon4aV7qb7vINSNCInUWt44mLhbt30Nm6/Z0a2zagGPNVX08Ziw==
  • 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 02 Jun 2022 02:18: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: AQHYdJxqwyiFdjgwHkGm0BKg5tWdR604qfGAgAK5SiA=
  • Thread-topic: [PATCH v5 2/9] xen: do not free reserved memory into heap


> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Tuesday, May 31, 2022 4:37 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Stefano Stabellini
> <sstabellini@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>; Bertrand Marquis
> <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>;
> Wei Liu <wl@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v5 2/9] xen: do not free reserved memory into heap
> 
> On 31.05.2022 05:12, Penny Zheng wrote:
> > Pages used as guest RAM for static domain, shall be reserved to this
> > domain only.
> > So in case reserved pages being used for other purpose, users shall
> > not free them back to heap, even when last ref gets dropped.
> >
> > free_staticmem_pages will be called by free_heap_pages in runtime for
> > static domain freeing memory resource, so let's drop the __init flag.
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> > ---
> > v5 changes:
> > - In order to avoid stub functions, we #define PGC_staticmem to
> > non-zero only when CONFIG_STATIC_MEMORY
> > - use "unlikely()" around pg->count_info & PGC_staticmem
> > - remove pointless "if", since mark_page_free() is going to set
> > count_info to PGC_state_free and by consequence clear PGC_staticmem
> > - move #define PGC_staticmem 0 to mm.h
> > ---
> > v4 changes:
> > - no changes
> > ---
> > v3 changes:
> > - fix possible racy issue in free_staticmem_pages()
> > - introduce a stub free_staticmem_pages() for the
> > !CONFIG_STATIC_MEMORY case
> > - move the change to free_heap_pages() to cover other potential call
> > sites
> > - fix the indentation
> > ---
> > v2 changes:
> > - new commit
> > ---
> >  xen/arch/arm/include/asm/mm.h |  2 ++
> >  xen/common/page_alloc.c       | 16 +++++++++-------
> >  xen/include/xen/mm.h          |  6 +++++-
> >  3 files changed, 16 insertions(+), 8 deletions(-)
> >
> > diff --git a/xen/arch/arm/include/asm/mm.h
> > b/xen/arch/arm/include/asm/mm.h index 1226700085..56d0939318 100644
> > --- a/xen/arch/arm/include/asm/mm.h
> > +++ b/xen/arch/arm/include/asm/mm.h
> > @@ -108,9 +108,11 @@ struct page_info
> >    /* Page is Xen heap? */
> >  #define _PGC_xen_heap     PG_shift(2)
> >  #define PGC_xen_heap      PG_mask(1, 2)
> > +#ifdef CONFIG_STATIC_MEMORY
> >    /* Page is static memory */
> >  #define _PGC_staticmem    PG_shift(3)
> >  #define PGC_staticmem     PG_mask(1, 3)
> > +#endif
> >  /* ... */
> >  /* Page is broken? */
> >  #define _PGC_broken       PG_shift(7)
> > diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index
> > 44600dd9cd..6425761116 100644
> > --- a/xen/common/page_alloc.c
> > +++ b/xen/common/page_alloc.c
> > @@ -151,10 +151,6 @@
> >  #define p2m_pod_offline_or_broken_replace(pg) BUG_ON(pg != NULL)
> > #endif
> >
> > -#ifndef PGC_staticmem
> > -#define PGC_staticmem 0
> > -#endif
> > -
> 
> Is the moving of this into the header really a necessary part of this change?
> Afaics the symbol is still only ever used in this one C file.

Later, in commit "xen/arm: unpopulate memory when domain is static", 
we will use this flag in xen/arch/arm/include/asm/mm.h

> > --- a/xen/include/xen/mm.h
> > +++ b/xen/include/xen/mm.h
> > @@ -85,10 +85,10 @@ bool scrub_free_pages(void);  } while ( false )
> > #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0)
> >
> > -#ifdef CONFIG_STATIC_MEMORY
> >  /* These functions are for static memory */  void
> > free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
> >                            bool need_scrub);
> > +#ifdef CONFIG_STATIC_MEMORY
> >  int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int
> nr_mfns,
> >                              unsigned int memflags);  #endif
> 
> Is the #ifdef really worth retaining at this point? Code is generally better
> readable without.
> 

Sure, will remove

> Jan


 


Rackspace

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