lkml.org 
[lkml]   [2012]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2012-05-28 17:01    [W:1.847 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site