linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [PATCH] KVM: MMU: fix huge page adapted on non-PAE host
Date: Mon, 28 May 2012 17:20:02 +0300	[thread overview]
Message-ID: <4FC38992.8070408@redhat.com> (raw)
In-Reply-To: <4FC3863F.5020902@linux.vnet.ibm.com>

On 05/28/2012 05:05 PM, Xiao Guangrong wrote:
>>>
>>>
>>> I think the reason we move refcount in current code is, we should increase the
>>> refcount of the page we will mapped into shadow page table, since we always
>>> decrease its refcount after it is mapped. (That is this patch does.)
>>>
>> 
>> 
>> As far as I can tell __get_user_pages_fast() will take the reference
>> count in the page head in the first place.
> 
> 
> IIUC, the refcount used in the Compound Page is like this:
> 
> get_user_pages / get_page(page):
> 	head_page = page->first_page;
> 	if (page is not the head page)
> 		page->__mapcount++
> 	head_page->_count++
> 
> 	
> put_page(page):
> 	head_page = page->first_page;
> 	if (page is not the head page)
> 		page->__mapcount--
> 	head_page->_count--
> 

Aha.

The "right thing" we should be doing is running get_page() on every
small page within the frame (we asked for a small page but are
opportunistrically using the pages around it, without a proper ref).
That's a bit slow though, so we cheat.

Maybe we should do it anyway.  Large page maps/unmaps should be rare.

But I guess we can start with your fix.  But what about shifting mask by
one bit?  Isn't it sufficient?

-		mask = KVM_PAGES_PER_HPAGE(level) - 1;
+		mask = KVM_PAGES_PER_HPAGE(level);
+		mask *= KVM_HOST_HPAGES_PER_HPAGE;
+		mask -= 1;

This should move the reference to the right place.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-05-28 14:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-28  6:10 [PATCH] KVM: MMU: fix huge page adapted on non-PAE host Xiao Guangrong
2012-05-28 10:57 ` Avi Kivity
2012-05-28 11:39   ` Xiao Guangrong
2012-05-28 12:24     ` Avi Kivity
2012-05-28 12:56       ` Xiao Guangrong
2012-05-28 13:14         ` Avi Kivity
2012-05-28 13:41           ` Xiao Guangrong
2012-05-28 13:53             ` Avi Kivity
2012-05-28 14:05               ` Xiao Guangrong
2012-05-28 14:20                 ` Avi Kivity [this message]
2012-05-28 14:42                   ` Andrea Arcangeli
2012-05-28 14:32               ` Andrea Arcangeli
2012-05-28 14:40                 ` Avi Kivity
2012-05-28 14:44                   ` Andrea Arcangeli
2012-05-29 14:23                     ` Avi Kivity

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=4FC38992.8070408@redhat.com \
    --to=avi@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=xiaoguangrong@linux.vnet.ibm.com \
    /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).