Skip to contentSkip to conversation

memory hotplug for guests?

DISCUSSION Tomasz Chmielewski 5 participants 11 messages Apr 4, 2007 – Apr 5, 2007 10 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

Does KVM allow something like "memory hotplug" for its guests?

For example, lets says you are running several guests, and would like to start yet another one for a while - but have no free memory left.

Obviously, your guests are so important that you don't want to stop them
- so you simply "hotplug remove" memory from a guest that has a lot of free memory left - and start a new guest.

When that new guest is no longer needed, and is stopped, you can "hotplug add" memory to the guest it was previously removed from.

Guest's kernel would of course need to support memory hotplugging, too.

Is it possible with KVM? If not, is such a feature planned?

I noticed it was only mentioned once or twice on the list:

http://article.gmane.org/gmane.comp.emulators.kvm.devel/712/

"Well, the _interface_ supports removing, the implementation does not :)

Everything was written in mind to allow memory hotplug."

Signature · 8 lines
Tomasz Chmielewski
http://wpkg.org

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 4613886F.5070408-Nem3ZqsbT/[email protected]

#2 lore raw
Quoted 1 line

Does KVM allow something like "memory hotplug" for its guests?

It does not support.

Quoted 3 lines

For example, lets says you are running several guests, and would like

to

Quoted 2 lines

start yet another one for a while - but have no free memory left.

We have another solution for it that will soon be pushed into the kernel:
It is the balloon driver solution.
Each guest runs a balloon driver, when the host needs to free up memory a daemon with certain policy asks some of the guests to inflate their balloon,
KVM frees their ballooned pages and the host free memory increases. When the memory pressure relives, the balloons get deflate command.

Quoted 2 lines

Obviously, your guests are so important that you don't want to stop

them

Quoted 9 lines

- so you simply "hotplug remove" memory from a guest that has a lot of free memory left - and start a new guest.

When that new guest is no longer needed, and is stopped, you can "hotplug add" memory to the guest it was previously removed from.

Guest's kernel would of course need to support memory hotplugging, too.

Quoted 7 lines

Is it possible with KVM? If not, is such a feature planned?

I noticed it was only mentioned once or twice on the list:

http://article.gmane.org/gmane.comp.emulators.kvm.devel/712/

"Well, the _interface_ supports removing, the implementation does not

:)

Quoted 10 lines

Everything was written in mind to allow memory hotplug."

--
Tomasz Chmielewski
http://wpkg.org

-----------------------------------------------------------------------

--

Quoted 5 lines

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVD

EV

Quoted 4 lines

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 64F9B87B6B770947A9F8391472E032160B318D11-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/[email protected]

#4 lore raw
Quoted 5 lines
Quoted 1 line

For example, lets says you are running several guests, and would like

to

Quoted 2 lines

start yet another one for a while - but have no free memory left.

Quoted 8 lines

We have another solution for it that will soon be pushed into the kernel:
It is the balloon driver solution.
Each guest runs a balloon driver, when the host needs to free up memory a daemon with certain policy asks some of the guests to inflate their balloon,
KVM frees their ballooned pages and the host free memory increases. When the memory pressure relives, the balloons get deflate command.

You probably want to have a look at arch/s390/mm/cmm.c which is exactly doing what you want. Of course the message interface to the hypervisor is different to what you want to do.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 20070405101608.GB8025-Pmgahw53EmNLmI7Nx2oIsGnsbthNF6/[email protected]

#6 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line

For example, lets says you are running several guests, and would

like

Quoted 8 lines
Quoted 8 lines

to

Quoted 2 lines

start yet another one for a while - but have no free memory left.

We have another solution for it that will soon be pushed into the kernel:
It is the balloon driver solution.
Each guest runs a balloon driver, when the host needs to free up

memory

Quoted 8 lines
Quoted 4 lines

a daemon with certain policy asks some of the guests to inflate their balloon,
KVM frees their ballooned pages and the host free memory increases. When the memory pressure relives, the balloons get deflate command.

You probably want to have a look at arch/s390/mm/cmm.c which is exactly doing what you want. Of course the message interface to the hypervisor is different to what you want to do.

Gee, thanks, I wasn't aware of it. I wrote the Linux driver, not yet ready for mainline. This might change things and I'll might use/change the cmm.
It will take a while because my queue is jammed with too much stuff.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 64F9B87B6B770947A9F8391472E032160B319410-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/[email protected]

#8 lore raw
Quoted 16 lines · Dor Laor
Quoted 1 line
Quoted 1 line
Quoted 1 line

For example, lets says you are running several guests, and would

like

Quoted 8 lines
Quoted 8 lines

to

Quoted 2 lines

start yet another one for a while - but have no free memory left.

We have another solution for it that will soon be pushed into the kernel:
It is the balloon driver solution.
Each guest runs a balloon driver, when the host needs to free up

memory

Quoted 5 lines
Quoted 4 lines

a daemon with certain policy asks some of the guests to inflate their balloon,
KVM frees their ballooned pages and the host free memory increases. When the memory pressure relives, the balloons get deflate command.

Quoted 8 lines
Quoted 3 lines

You probably want to have a look at arch/s390/mm/cmm.c which is exactly doing what you want. Of course the message interface to the hypervisor is different to what you want to do.

Gee, thanks, I wasn't aware of it. I wrote the Linux driver, not yet ready for mainline. This might change things and I'll might use/change the cmm.
It will take a while because my queue is jammed with too much stuff.

Another driver you might want to look at is the Xen balloon driver:
http://81.161.245.2/lxr/http/source/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c

The s390 driver is probably a better example though. One thing the Xen one got wrong is that its interface requires you do an hcall in order to get back a page that you gave up to the host. On s390, it simply maps the host empty_zero_page as COW into the guest like the initial memory, so you get a new page back with the regular method whenever you write to the guest real page.

	Arnd <><

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 7 lines · Arnd Bergmann

Another driver you might want to look at is the Xen balloon driver:
http://81.161.245.2/lxr/http/source/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c

The s390 driver is probably a better example though. One thing the Xen one got wrong is that its interface requires you do an hcall in order to get back a page that you gave up to the host.

Er, that's what we do :)

Quoted 5 lines

On s390, it
simply maps the host empty_zero_page as COW into the guest like the initial memory, so you get a new page back with the regular method whenever you write to the guest real page.

This has the advantage of surviving a guest reboot, but the disadvantage of not allowing the host to nack the request.

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


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 4614EE12.7060702-atKUWr5tajBWk0Htik3J/[email protected]

#12 lore raw
Quoted 11 lines
Quoted 3 lines · Arnd Bergmann

Another driver you might want to look at is the Xen balloon driver:
http://81.161.245.2/lxr/http/source/linux-2.6-xen-

sparse/drivers/xen/balloon/balloon.c

Quoted 4 lines

The s390 driver is probably a better example though. One thing the Xen one got wrong is that its interface requires you do an hcall in order to get back a page that you gave up to the host.

Er, that's what we do :)

I don't think it a disadvantage since it's happens rarely. It's not performance sensitive thing.
Never the less it's worth learning/copying from the alternatives.

Currently the only memory-over-commit mechanism is the balloon. In the future we will add all the wise spectrum of host demand pages, shared pages, etc.

Quoted 8 lines
Quoted 6 lines

On s390, it
simply maps the host empty_zero_page as COW into the guest like the initial memory, so you get a new page back with the regular method whenever you write to the guest real page.

This has the advantage of surviving a guest reboot, but the

disadvantage

Quoted 7 lines

of not allowing the host to nack the request.

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

-----------------------------------------------------------------------

--

Quoted 5 lines

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVD

EV

Quoted 4 lines

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 64F9B87B6B770947A9F8391472E032160B31944E-yEcIvxbTEBqsx+V+t5oei8rau4O3wl8o3fe8/T/[email protected]

#14 lore raw
Quoted 3 lines · Dor Laor

Currently the only memory-over-commit mechanism is the balloon. In the future we will add all the wise spectrum of host demand pages, shared pages, etc.

Ok, just as another hint: you should definitely take a look at pfault_interrupt() in arch/s390/mm/fault.c, which manages notifications about host memory manangement, so that the guest can put a task to sleep that accesses a page on the host block device, instead of suspending the entire guest, while waiting for the page to come back.

arch/s390/mm/extmem.c has another very interesting concept, though the hcall interfaces used there are not as flexible as they should be in kvm. It's basically about mapping host files into the guest real address space, e.g. for shared memory between guests.

	Arnd <><

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw
Quoted 7 lines · Arnd Bergmann
Quoted 4 lines · Dor Laor

Currently the only memory-over-commit mechanism is the balloon. In the future we will add all the wise spectrum of host demand pages, shared pages, etc.

Quoted 6 lines

Ok, just as another hint: you should definitely take a look at pfault_interrupt() in arch/s390/mm/fault.c, which manages notifications about host memory manangement, so that the guest can put a task to sleep that accesses a page on the host block device, instead of suspending the entire guest, while waiting for the page to come back.

It's a lot simpler than I would have guessed... this could be quite easily ported to kvm, once we have guest swap.

Quoted 5 lines

arch/s390/mm/extmem.c has another very interesting concept, though the hcall interfaces used there are not as flexible as they should be in kvm. It's basically about mapping host files into the guest real address space, e.g. for shared memory between guests.

This, too, is interesting, though it means guest apps need to be written to take advantage of it.

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


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): 46150835.80700-atKUWr5tajBWk0Htik3J/[email protected]

#18 lore raw
Quoted 8 lines · Avi Kivity
Quoted 5 lines

arch/s390/mm/extmem.c has another very interesting concept, though the hcall interfaces used there are not as flexible as they should be in kvm. It's basically about mapping host files into the guest real address space, e.g. for shared memory between guests.

This, too, is interesting, though it means guest apps need to be written to take advantage of it.

The primary user of this interface is the ext2 file system with the -oxip mount option that can easily share read-only file systems across guests without actually copying files into the page cache of each guest.

Another potential (future) user are cluster file systems like ocfs2 and gfs2, but to be really efficient, these also need a specialized distributed lock manager that communicates through hcalls instead of TCP/IP networking.

Simply mapping the shared memory as a character device is similar enough that applications written for posix shared memory can easily be adapted, but I'm not aware of anyone doing that currently.

	Arnd <><

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

A message that is not in the archive (sent off-list or not yet received): [email protected]

#20 lore raw
Quoted 2 lines · Avi Kivity
Quoted 1 line
Quoted 1 line

arch/s390/mm/extmem.c has another very interesting concept, though

the

Quoted 1 line
Quoted 1 line
Quoted 1 line

hcall interfaces used there are not as flexible as they should be

in

Quoted 6 lines
Quoted 1 line
Quoted 1 line

kvm. It's basically about mapping host files into the guest real

address

Quoted 4 lines
Quoted 2 lines

space, e.g. for shared memory between guests.

This, too, is interesting, though it means guest apps need to be

written

Quoted 3 lines
Quoted 1 line

to take advantage of it.

The primary user of this interface is the ext2 file system with the

-oxip

Quoted 2 lines

mount option that can easily share read-only file systems across guests without actually copying files into the page cache of each guest.

That's nice. Thanks for the tip.

Quoted 3 lines

Another potential (future) user are cluster file systems like ocfs2 and gfs2, but to be really efficient, these also need a specialized

distributed

Quoted 1 line

lock manager that communicates through hcalls instead of TCP/IP

networking.

Quoted 2 lines

Simply mapping the shared memory as a character device is similar

enough

Quoted 1 line

that applications written for posix shared memory can easily be

adapted,

Quoted 3 lines

but I'm not aware of anyone doing that currently.

	Arnd <><

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV