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

RE: [PATCH v4 1/6] xen: do not free reserved memory into heap


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Wed, 18 May 2022 06:06:28 +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=uOwbzjpRJ+EbpJgJypJC8xojlw87UhBhAXL0xI1+Dpg=; b=fs2qMuqm4A6fhTarXCBfLnz0JuWUxSc/HAHDt5mT+7aa5GYku3cV9M2l0ws+7VOKYgfQuTuGPPkW37Y/s52meCSI8VibTSksvrEh6luJSd0UlPk/3YPJGMX8BIKW7GNkSQkPvIf6iBBdNe3wQXdiDO1Uy9QyRJ5aX1aQxpvOdZpxYdoh+o37pP/9dsoH/YL3kmOy+ZxGKRSN9rRbP8e6fIt/fEUTAere+9zdMCDNLzkFWkS0x4vGICzIQgpOsUKXS6m9mOHMDVeTb/EhenrlgZYbdAQVUSSjjo9vYK8JRL8ampMogIfak84ZJ3lazgYDofBhQhaPN0XuwcLZqwu1Uw==
  • 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=uOwbzjpRJ+EbpJgJypJC8xojlw87UhBhAXL0xI1+Dpg=; b=IhB+mFo3sFG54Tn+rocQT9ekM1s4mSVdgzRTXi2DpKD1s4vgoszC4FUiLMUaMHQWfSvJF5TsiSttTREVyieJrQXl5NWR2qaf7raia36pkUUO4cEkwU9RoMFqHPgNltkd92YIaWAE18mzaq/3w42gCVC/EyiI6ruGVTeEv/lX9XzBCKV1PoHp8HBH8g3z/e+/c0emesJJxtGOK/dqkFvNepC9sAfthckkFnLtARO7S5RIyobD5HBQFDV9KVzzLUwPrY1rdoL+ATZgzu5pYxEkRtjx+noQCqolLKLbyys8Upx3whMuyoaicH/xyAZ5FqL+WhDX+kNtFwx+9YncXbR2cA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=gbHlm5I0XToWNaE/UuOLOMG8dW8eL7p2siNWiJh/XaZWJj5O706hrt2Dyc06kVU0mntf3J5UWDBK8mrdg+h0F6Pu4PvXjRYwOjaYQJOHcnuYInb4C7dur0nDtZnlR66oBpN2ngwxrZwwJMAoAi4VATDnR8v3EqdgtrISUxPTCz7ejifLHtdgCh/mGVxikZwvCbdBdJ5u13E2dD6NSgcw1PzK+OAuKhXjOO1DJnyKh4TNIcTSr+3JjRFDNLenDXlYIt6WfkIxRH8LAtwTHDk+rMGb32/Bn44/as6vSK4xVD+Rprag4rugvxGUon8Dr0pcyNaP6HOx1kfnsykGvpV2EQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JbBI9XjxDVEb6OQcY77PuX8mhyr4m53ympX5XPRuZyyr1/3d2yzwqPryWeIj2+ubPYm0bKS+V93WK69GErsGnsUvBVXbzF/KkiRbnfV/q/45BWIsMZrNC0NKwUbNKHxXfnAgAehi9Y/C8fnbkk7/fzsXWLXH2cE5z49wGvwzQAOgbYkmIKfXlvULVjqftnbRt6a5/smQj19JYTqMewqwYXuS+V83J5e4T9j5eSbGyMjPGWDyu1+FxoO1ja92ulR4CkVU/1j+r1/7ukVj5ywMTcOvjl0e3xQJsC6Z+KIMi0q7c/P8H/GHJWCgoFSePg7GXLRNpB7m7Z6BIypLUeeMTQ==
  • 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: Wed, 18 May 2022 06:06: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: AQHYZBWe/uxRZBdW10mDRgQaF95/K60h1bOAgADQseCAADJ5AIABLJMQ
  • Thread-topic: [PATCH v4 1/6] xen: do not free reserved memory into heap

