xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bob Liu <bob.liu@oracle.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Bob Liu <lliubbo@gmail.com>,
	keir@xen.org, ian.campbell@citrix.com
Subject: Re: [PATCH 1/2] tmem: add full support for x86 up to 16Tb
Date: Mon, 23 Sep 2013 21:17:20 +0800	[thread overview]
Message-ID: <52403F60.9070805@oracle.com> (raw)
In-Reply-To: <5240384202000078000F57F2@nat28.tlf.novell.com>

Hi Jan,

Thanks for you review.

On 09/23/2013 06:46 PM, Jan Beulich wrote:
>>>> On 23.09.13 at 04:23, Bob Liu <lliubbo@gmail.com> wrote:
>> tmem used to have code assuming to be able to directly access all memory.
>> This patch try to fix this problem fully so that tmem can work on x86 up to
>> 16Tb.
>>
>> tmem allocates pages mainly for two purposes.
>> 1. store pages passed from guests through the frontswap/cleancache frontend.
>> In this case tmem code has already using map_domain_page() before
>> accessing the memory, no need to change for 16Tb supporting.
> 
> Did you also verify that none of these mappings remain in place
> for undue periods of time?
>

Yes, I think so.

>> 2. store tmem meta data.
>> In this case, there is a problem if we use map_domain_page(). That's the 
>> mapping
>> entrys are limited, in the 2 VCPU guest we only have 32 entries and tmem 
>> can't
>> call unmap in a short time.
>> The fixing is allocate xen heap pages instead of domain heap for tmem meta
>> data.
> 
> Please quantify the amount of Xen heap memory potentially
> getting buried here.
> 

Okay, I'll try to count xen heap pages used here and provide some
statistic result.

> Please also clarify whether reclaiming this memory in fact works
> (i.e. that upon memory pressure the rest of the system can
> be kept alive by tmem giving up this memory in due course).
> 

This memory here can't be reclaimed directly because it's used for meta
data i.e. radix tree node.
But if the tmem data page gets reclaimed during memory pressure, the
corresponding radix tree node will also be freed.
After enough radix tree nodes get freed meta page used here will be
reclaimed.

>> Signed-off-by: Bob Liu <bob.liu@oracle.com>
> 
> The patch is full of coding style violations; in fact there are too
> many of them to list them individually.
> 

Sorry for that, it's my first xen patch.
Is there any document or checkpatch script so that I can get rid of the
coding style problem?

>> @@ -166,38 +167,48 @@ static inline struct page_info *_tmh_alloc_page_thispool(struct domain *d)
>>      if ( d->tot_pages >= d->max_pages )
>>          return NULL;
>>  
>> -    if ( tmh_page_list_pages )
>> -    {
>> -        if ( (pi = tmh_page_list_get()) != NULL )
>> -        {
>> -            if ( donate_page(d,pi,0) == 0 )
>> -                goto out;
>> -            else
>> -                tmh_page_list_put(pi);
>> -        }
>> +    if (xen_heap)
>> +	    pi = alloc_xenheap_pages(0,MEMF_tmem);
>> +    else {
>> +	    if ( tmh_page_list_pages )
>> +	    {
>> +		    if ( (pi = tmh_page_list_get()) != NULL )
>> +		    {
>> +			    if ( donate_page(d,pi,0) == 0 )
>> +				    goto out;
>> +			    else
>> +				    tmh_page_list_put(pi);
>> +		    }
>> +	    }
>> +
>> +	    pi = alloc_domheap_pages(d,0,MEMF_tmem);
>>      }
>>  [...]
>>  static inline void _tmh_free_page_thispool(struct page_info *pi)
>>  {
>>      struct domain *d = page_get_owner(pi);
>> +    int xen_heap = is_xen_heap_page(pi);
>>  
>>      ASSERT(IS_VALID_PAGE(pi));
>> -    if ( (d == NULL) || steal_page(d,pi,0) == 0 )
>> -        tmh_page_list_put(pi);
>> +    if ( (d == NULL) || steal_page(d,pi,0) == 0 ) {
>> +	    if (!xen_heap)
>> +		    tmh_page_list_put(pi);
> 
> Looking at the allocation path above the opposite ought to be
> impossible. Hence rather than if() you want to ASSERT() here.
> 

Thanks, will be fixed.

>> +    }
>>      else
>>      {
>>          scrub_one_page(pi);
>>          ASSERT((pi->count_info & ~(PGC_allocated | 1)) == 0);
>> -        free_domheap_pages(pi,0);
>> +	if (xen_heap)
>> +		free_xenheap_pages(pi,0);
> 
> free_xenheap_page().
> 

Same with those place.

>> +	else
>> +		free_domheap_pages(pi,0);
> 
> free_domheap_page()
> 
>>  static inline void tmh_free_page(struct page_info *pi)
>>  {
>> +    int xen_heap = is_xen_heap_page(pi);
>>      ASSERT(IS_VALID_PAGE(pi));
>> -    tmh_page_list_put(pi);
>> -    atomic_dec(&freeable_page_count);
>> +    if (xen_heap){
>> +	    scrub_one_page(pi);
>> +	    ASSERT((pi->count_info & ~(PGC_allocated | 1)) == 0);
> 
> Did you perhaps copy this from somewhere else without
> understanding why it is needed there? It certainly doesn't look
> necessary here: Such checks are meaningful only when you
> allow a guest access to a Xen heap page.
> 

Sorry, I just copyed this code from _tmh_free_page_thispool().
Sounds like these checks are also unneeded in _tmh_free_page_thispool()?

>> +	    free_xenheap_pages(pi,0);
> 
> free_xenheap_page().
> 
>> +    } else {
>> +	    tmh_page_list_put(pi);
>> +	    atomic_dec(&freeable_page_count);
>> +    }
>>  }
> 
> All that said - I'm not sure we want to accept enhancements to
> tmem without the security audit happening first, which has been
> due for over a year now.
> 

Okay, I'll take a look at it.
Anyway I'll try to make a V2 of this patchset based on your feedbacks.

-- 
Regards,
-Bob

  reply	other threads:[~2013-09-23 13:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23  2:23 [PATCH 1/2] tmem: add full support for x86 up to 16Tb Bob Liu
2013-09-23  2:23 ` [PATCH 2/2] xen: arch: x86: re-enable tmem for system " Bob Liu
2013-09-23  9:36 ` [PATCH 1/2] tmem: add full support for x86 " Andrew Cooper
2013-09-23  9:45   ` Ian Campbell
2013-09-23 10:46 ` Jan Beulich
2013-09-23 13:17   ` Bob Liu [this message]
2013-09-23 13:28     ` Jan Beulich
2013-09-25 20:44   ` Konrad Rzeszutek Wilk

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=52403F60.9070805@oracle.com \
    --to=bob.liu@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=ian.campbell@citrix.com \
    --cc=keir@xen.org \
    --cc=lliubbo@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).