[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: Julien Grall <julien@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Wed, 29 Jun 2022 03:12:01 +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=kHbnPXx6i6lC9j4Wm1VPjmIcEPajH8+B1X/q2adN1qI=; b=e8GgBkwh9xU1+85nm0E4ZWMsZyLOq+c6CIB0nBaymnRdW5bwDPUlUcU9FkhTguK5zq7cYhHR4ZeFDy9Jan4XaiLoCqTQJ1mT1C/gsM+un8/ayt/7jnvO5WxOvSjzWmZ4GcwoIED7ZCC5k5esytNYc59XTFaQosGm5wqUZ81JZ5pBTvjQZV50uwTaSa8tnvhWP5vGWA9+XC9lLjZCYXEEj69SZrce9ghBM6BhLbUPL+WRm29ZW11suN6T/r5sRjWtn4xAjqFMJXOJKxOL9qsu5Rg2CHXduZA69gKVltmMlXJt5+7SmmXmzu8ZZqqXLLAuR0l348i/iEnJnm1mJ9IgKg==
  • 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=kHbnPXx6i6lC9j4Wm1VPjmIcEPajH8+B1X/q2adN1qI=; b=KsLC/iBW/aUhGJOybX+w+T8R9XLuBVBy1NgsBGwbju80SSfZk4Rv2AsmJHykrH+knlJlPJh6D2RkPJ1gZsXI501zAT0I0iVQ6/ZLRFQdMo2rSdockFG7t9J8mqpSAMSfGpt7gJH9Y7bOloR7+8XKmQb0wQnm4hkCO+tDNRfG7k7cg5I9oUJeyU3gY//d/zTFn4JBxl5xPmz8ogh8k5ByQqJ8g+C5H8gwXEsl8KZCHnyq6OVvpeyYmRLHOkoPfTPhc18t/Dh5poq/XPxqlXFxJ0adYhpq3M3F2m+VlyGiwGIwdydxnz3I5/Zij8CA++8f2fGlLzxQKFS8Mp7dntbEeA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=jhKD6DaZfbgmGdPnaT1Wv3iAfb8muvii8onRbv+ffL2NxvO055qmiFz5FWOlW0qQxv6TB8ImR3Rg9MMofR0Zoyb0gPD6m+SNfSBIto3n4K7Vgif3GtTTiOL+7UISmd7u7EA41SP4vZJqlqU2pYpmbjLKcnoX+//dDJF83MFbtgF1eoYWmJ0BcAZGT+7ANbt0HB4xqFlzsqE/Iemqkc8SWeguiTelTPmBR4YJkv1ytWKkr/x8yrUXw+OjE2pZW6NnbGzqHJ/LrFhsILL05DYERb1PK4osJChBi7VDn8bucbQdgWYEJpOhPaOW2OcdvR29EPzsK9bhZdS5lEIz4LEMmg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XWFHPXnbGpMVGTzX5cZozjJECZmWrZz7rfP+m6deyZA2a6/UI38jyobjB0EtgoGS0QnImaJfiIzQDU2qnKYFbdsyQy9Fc3uCdDY8sFUPferIOEXoiJAS5jrSHGY1pR9o3eksS67fr2eihUcq21bD1wMJV1GsbgI586GQ2ZSVp4e2M+6iw5f5DcSzW7dOGWcUPJLUUurCvmgUwQLNMm6IXSd/Vu4qb8eLowv8A0ZSoiNdPXZvo0HzfJg7uIstjuZRORXo7MkIYKRoXsjypeMhkyWzcCnUWRk0LgdX2MrG30JRtbTL00NUn43+8HbsL6Z7kahFS16/3D+XgaPbalyfIA==
  • 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>
  • Delivery-date: Wed, 29 Jun 2022 03:12:25 +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/FRuoXPvvK9EWAAAtCUPIrtq1bKxqAgAfcEECAAA7bAIACoRkg
  • Thread-topic: [PATCH v7 7/9] xen/arm: unpopulate memory when domain is static

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? 

> Cheers,
> 
> --
> Julien Grall

 


Rackspace

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