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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Mon, 18 Jul 2022 06:09:06 +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=ECWi0u5Qd/LatKWNWwU26XIJrdW3oc6HoJjq49c6keA=; b=Wx0pqrB0oy7fJmuVx1/9oHHTl4xXMoAUpny6zs+ZdUCa2SbaZJflrRIiMayEzMzxY31zsuclUmeqOdAXy9iGAJrw+LzV2k1565DaTIKdXAE7W60Ve7A2afscx3vappE756wJk7j3HrJQf1fEaptMxqSU9yOmyUtc+0be6LqpbCpF50cNv8hkogpffVPSwRl+lKT4BG+C4mDcV/vIHvNpqMCDe7JDCczDHVCRocRPhODQlJr83kHAkV7Dq9wuf27lGsm7XOSk2uL3i3MlWRfBJUi9pgACzBoqoEK+I43xzlFUeKlL6w2pvlWCazk6NAeKat698Jq0Nska4Tx93fG8Bg==
  • 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=ECWi0u5Qd/LatKWNWwU26XIJrdW3oc6HoJjq49c6keA=; b=WdDpGBKHSHbl2XX7Wc2iOUbyZXdG/GBEALbLTRBQV6jAvJZVcnf1NJPewDklxWnlFNV6x1LTMOAdQlr7VABC/0wzToxDrDBPxSe8SZNQIReDT4A2RTJl8yJq9q3MCmxhjAnleL2GZe8rhTmXFQvvbOfAb/L0fDHBohIDnNrJYxFxqTc17Wu+taJsFUbGn0l6l6dYLME5FWu667+VyWdkBT1eopbZvbceHr7ThP5ESa1ipKPNXGhxATqG2IbjlXIDK47KRdlRXwxkEV8I+1fvMqRVWqDnr8p35p3LkoH79BiRVNMFdMsCBUJ9NJNOfPRAOSDCjBCeh+NsoCBFhcl3rQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=EAO4+/EjOMJCta00dWFrfMTr2C820Ika2ffMzmN8dsKo9LKfbQrg2ijU/OUczpgfGKMWCoV4rniJB8eMZrTImJkJiZwdYcyOPx0t6yBUngLL8p48cs7/7FpQwdIcxEJEbE5qwCYCWRloYBnHNLX5oBK/t6yCvabnhH/SGRQHHyYFXnKpbArVAWAnIPqJ8BsMGD1lJ193jyIQK0PTiiBuC0HWpPgDnRyzhfxCDr71dUZwcWtXErpasr3TctcJl5kZIHHswQcqnhvMEPkr2u3F0gVwEDvQ8GZ6y86Ea8G32+ky6dgb8eW84YYarBavFfJA/Wbg2RgaQP1RzqTqDKwurA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EI+WFRQ1AXbMkccqP9gP/wu4W5QSE+1cZLyhH+0iAzRHvOf/oYyX8S3wUr1dCuzv4MdjTzBT9pU0HTg6Kkonq2bz0+OOGFmTxAOjX0WrrcI03SPM1cy7NvUP8QFmauIAXMyXWeXnp55B0/46rYcLAylLIqsXlEhuocafgjVLVRbNKMXwqEHR47d/9M02g1CgQ2dBgnPYJDIsPnQ6ZaCaMSislkJgq2fcglWarEDJzPeyJ4s4MN6PzjswwR5m8SshxE3M5pM/L7EeQ8J6grJp8SQjilAcRo/+3FKug/URsQ8AxZPUrPQbcNL5mmFFy7IEXWK90nTttmnzobNTblWpXw==
  • 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: Mon, 18 Jul 2022 06:09:29 +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: AQHYkeMzaseZ5YPTu0ykk9py2DMCTK10bf4AgA88QbA=
  • Thread-topic: [PATCH v8 2/9] xen: do not free reserved memory into heap

Hi Jan

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Friday, July 8, 2022 8:48 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 v8 2/9] xen: do not free reserved memory into heap
> 
> On 07.07.2022 11:22, Penny Zheng wrote:
> > --- a/xen/arch/arm/mm.c
> > +++ b/xen/arch/arm/mm.c
> > @@ -1622,6 +1622,8 @@ void put_page(struct page_info *page)
> >
> >      if ( unlikely((nx & PGC_count_mask) == 0) )
> >      {
> > +        if ( unlikely(nx & PGC_static) )
> > +            free_domstatic_page(page);
> >          free_domheap_page(page);
> 
> Didn't you have "else" there in the proposal you made while discussing v7?
> You also don't alter free_domheap_page() to skip static pages.
> 

Yes, "else" is needed

> > @@ -2652,9 +2650,48 @@ void __init free_staticmem_pages(struct
> page_info *pg, unsigned long nr_mfns,
> >              scrub_one_page(pg);
> >          }
> >
> > -        /* In case initializing page of static memory, mark it PGC_static. 
> > */
> >          pg[i].count_info |= PGC_static;
> >      }
> > +
> > +    spin_unlock(&heap_lock);
> > +}
> > +
> > +void free_domstatic_page(struct page_info *page) {
> > +    struct domain *d = page_get_owner(page);
> > +    bool drop_dom_ref, need_scrub;
> > +
> > +    ASSERT_ALLOC_CONTEXT();
> > +
> > +    if ( likely(d) )
> > +    {
> > +        /* NB. May recursively lock from relinquish_memory(). */
> > +        spin_lock_recursive(&d->page_alloc_lock);
> > +
> > +        arch_free_heap_page(d, page);
> > +
> > +        /*
> > +         * Normally we expect a domain to clear pages before freeing them,
> > +         * if it cares about the secrecy of their contents. However, after
> > +         * a domain has died we assume responsibility for erasure. We do
> > +         * scrub regardless if option scrub_domheap is set.
> > +         */
> > +        need_scrub = d->is_dying || scrub_debug || opt_scrub_domheap;
> 
> May I suggest that instead of copying the comment you simply add one here
> referring to the other one? Otoh I'm not sure about the "dying" case: What
> happens to a domain's static pages after its death? Isn't it that they cannot
> be re-used? If so, scrubbing is pointless. And whether the other reasons to
> scrub actually apply to static pages also isn't quite clear to me.
> 

Yes, Julien also raised the same question once before while we have been 
discussing
about how to make the scrubbing static pages asynchronously.

Right now, static memory is either reserved as guest memory or as shared memory,
which both cannot be re-used, so as you said, scrubbing is pointless at the 
moment.

So here I'll only keep the scrub_debug option, as synchronously scrubbing is 
already in
free_staticmem_pages.

> > +        drop_dom_ref = !domain_adjust_tot_pages(d, -1);
> > +
> > +        spin_unlock_recursive(&d->page_alloc_lock);
> > +    }
> > +    else
> > +    {
> > +        drop_dom_ref = false;
> > +        need_scrub = true;
> > +    }
> 
> Why this "else"? I can't see any way unowned paged would make it here.
> Instead you could e.g. have another ASSERT() at the top of the function.
> 

True, true. ASSERT(d) will be added

> Jan

 


Rackspace

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