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 16:14:00 +0300	[thread overview]
Message-ID: <4FC37A18.10809@redhat.com> (raw)
In-Reply-To: <4FC37600.1060301@linux.vnet.ibm.com>

On 05/28/2012 03:56 PM, Xiao Guangrong wrote:
> On 05/28/2012 08:24 PM, Avi Kivity wrote:
> 
>> On 05/28/2012 02:39 PM, Xiao Guangrong wrote:
>>> On 05/28/2012 06:57 PM, Avi Kivity wrote:
>>>
>>>> On 05/28/2012 09:10 AM, Xiao Guangrong wrote:
>>>>> The huge page size is 4M on non-PAE host, but 2M page size is used in
>>>>> transparent_hugepage_adjust(), so the page we get after adjust the
>>>>> mapping level is not the head page, the BUG_ON() will be triggered
>>>>>
>>>>>
>>>>> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
>>>>> index 72102e0..be3cea4 100644
>>>>> --- a/arch/x86/kvm/mmu.c
>>>>> +++ b/arch/x86/kvm/mmu.c
>>>>> @@ -2595,8 +2595,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu,
>>>>>  			*gfnp = gfn;
>>>>>  			kvm_release_pfn_clean(pfn);
>>>>>  			pfn &= ~mask;
>>>>> -			if (!get_page_unless_zero(pfn_to_page(pfn)))
>>>>> -				BUG();
>>>>> +			kvm_get_pfn(pfn);
>>>>>  			*pfnp = pfn;
>>>>>  		}
>>>>>  	}
>>>>
>>>> Shouldn't we adjust mask instead?
>>>>
>>>
>>>
>>> Adjusting mask to map the whole 4M huge page to KVM guest?
>> 
>> The code moves the refcount from the small page to the huge page.  i.e.
>> from pfn 0x1312 to pfn 0x1200.  But if the huge page frame contains
>> 0x400 pages, it should move the refcount to pfn 0x1000.
>> 
> 
> 
> We need not move the refcount to the huge page (the head of pages), moving
> the refcount to the any middle small page is also ok, get_page() will
> properly handle it:
> 
> get_page() -> __get_page_tail():
> 
> |	struct page *page_head = compound_trans_head(page);
> |
> |	if (likely(page != page_head && get_page_unless_zero(page_head))) {
> |		/*
> |		 * page_head wasn't a dangling pointer but it
> |		 * may not be a head page anymore by the time
> |		 * we obtain the lock. That is ok as long as it
> |		 * can't be freed from under us.
> |		 */
> |		flags = compound_lock_irqsave(page_head);
> |		/* here __split_huge_page_refcount won't run anymore */
> |		if (likely(PageTail(page))) {
> |			__get_page_tail_foll(page, false);
> |			got = true;
> |		}
> |		compound_unlock_irqrestore(page_head, flags);
> |		if (unlikely(!got))
> |			put_page(page_head);
> |	}
> 
> The refcount of page_head is increased.
> 

So, the whole thing is unneeded?  Andrea?


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

  reply	other threads:[~2012-05-28 13:14 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 [this message]
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
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=4FC37A18.10809@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).