All of lore.kernel.org
 help / color / mirror / Atom feed
From: Penny Zheng <Penny.Zheng@arm.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Wei Chen <Wei.Chen@arm.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: RE: [PATCH v10 8/9] xen: retrieve reserved pages on populate_physmap
Date: Mon, 5 Sep 2022 07:08:45 +0000	[thread overview]
Message-ID: <AM0PR08MB4530A910E43B82D9B5226F42F77F9@AM0PR08MB4530.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <691b68f0-db68-b400-5473-558583f8dbc1@suse.com>

Hi jan 

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Wednesday, August 17, 2022 6:05 PM
> To: Penny Zheng <Penny.Zheng@arm.com>
> Cc: Wei Chen <Wei.Chen@arm.com>; Andrew Cooper
> <andrew.cooper3@citrix.com>; George Dunlap <george.dunlap@citrix.com>;
> Julien Grall <julien@xen.org>; Stefano Stabellini <sstabellini@kernel.org>;
> Wei Liu <wl@xen.org>; xen-devel@lists.xenproject.org
> Subject: Re: [PATCH v10 8/9] xen: retrieve reserved pages on
> populate_physmap
> 
> On 16.08.2022 04:36, Penny Zheng wrote:
> > @@ -2867,6 +2854,61 @@ int __init acquire_domstatic_pages(struct
> > domain *d, mfn_t smfn,
> >
> >      return 0;
> >  }
> > +
> > +/*
> > + * 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) {
> > +    struct page_info *pg;
> > +
> > +    ASSERT_ALLOC_CONTEXT();
> > +
> > +    pg = acquire_staticmem_pages(smfn, nr_mfns, memflags);
> > +    if ( !pg )
> > +        return -ENOENT;
> > +
> > +    if ( assign_domstatic_pages(d, pg, nr_mfns, memflags) )
> > +        return -EINVAL;
> > +
> > +    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;
> > +
> > +    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);
> 
> Doesn't this need to be !(memflags & MEMF_no_scrub)? And then - with

I got a bit confused about this flag MEMF_no_scrub, does it mean no need
to scrub? 
Since I saw that in alloc_domheap_pages(...)
    if ( assign_page(pg, order, d, memflags) )
    {
        free_heap_pages(pg, order, memflags & MEMF_no_scrub);
        return NULL;
    }
It doesn't contain exclamation mark too...

> assignment having failed and with it being just a single page we're talking
> about, the page was not exposed to the guest at any point afaict. So I don't
> see the need for scrubbing in the first place.
> 
> Also I think the rename of the function would better be done first, since then
> you wouldn't need to touch this line again right in the next patch, and the
> prepare/unprepare pairing would also be visible right here. This would then
> also better fit with the introduction of prepare_*() in the previous patch
> (which, afaic, the name change could also be merged into; FTAOD I don't
> mind it to be separate).
> 
> Jan

  reply	other threads:[~2022-09-05  7:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  2:36 [PATCH v10 0/9] populate/unpopulate memory when domain on static allocation Penny Zheng
2022-08-16  2:36 ` [PATCH v10 1/9] xen/arm: rename PGC_reserved to PGC_static Penny Zheng
2022-08-16  2:36 ` [PATCH v10 2/9] xen: do not free reserved memory into heap Penny Zheng
2022-08-16  6:40   ` Jan Beulich
2022-08-24  9:03     ` Julien Grall
2022-08-24  9:27       ` Juergen Gross
2022-08-24  9:31         ` Julien Grall
2022-08-24  9:38           ` Juergen Gross
2022-08-24 10:42       ` Jan Beulich
2022-08-16  2:36 ` [PATCH v10 3/9] xen: do not merge reserved pages in free_heap_pages() Penny Zheng
2022-08-16  2:36 ` [PATCH v10 4/9] xen: add field "flags" to cover all internal CDF_XXX Penny Zheng
2022-08-16  2:36 ` [PATCH v10 5/9] xen/arm: introduce CDF_staticmem Penny Zheng
2022-08-16  2:36 ` [PATCH v10 6/9] xen: unpopulate memory when domain is static Penny Zheng
2022-08-17  8:51   ` Jan Beulich
2022-08-24  9:12   ` Julien Grall
2022-08-16  2:36 ` [PATCH v10 7/9] xen: introduce prepare_staticmem_pages Penny Zheng
2022-08-16  2:36 ` [PATCH v10 8/9] xen: retrieve reserved pages on populate_physmap Penny Zheng
2022-08-17 10:04   ` Jan Beulich
2022-09-05  7:08     ` Penny Zheng [this message]
2022-09-06  6:33       ` Jan Beulich
2022-09-06  7:14         ` Penny Zheng
2022-09-06  7:19           ` Jan Beulich
2022-08-16  2:36 ` [PATCH v10 9/9] xen: rename free_staticmem_pages to unprepare_staticmem_pages Penny Zheng
2022-08-17 10:07   ` Jan Beulich
2022-08-24  9:54 ` [PATCH v10 0/9] populate/unpopulate memory when domain on static allocation Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR08MB4530A910E43B82D9B5226F42F77F9@AM0PR08MB4530.eurprd08.prod.outlook.com \
    --to=penny.zheng@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.