[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4FC38992.8070408@redhat.com>
Date: Mon, 28 May 2012 17:20:02 +0300
From: Avi Kivity <avi@...hat.com>
To: Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
CC: Marcelo Tosatti <mtosatti@...hat.com>,
LKML <linux-kernel@...r.kernel.org>, KVM <kvm@...r.kernel.org>,
Andrea Arcangeli <aarcange@...hat.com>
Subject: Re: [PATCH] KVM: MMU: fix huge page adapted on non-PAE host
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists