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

RE: [PATCH v7 7/9] xen/arm: unpopulate memory when domain is static


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Wed, 29 Jun 2022 06:08:51 +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=FAELKJo0AWpheEOWeZU4t88zp0j0ouqU4liKC/e+OrU=; b=ipnwt0olG2UuY0MiRUx5OW1OXBC7BPpdObaMft1o/4DUjPLFDc6E6PJwt/a0/GHIrKBx8fd7ZqGmPvyM4bsLAbd9RoXBeD+aDadbzJGT/YvFfH2LfK/86YqHHx9p8rUljvG5xfdQxP47Si2waf55tAjceGsiyvfXi62ZFyMb8Xk2scv9Ymw6ppKKj8FxweZd4Otg1jlniKfWGnry4rH/Qa2mU5PdPaesjF0bGLb1BqNpjB6LnI5mWKaPbQDhhyRIx2Fg2RCLqe16KJVZjHBLNsYAneWKVSSSxLQTBlR50VHFpti41BQ9dC2LZqF8SpLwyBb15/Wygyx0WG7jowJLqw==
  • 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=FAELKJo0AWpheEOWeZU4t88zp0j0ouqU4liKC/e+OrU=; b=i49pvj4xdiXr842NnVy27v8P2e1tXdk4lTDnB4pLyL1lNNpmQg/LG2VsulW3H0odrYrSXyWMEYEI5bCNnxsBIDCd/gmP4HsCKSvixuQkKR7g4pyYKVnTW0ap1lO6lNNn4SPWxIOHYQd1u7M7FPRgvEO2m3xM2URsLxt+x0jo/gkszv2JkjWtDHM2u8vFt7wMuORdSx3n4CQ982W59/9OuxqtEFeT3OH0NiwX0IUbh2wGRh7+qyk9O4VBFpnBWYMxh1/EZXVGFkpnD1eGi/wBVmiDM5csa+LHJwiEce/pOjOyJmmXuyxLV6qsyfxVRtyiP9I7tqjviV6YTAXp7q7x8A==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=gQ1VemotP6HLPmNrrXRzYbcxg/9Iynt+8ErCxUxdGHjJ1nAKt9SEeSzwy25pL9xH3jOP5KTodef5XRAWxjt4xhorr9OynXzUrFqOOAjWPYviNZlH4hDGVoxB3nrNQcom8LNQO7fdIQJM+WM8JupY2za7wJgkDzDz9+DU5+W68Y+SKwFGK4i1q5PNRF1PKWQPjHZy+s10rMirPfCEMNsW4bZ0JrOTXDfb9uBsqq5Owlokpt78SGI3My5Pa5zwMeDyZybN1Zgp93WHcbR0QKJztWd/bYQMcN1C9HqPLmErpRgMDAhzeERJE0abnXXJTjeRoMEOB3HYyQvLGPm+ai47jA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/hNO7aJPZMgDgZp6EucuqjkiHN3Q7eO8F6zHw7LUFqams44yy3VN40SeT3xwoLU3J8for0AwYTjqIqFpv3u+5BxM3MlWTUqNJWRUMvD0jLhi45BkhoP+iDE2Es49NJjzWlc4drPRh8ohmO2cT4+JdP2qq5sdwhwSFkjJ1zDVwfsGNP3aTvvBiu9RraPc6N9KYsJz2gzWT61RH2g0njQ42uuOMPkOO7RzixheT55re+GII+Y2ryngDqQK1Ai3UkOyeeUQE0+eKyvd5+xHpnpCEJfTxjd2U7vkRYApXFKKPzd+Q+yIDP8KMLMJ206UhNqFVyUWRUs0Z5Xunmfv3nRNg==
  • 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Wed, 29 Jun 2022 06:09:11 +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: AQHYhE/FRuoXPvvK9EWAAAtCUPIrtq1bKxqAgAfcEECAAA7bAIACoRkggAA58ICAAACkIA==
  • Thread-topic: [PATCH v7 7/9] xen/arm: unpopulate memory when domain is static

