All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH] slightly consolidate code in free_domheap_pages()
Date: Fri, 20 Jun 2014 14:16:35 +0100	[thread overview]
Message-ID: <53A43433.3070900@citrix.com> (raw)
In-Reply-To: <53A447C9020000780001BF5F@mail.emea.novell.com>


[-- Attachment #1.1: Type: text/plain, Size: 3466 bytes --]

On 20/06/14 13:40, Jan Beulich wrote:
> ... to combine the three scrubbing paths into a single one.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -1724,47 +1724,45 @@ void free_domheap_pages(struct page_info
>  
>          spin_unlock_recursive(&d->page_alloc_lock);
>      }
> -    else if ( likely(d != NULL) && likely(d != dom_cow) )
> +    else
>      {
> -        /* NB. May recursively lock from relinquish_memory(). */
> -        spin_lock_recursive(&d->page_alloc_lock);
> +        bool_t scrub;
>  
> -        for ( i = 0; i < (1 << order); i++ )
> +        if ( likely(d) && likely(d != dom_cow) )
>          {
> -            BUG_ON((pg[i].u.inuse.type_info & PGT_count_mask) != 0);
> -            page_list_del2(&pg[i], &d->page_list, &d->arch.relmem_list);
> -        }
> +            /* NB. May recursively lock from relinquish_memory(). */
> +            spin_lock_recursive(&d->page_alloc_lock);
>  
> -        drop_dom_ref = !domain_adjust_tot_pages(d, -(1 << order));
> -
> -        spin_unlock_recursive(&d->page_alloc_lock);
> +            for ( i = 0; i < (1 << order); i++ )
> +            {
> +                BUG_ON((pg[i].u.inuse.type_info & PGT_count_mask) != 0);
> +                page_list_del2(&pg[i], &d->page_list, &d->arch.relmem_list);
> +            }
> +
> +            drop_dom_ref = !domain_adjust_tot_pages(d, -(1 << order));
> +
> +            spin_unlock_recursive(&d->page_alloc_lock);
> +
> +            /*
> +             * 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.
> +             */
> +            scrub = !!d->is_dying;

d->is_dying is technically protected by d->page_alloc_lock, and one
extra boolean read isn't going to extend the critical region too much.

Unrelated to the content of the patch, I can't see a codepath where we
would relinquish domain memory from a clean shutdown without setting
d->is_dying.  Does this mean that we are even scrubbing pages from
cleanly shut down domains?

~Andrew

> +        }
> +        else
> +        {
> +            ASSERT(!d || !order);
> +            drop_dom_ref = 0;
> +            scrub = 1;
> +        }
>  
> -        /*
> -         * 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.
> -         */
> -        if ( unlikely(d->is_dying) )
> +        if ( unlikely(scrub) )
>              for ( i = 0; i < (1 << order); i++ )
>                  scrub_one_page(&pg[i]);
>  
>          free_heap_pages(pg, order);
>      }
> -    else if ( unlikely(d == dom_cow) )
> -    {
> -        ASSERT(order == 0); 
> -        scrub_one_page(pg);
> -        free_heap_pages(pg, 0);
> -        drop_dom_ref = 0;
> -    }
> -    else
> -    {
> -        /* Freeing anonymous domain-heap pages. */
> -        for ( i = 0; i < (1 << order); i++ )
> -            scrub_one_page(&pg[i]);
> -        free_heap_pages(pg, order);
> -        drop_dom_ref = 0;
> -    }
>  
>      if ( drop_dom_ref )
>          put_domain(d);
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel


[-- Attachment #1.2: Type: text/html, Size: 4364 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-06-20 13:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 12:40 [PATCH] slightly consolidate code in free_domheap_pages() Jan Beulich
2014-06-20 13:16 ` Andrew Cooper [this message]
2014-06-20 14:23   ` Jan Beulich
2014-06-20 14:35     ` Andrew Cooper
2014-06-20 14:43       ` Jan Beulich
2014-06-24 10:04 ` Ian Campbell
2014-06-24 10:25   ` Jan Beulich
2014-06-24 11:27     ` Ian Campbell
2014-06-24 11:53       ` Jan Beulich
2014-06-24 12:10         ` Ian Campbell
2014-06-24 12:25           ` Jan Beulich
2014-06-24 12:35             ` Ian Campbell
2014-06-24 12:36           ` [PATCH v2] " Jan Beulich
2014-06-24 12:37             ` Ian Campbell

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=53A43433.3070900@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@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.