Hi Julien

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Tuesday, May 17, 2022 5:29 PM
> 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 1/6] xen: do not free reserved memory into heap
> 
> Hi,
> 
> On 17/05/2022 09:21, Penny Zheng wrote:
> > Yes,  I remembered that asynchronous is still on the to-do list for static
> memory.
> >
> > If it doesn't bother too much to you, I would like to ask some help on this
> issue, ;).
> > I only knew basic knowledge on the scrubbing,
> My kwnoledge on the scrubbing code is not much better than yours :).
> 
> > I knew that dirty pages is placed at the
> > end of list heap(node, zone, order) for scrubbing and "first_dirty" is used 
> > to
> track down
> > the dirty pages. IMO, Both two parts are restricted to the heap thingy,  not
> reusable for
> > static memory,
> 
> That's correct.
> 
> > so maybe I need to re-write scrub_free_page for static memory, and also
> > link the need-to-scrub reserved pages to a new global list e.g.  
> > dirty_resv_list
> for aync
> > scrubbing?
> 
> So I can foresee two problems with scrubbing static memory:
>    1) Once the page is scrubbed, we need to know which domain it belongs
> so we can link the page again
>    2) A page may still wait for scrubbing when the domain allocate
> memory (IOW the reserved list may be empty). So we need to find a page
> belonging to the domain and then scrubbed.
>

Understood, thanks for the to-the-point instruction! ;)
For scrubbing on runtime, un-populating memory will free reserved pages
to reserved list, then async scrubbing will move them to a per-domain list. 
Later
when scrubbing is finished, we need to again move it back to the reserved
list.
And if we failed on acquiring a page from reserved list, then trying to get a 
page
from the per-domain list and scrub it. 

And with initial scrubbing, since the concept of domain is not constructed, a
global list is better.
Right now, we always allocate static memory from specified starting address,
so just make sure that page is scrubbed before allocation.

> The two problems above would indicate that a per-domain scrub list would
> be the best here. We would need to deal with initial scrubbing
> differently (maybe a global list as you suggested).
> 
> I expect it will take some times to implement it properly. While writing
> this, I was wondering if there is actually any point to scrub pages when
> the domain is releasing them. Even if they are free they are still
> belonging to the domain, so scrubbing them is technically not necessary.
> 

True, true, if static memory used as guest memory, even if they are free, they 
are still
belonging to the domain. Even as static shared memory, it is pre-configured in 
boot-time
and could not be used for any other purpose.
Hmmm, may I ask that if we reboot the domain and didn't scrub the pages before, 
the
old stale contents will not affect the rebooting machine?
Or it should be the guest's responsibility to do the cleaning up before using 
it?

If it is the guest's responsibility, yeah, maybe scrubbing them is technically 
not
necessary, flushing TLB and cleaning cache is enough~ So should I remove the 
scrubbing
totally for static memory?

> Any thoughts?
> 
> >>>    {
> >>>        mfn_t mfn = page_to_mfn(pg);
> >>>        unsigned long i;
> >>> @@ -2653,7 +2657,8 @@ void __init free_staticmem_pages(struct
> page_info
> >> *pg, unsigned long nr_mfns,
> >>>            }
> >>>
> >>>            /* In case initializing page of static memory, mark it 
> >>> PGC_reserved. */
> >>> -        pg[i].count_info |= PGC_reserved;
> >>> +        if ( !(pg[i].count_info & PGC_reserved) )
> >>
> >> NIT: I understand the flag may have already been set, but I am not
> convinced if
> >> it is worth checking it and then set.
> >>
> >
> > Jan suggested that since we remove the __init from free_staticmem_pages,
> it's now in preemptable
> > state at runtime, so better be adding this check here.
> 
> Well, count_info is already modified within that loop (see
> mark_page_free()). So I think the impact of setting PGC_reserved is
> going to be meaningless.
> 
> However... mark_page_free() is going to set count_info to PGC_state_free
> and by consequence clear PGC_reserved. Theferore, in the current
> implementation we always need to re-set PGC_reserved.
> 
> So effectively, the "if" is pointless here.
> 
> Cheers,
> 
> --
> Julien Grall

 


Rackspace

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