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

On 05/28/2012 05:32 PM, Andrea Arcangeli wrote:
> Hi,
> 
> On Mon, May 28, 2012 at 04:53:38PM +0300, Avi Kivity wrote:
>> As far as I can tell __get_user_pages_fast() will take the reference
>> count in the page head in the first place.
> 
>     mask = KVM_PAGES_PER_HPAGE(level) - 1;
> 
> The BUG would trigger if the above KVM mask is 2M (that is the NPT/EPT
> pmd size), but the hugepage size in the host is 4M (noPAE 32bit).
> 
> The refcount is taken only in the head page for heads, and in both for
> tails.
> 
> Because we've mmu notifier, we never keep the pages mapped by sptes
> refcounted, we drop them all. So all we need to do is just to move the
> refcount on the same exact pfn that is then freed by mmu_set_spte
> (kvm_release_pfn_clean at the end).
> 
> The adjustement is not done for the refcounting, the issue here is, we
> want to adjust the "pfn" passed to mmu_set_spte, and in turn we've to
> move the refcounting too, because the kvm_release_pfn_clean will run
> on that "pfn" (not on the pfn returned by gup-fast anymore).
> 
> So it looks fine to just do get_page and the patch looks correct (not
> sure if the mmio the mmio check is needed or if we can just do
> get_page) as long as the "pfn" that is returned through &pfn parameter
> and then passssed to mmu_set_sptes is the same one were we do get_page.
> 
> The reason it was a get_page_unless_zero() is that it wanted to check
> that there was no THP split and the head page was still there. Problem
> is that with a 4M host page size and 2M NTP/EPT pmd size, we need to
> get_page a tail page half of the time, and get_page_unless_zero()
> won't be a correct refcount for tail pages, not equivalent to a full
> get_page.
> 
> Overall the most important thing is that the pfn returned is the
> correct one that matches the alignment of the NPT/EPT hugepmd size,
> the refcounting just closely follows that aligned "pfn".

Yes, I see it now.  Adjusting mask is incorrect since we won't have the
same adjustment on release.  I'll apply the patch for 3.5.

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

  reply	other threads:[~2012-05-28 14:40 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
2012-05-28 14:42                   ` Andrea Arcangeli
2012-05-28 14:32               ` Andrea Arcangeli
2012-05-28 14:40                 ` Avi Kivity [this message]
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=4FC38E48.9080701@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 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.