Re: [PATCH] KVM: MMU: fix huge page adapted on non-PAE host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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 kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[KVM ARM]     [KVM ia64]     [KVM ppc]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux