Skip to contentSkip to conversation

Need info on guest swapping and other things in KVM

DISCUSSION Arjun 2 participants 4 messages Apr 5, 2008 – Apr 7, 2008 KVM

lore
Share & tools
lore

Arjun

author
#0 lore raw

Hi Folks,

A fellow student and I wish to do run some experiments with KVM. Specifically, we would like to examine
KVM's guest paging/swapping mechanism, make some changes and run some tests. After a brief search through
the docs and code, we would greatly appreciate help with the following:

1) Guest Paging : What is the selection mechanism used by KVM for evicting a guest's page ?
What if there are any conflicts between host and guest as to which page to evict ?

2) Where can we find the code for the above (guest paging).

3) Are the KVM guests scheduled by the (hosts) standard linux scheduler ? It appears that this
is the case but I want to be sure.

4) Have there been any changes to the host's page/buffer cache ? Are there any changes planned ?

Thanks in advance
Arjun

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#1 lore raw
Quoted 10 lines · Arjun

Hi Folks,

A fellow student and I wish to do run some experiments with KVM. Specifically, we would like to examine
KVM's guest paging/swapping mechanism, make some changes and run some tests. After a brief search through
the docs and code, we would greatly appreciate help with the following:

1) Guest Paging : What is the selection mechanism used by KVM for evicting a guest's page ?

With mmu notifiers (not yet merged), pages are picked by the normal Linux LRU mechanism.

Quoted 3 lines

What if there are any conflicts between host and guest as to which page to evict ?

I don't understand this question.

Quoted 1 line

2) Where can we find the code for the above (guest paging).

It's the normal Linux swapping code.

Quoted 4 lines

3) Are the KVM guests scheduled by the (hosts) standard linux scheduler ? It appears that this
is the case but I want to be sure.

Yes.

Quoted 4 lines

4) Have there been any changes to the host's page/buffer cache ? Are there any changes planned ?

Yes, mmu notifiers. This doesn't change pagecache, but rather allows kvm's shadow mmu to be synchronized to the main Linux mmu, which is what allows page eviction and page aging to work.

Signature · 8 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
author
#2 lore raw

Avi,
Thanks for your response.

Regarding the query on "Guest Swapping", I'm referring to the mechanism that the KVM host can use to swap out a guest's pages. Since a guest OS will have its own swapping mechanism, then how will the host ensure that if it choses to swap out a guest's page, it will not conflict with the guest's own swapping mechanism.
Put another way: I understand (from docs, mailing list etc.) that KVM allows the host to overbook/overcommit physical memory via the guest swapping mechanism. i.e. the guest thinks it has x number of physical pages but actually the host has swapped out some of the guests pages and given the freed up physical memory to another guest VM. So the guest actually has less than x pages in physical memory but doesn't know it.

It possible that my understanding of the way KVM works may be incorrect, in that case any clarifications would be appreciated.

Thanks again
Arjun

Quoted 41 lines · Avi Kivity
Quoted 11 lines · Arjun

Hi Folks,

A fellow student and I wish to do run some experiments with KVM. Specifically, we would like to examine
KVM's guest paging/swapping mechanism, make some changes and run some tests. After a brief search through
the docs and code, we would greatly appreciate help with the following:

1) Guest Paging : What is the selection mechanism used by KVM for evicting a guest's page ?

With mmu notifiers (not yet merged), pages are picked by the normal Linux LRU mechanism.

What if there are any conflicts between host and guest as to which page

Quoted 3 lines

to evict ?

I don't understand this question.

2) Where can we find the code for the above (guest paging).

Quoted 1 line

It's the normal Linux swapping code.

Quoted 4 lines

3) Are the KVM guests scheduled by the (hosts) standard linux scheduler ? It appears that this
is the case but I want to be sure.

Yes.

Quoted 4 lines

4) Have there been any changes to the host's page/buffer cache ? Are there any changes planned ?

Quoted 8 lines

Yes, mmu notifiers. This doesn't change pagecache, but rather allows kvm's shadow mmu to be synchronized to the main Linux mmu, which is what allows page eviction and page aging to work.

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

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#3 lore raw

Please don't top-post.

Quoted 16 lines · Arjun

Avi,
Thanks for your response.

Regarding the query on "Guest Swapping", I'm referring to the mechanism that the KVM host can use to swap out a guest's pages. Since a guest OS will have its own swapping mechanism, then how will the host ensure that if it choses to swap out a guest's page, it will not conflict with the guest's own swapping mechanism.
Put another way: I understand (from docs, mailing list etc.) that KVM allows the host to overbook/overcommit physical memory via the guest swapping mechanism. i.e. the guest thinks it has x number of physical pages but actually the host has swapped out some of the guests pages and given the freed up physical memory to another guest VM. So the guest actually has less than x pages in physical memory but doesn't know it.

The guest and host swapping algorithms are completely independent. It is quite possible for the host to select an incorrect page (from a performance point of view) for swapping.

There is a proposal (search for "CMM2") to allow cooperation between guest and host in this area.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone