All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Penny Zheng <Penny.Zheng@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Wei Chen <Wei.Chen@arm.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH v4 6/6] xen: retrieve reserved pages on populate_physmap
Date: Tue, 17 May 2022 09:48:37 +0100	[thread overview]
Message-ID: <277cd64d-f3eb-d2ad-d1d4-e293883ca7ef@xen.org> (raw)
In-Reply-To: <DU2PR08MB7325E62AFC9087725D69BA1DF7CE9@DU2PR08MB7325.eurprd08.prod.outlook.com>



On 17/05/2022 07:24, Penny Zheng wrote:
> Hi Julien

Hi Penny,

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

I don't think we need a new flag because the decision is internal to the 
page allocator. Instead, acquire_staticmem_pages() could be split in two 
parts. Something like (function names are random):


static bool foo(struct page_info *pg,
	        unsigned long nr,
	        unsigned long memflags)
{
	spin_lock(&heap_lock);

	for ( i = 0; i < nr; i++ )
		...

	spin_unlock(&heap_lock);

	if ( need_tlbflush )
	  filtered...

  	return true;

out_err:
	for ( ... )
	  ...
	return false;
}

static struct page_info *bar(mfn_t smfn,
			     unsigned long mfn,
			     unsigned int memflags)
{
	ASSERT(nr_mfns);
	for ( i = 0; i < nr_mfns; i++ )
	    if ( !mfn_valid(mfn_add(smfn, i)) )
		return NULL;

	pg = mfn_to_page(mfn);
	if ( !foo(...) )
	  return NULL;

	for ( i = 0; i < nr_mfns; i++ )
		flush_page_to_ram(...);
}


acquire_reserved_page() would then only call foo() and assign_pages().

Cheers,

-- 
Julien Grall


  reply	other threads:[~2022-05-17  8:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10  2:27 [PATCH V4 0/6] populate/unpopulate memory when domain on static Penny Zheng
2022-05-10  2:27 ` [PATCH v4 1/6] xen: do not free reserved memory into heap Penny Zheng
2022-05-16 18:01   ` Julien Grall
2022-05-17  8:21     ` Penny Zheng
2022-05-17  9:28       ` Julien Grall
2022-05-17 16:07         ` Jan Beulich
2022-05-18  6:06         ` Penny Zheng
2022-05-17 16:11   ` Jan Beulich
2022-05-18  2:29     ` Penny Zheng
2022-05-18  6:30       ` Jan Beulich
2022-05-10  2:27 ` [PATCH v4 2/6] xen: do not merge reserved pages in free_heap_pages() Penny Zheng
2022-05-16 17:36   ` Julien Grall
2022-05-10  2:27 ` [PATCH v4 3/6] xen: add field "flags" to cover all internal CDF_XXX Penny Zheng
2022-05-10  2:27 ` [PATCH v4 4/6] xen/arm: introduce CDF_staticmem Penny Zheng
2022-05-10  2:27 ` [PATCH v4 5/6] xen/arm: unpopulate memory when domain is static Penny Zheng
2022-05-10  2:27 ` [PATCH v4 6/6] xen: retrieve reserved pages on populate_physmap Penny Zheng
2022-05-16 18:29   ` Julien Grall
2022-05-17  6:24     ` Penny Zheng
2022-05-17  8:48       ` Julien Grall [this message]
2022-05-17 16:16   ` Jan Beulich

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=277cd64d-f3eb-d2ad-d1d4-e293883ca7ef@xen.org \
    --to=julien@xen.org \
    --cc=Penny.Zheng@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --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.