Hi Jan

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Wednesday, June 29, 2022 1:56 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; George Dunlap <george.dunlap@xxxxxxxxxx>;
> Stefano Stabellini <sstabellini@xxxxxxxxxx>; Wei Liu <wl@xxxxxxx>; xen-
> devel@xxxxxxxxxxxxxxxxxxxx; Julien Grall <julien@xxxxxxx>
> Subject: Re: [PATCH v7 7/9] xen/arm: unpopulate memory when domain is
> static
> 
> On 29.06.2022 05:12, Penny Zheng wrote:
> > Hi Julien and Jan
> >
> >> -----Original Message-----
> >> From: Julien Grall <julien@xxxxxxx>
> >> Sent: Monday, June 27, 2022 6:19 PM
> >> To: Penny Zheng <Penny.Zheng@xxxxxxx>; Jan Beulich
> >> <jbeulich@xxxxxxxx>
> >> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Andrew Cooper
> >> <andrew.cooper3@xxxxxxxxxx>; George Dunlap
> >> <george.dunlap@xxxxxxxxxx>; Stefano Stabellini
> >> <sstabellini@xxxxxxxxxx>; Wei Liu <wl@xxxxxxx>; xen-
> >> devel@xxxxxxxxxxxxxxxxxxxx
> >> Subject: Re: [PATCH v7 7/9] xen/arm: unpopulate memory when domain
> is
> >> static
> >>
> >>
> >>
> >> On 27/06/2022 11:03, Penny Zheng wrote:
> >>> Hi jan
> >>>
> >>>> -----Original Message-----
> >>> put_static_pages, that is, adding pages to the reserved list, is
> >>> only for freeing static pages on runtime. In static page
> >>> initialization stage, I also use free_statimem_pages, and in which
> >>> stage, I think the domain has not been constructed at all. So I
> >>> prefer the freeing of staticmem pages is split into two parts:
> >>> free_staticmem_pages and put_static_pages
> >>
> >> AFAIU, all the pages would have to be allocated via
> >> acquire_domstatic_pages(). This call requires the domain to be
> >> allocated and setup for handling memory.
> >>
> >> Therefore, I think the split is unnecessary. This would also have the
> >> advantage to remove one loop. Admittly, this is not important when
> >> the order 0, but it would become a problem for larger order (you may
> >> have to pull the struct page_info multiple time in the cache).
> >>
> >
> > How about this:
> > I create a new func free_domstatic_page, and it will be like:
> > "
> > static void free_domstatic_page(struct domain *d, struct page_info
> > *page) {
> >     unsigned int i;
> >     bool need_scrub;
> >
> >     /* 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;
> >
> >     free_staticmem_pages(page, 1, need_scrub);
> >
> >     /* Add page on the resv_page_list *after* it has been freed. */
> >     put_static_page(d, page);
> >
> >     drop_dom_ref = !domain_adjust_tot_pages(d, -1);
> >
> >     spin_unlock_recursive(&d->page_alloc_lock);
> >
> >     if ( drop_dom_ref )
> >         put_domain(d);
> > }
> > "
> >
> > In free_domheap_pages, we just call free_domstatic_page:
> >
> > "
> > @@ -2430,6 +2430,9 @@ void free_domheap_pages(struct page_info *pg,
> > unsigned int order)
> >
> >      ASSERT_ALLOC_CONTEXT();
> >
> > +    if ( unlikely(pg->count_info & PGC_static) )
> > +        return free_domstatic_page(d, pg);
> > +
> >      if ( unlikely(is_xen_heap_page(pg)) )
> >      {
> >          /* NB. May recursively lock from relinquish_memory(). */ @@
> > -2673,6 +2676,38 @@ void free_staticmem_pages(struct page_info *pg,
> > unsigned long nr_mfns, "
> >
> > Then the split could be avoided and we could save the loop as much as
> possible.
> > Any suggestion?
> 
> Looks reasonable at the first glance (will need to see it in proper context 
> for a
> final opinion), provided e.g. Xen heap pages can never be static.

If you don't prefer let free_domheap_pages to call free_domstatic_page, then, 
maybe
the if-array should happen at put_page
"
@@ -1622,6 +1622,8 @@ void put_page(struct page_info *page)

     if ( unlikely((nx & PGC_count_mask) == 0) )
     {
+        if ( unlikely(page->count_info & PGC_static) )
+            free_domstatic_page(page);
         free_domheap_page(page);
     }
 }
"
Wdyt now?
 
> 
> Jan

 


Rackspace

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