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

RE: [PATCH v4 6/6] xen: retrieve reserved pages on populate_physmap


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 17 May 2022 06:24:18 +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=P+WogaoU5NMk4VzfTmoz6DN+xqWel39r/u7WQhU1jlc=; b=XaFj2WvtuWjBzdkeuh8yVkrjP8vmVd3uNs4LiUZZCmDwhLapL7lWgSFQVxr+4CXmcGQX4eMns7GZbjmxSNbG+zysIRWXBVR1o90qdTm0AzQV8Cfa3Ke5NkPvk6C5Vh8fseufhYfHytrNa1a2XlcItRtnb/k97GiZ7ZH3FYCskNEVhNhkdsA5ZIUDXNfep6QYkwkAIqpt7a9Uu4VPS8IkiM1QzkOBE0sULtE+tXDv32zIU3J9OhCX528VrfDcPPQ2wEsK/WcCBJWsRULw12T9tRw+m0a3jlfzKwKyQRPydX3Ohu35o+27yR1b2d/vhUB/dnzFRkfE53YMCQX3UQLwFg==
  • 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=P+WogaoU5NMk4VzfTmoz6DN+xqWel39r/u7WQhU1jlc=; b=U/L5JieMDXyd/K5D9FMeeXj3MqBp1rlRA5sl5Xo2xf/e7y29yJdVVQMnfyWWL0WGKUtfx1ea85/kDJCgvzzVW9tzxmgT6DgATMc7Xry7yeVdX2GoHilj66ChFodiCOxs6z+pInjU6R4wW+C/Zepi5NV7pkVXt/4eDwJFjlfeq0BVxGZ8/eBzyEMhMEc5cJZ/mosW+DJIvhVR4J5IbPamVtFUg9cX3u85/uMLv3wx0/sH82uozSGWwSdOK/ApT2Mt3DX7HPI+wL4AyrBco5tCUqFxwcOjEdmnwOlJus4+sSz4ySVdu/G/q6THSvsu+MijGqnaBzqsmUAbKBW88MfukA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=d9xwTPFzPSjBozLaD4wfcBI1aCKqRm6YHvORToI11oxKv90OCgGUv6rawfO6oYG80xhfieGCpvWC2JPMT+4mwS1Cb+k7gqKrtIc4RehJgD8E9QtUFzQorKlMPxinUhJ4ZQ1x759oEBEo7iUmKgLuAi23JopiOdTevWtbe14lyqnOmeICywp0pKLwOB3FAdymN5+XQycXInqh85SCeB6SJ+b0GitJyf8EKGyXMV02QMIvyc5GSU3vtpE/C/enqrN2xxW2kZOdvg3bZJyBufyTsJbYykqhVONcD6r1k+yrFOchXwPvRHoJasBDONGU6/ORrHDicThniS/UVi75CdbJWA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H/V5LQuDz+VHz3va2wcq5Ua91tNkssFUmJdsCuF8gSOptxuRDQxQ2fBPxH/0FlZz4/ZnwDsEbnlSDt//iGhetot55MA9TfnlqkWLx6RLx/fSLkcUPBRxcT45mTttPrae6D4J+f2MppOCh2l+y6ncFpRIoTAtJjrXz23KzXlHdFVxroGVhqofu7rG4eHjIK4qxNW1cfI1tLNgim9/kX9e4ROmFD9u6uKcB0aMCS8DI7ftBJzcngQagn1cStCMPgNu7NqPmXBzKJNzT8RGHmp7jTDyjHKrk6RsKJe8egRDYtmNZ7xN/iouSOy91PpbLwRQAYnH01x/nGGT+cKxFa0gGg==
  • 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>, Jan Beulich <jbeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 17 May 2022 06:24:45 +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: AQHYZBWotDDYRSpFwES4i4qLUHUim60h3YOAgAC/qjA=
  • Thread-topic: [PATCH v4 6/6] xen: retrieve reserved pages on populate_physmap

Hi Julien

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Tuesday, May 17, 2022 2:29 AM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>;
> Jan Beulich <jbeulich@xxxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>;
> Wei Liu <wl@xxxxxxx>
> Subject: Re: [PATCH v4 6/6] xen: retrieve reserved pages on populate_physmap
> 
> Hi Penny,
> 
> On 10/05/2022 03:27, Penny Zheng wrote:
> > When static domain populates memory through populate_physmap on
> > runtime,
> 
> Typo: s/when static/when a static/ or "when static domains populate"
> 
> s/on runtime/at runtime/
> 

Sure, 

> > other than allocating from heap, it shall retrieve reserved pages from
> 
> I am not sure to understand the part before the comma. But it doens't sound
> necessary so maybe drop it?
>  

Sure,

> > resv_page_list to make sure that guest RAM is still restricted in
> > statically configured memory regions. And this commit introduces a new
> > helper acquire_reserved_page to make it work.
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> 
> [...]
> 
> > diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index
> > 290526adaf..06e7037a28 100644
> > --- a/xen/common/page_alloc.c
> > +++ b/xen/common/page_alloc.c
> > @@ -2740,8 +2740,8 @@ static struct page_info * __init
> acquire_staticmem_pages(mfn_t smfn,
> >    * 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)
> > +int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int
> nr_mfns,
> > +                            unsigned int memflags)
> >   {
> >       struct page_info *pg;
> >
> > @@ -2769,12 +2769,43 @@ int __init acquire_domstatic_pages(struct
> > domain *d, mfn_t smfn,
> >
> >       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;
> > +    mfn_t smfn;
> > +
> > +    /* Acquire a page from reserved page list(resv_page_list). */
> > +    page = page_list_remove_head(&d->resv_page_list);
> Alloc/free of memory can happen concurrently. So access to rsv_page_list
> needs to be protected with a spinlock (mostly like d->page_alloc_lock).
>

Oh, understood, will fix.
 
> > +    if ( unlikely(!page) )
> > +        return INVALID_MFN;
> > +
> > +    smfn = page_to_mfn(page);
> > +
> > +    if ( acquire_domstatic_pages(d, smfn, 1, memflags) )
> 
> I am OK if we call acquire_domstatic_pages() for now. But long term, I think 
> we
> should consider to optimize it because we know the page is valid and belong
> to the guest. So there are a lot of pointless work (checking mfn_valid(),
> scrubbing in the free part, cleaning the cache...).
> 

I'm willing to fix it here since this fix is not blocking any other patch 
serie~~
I'm considering that maybe we could add a new memflag MEMF_xxx, (oh,
Naming something is really "killing" me), then all these pointless work, 
checking
mfn_valid, flushing TLB and cache, we could exclude them by checking
memflags & MEMF_xxxx.
Wdyt?

> > +    {
> > +        page_list_add_tail(page, &d->resv_page_list);
> > +        return INVALID_MFN;
> > +    }
> > +
> > +    return smfn;
> > +}
> >   #else
> >   void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
> >                             bool need_scrub)
> >   {
> >       ASSERT_UNREACHABLE();
> >   }
> > +
> > +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags)
> > +{
> > +    ASSERT_UNREACHABLE();
> > +    return INVALID_MFN;
> > +}
> >   #endif
> >
> >   /*
> > diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index
> > 35dc7143a4..c613afa57e 100644
> > --- a/xen/include/xen/domain.h
> > +++ b/xen/include/xen/domain.h
> > @@ -38,6 +38,10 @@ void arch_get_domain_info(const struct domain *d,
> >   #define CDF_staticmem            (1U << 2)
> >   #endif
> >
> > +#ifndef is_domain_using_staticmem
> > +#define is_domain_using_staticmem(d) ((void)(d), false) #endif
> > +
> >   /*
> >    * Arch-specifics.
> >    */
> > diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index
> > 9fd95deaec..74810e1f54 100644
> > --- a/xen/include/xen/mm.h
> > +++ b/xen/include/xen/mm.h
> > @@ -92,6 +92,7 @@ void free_staticmem_pages(struct page_info *pg,
> unsigned long nr_mfns,
> >   int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int
> nr_mfns,
> >                               unsigned int memflags);
> >   #endif
> > +mfn_t acquire_reserved_page(struct domain *d, unsigned int memflags);
> >
> >   /* Map machine page range in Xen virtual address space. */
> >   int map_pages_to_xen(
> 
> Cheers,
> 
> --
> Julien Grall

 


Rackspace

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