Skip to contentSkip to conversation

balloon: selfballooning and post memory info via xenbus,

PATCH Dan Magenheimer 4 participants 9 messages May 16, 2008 – Jun 30, 2008 1 message not in the archive

lore
Share & tools
lore

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

#1 lore raw

(Your reply came to me but not to the list... not sure why. So I've attached your full reply below.)

Quoted 1 line

ah ok, that is my failure, I need a bigger swapdisk ;)

Yes, definitely. If you are creating the swapdisk on an ext3 filesystem, you might try using sparse files. They won't take up much disk space unless/until they get swapped-to. There might be some performance ramifications though. (My testing has been with swap disk as a logical volume so I can't try sparse.)

Quoted 8 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server, normal a server needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Exactly what it is intended for!

I'd be interested in how it works for guests with memory=4096 and higher. All of my testing so far has been on a machine with only 2GB of physical memory so I can test lots of guests but no large guests.

Thanks,
Dan

Quoted 208 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, May 16, 2008 9:49 AM
To: [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 5 lines · Dan Magenheimer
Quoted 1 line

thanks for the patch, I was waiting for this feature.

Thanks very much for the testing and feedback! Could you comment on what you plan to use it for? (Keir hasn't accepted it yet, so I am looking for user support ;-)

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server, normal a server needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 5 lines

First question: Do you have a swap (virtual) disk configured and, if so, how big is it? (Use "swapon -s" and the size shows in KB.) Selfballooning shouldn't be run in a domain with no swap disk. Also, how big is your "memory=" in your vm.cfg file?

#kernel = "/boot/xen-3.2.0/vmlinuz-2.6.18.8-xenU" #kernel = "/boot/vmlinuz-2.6.18.8-xenU"
kernel = "/boot/vmlinuz-selfballooning"
memory = 256
maxmem = 8192
vcpu = 4
name = "test.work.de"
vif = [ 'bridge=xenvlan323' ]
disk = [ 'phy:/dev/sda,hda,w', 'file:/var/swap.img,hdb,w' ] root = "/dev/hda ro"
extra = 'xencons=tty'

swap_size = 256M

Quoted 5 lines

I'm not able to reproduce your dd failure at all, even with bs=2047M (dd doesn't permit larger values for bs).
Your program (I called it "mallocmem") does eventually fail for me but not until i==88. However, I have a 2GB swap disk configured.

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 11 lines

I think both tests are really measuring the total virtual memory space configured, e.g. the sum of physical memory (minus kernel overhead) and configured swap space. I think you will find that both will fail similarly with ballooning off and even on a physical system, just at different points in virtual memory usage. Indeed, by adding additional output to mallocmem, I can see that it fails exactly when it attempts to malloc memory larger than the CommitLimit value in /proc/meminfo. I expect the same is true for the dd test.

Quoted 29 lines

Note that CommitLimit DOES go down when memory is ballooned-out from a guest. So your test does point out to me that I should include a warning in the documentation not only that a swap disk should be configured, but also that the swap disk should be configured larger for a guest if selfballooning will be turned on.

Thanks,
Dan

Quoted 20 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: Friday, May 16, 2008 3:36 AM
To: [email protected]
Subject: RE: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

thanks for the patch, I was waiting for this feature.

I've tried this patch and I've seen that if I malloc a great size of memory in time, this fails, but if I malloc a small size first and then resize it slowly, it works.

this highly suffisticated (:p) program I use to test the

ballooning:

Quoted 110 lines
Quoted 108 lines

#include <stdio.h>
#include <unistd.h>

int main () {
void *v;
int i;

  for(i=40; i < 50; ++i) {
    v = malloc((i*32*1024*1024));
    printf("%i\n", i);
    if ( v != NULL) {
      system("cat /proc/xen/balloon");
      sleep(1);
      free(v);
    }

}
}

same effect I've got if I change the blocksize in a dd:

works: dd if=zero of=/test.img count=1 bs=32M doesn't work: dd if=zero of=/test.img count=1 bs=256M

Don't know whether this is the right test for this...

greetings
Torben Viets

Dan Magenheimer wrote

Quoted 38 lines

OK, here's the promised patch. The overall objective of the patch is to enable limited memory load-balancing capabilities as a step toward allowing limited memory overcommit. With this and some other minor hackery, I was able to run as many as 15 lightly loaded 512MB domains on a 2GB system (yes, veerrrryyy slooowwwlly).

Review/comments appreciated.

With this patch, balloon.c communicates (limited) useful memory usage information via xenbus. It also implements "selfballooning" which applies the memory information locally to immediately adjust the balloon, giving up memory when it is not needed and asking for it back when it is needed, implementing a first-come-first-served system-wide ballooning "policy". When a domain asks for memory but none is available, it must use its own configured swap disk, resulting in (potentially severe) performance degradation. Naturally, it is not recommended to turn on selfballooning in a domain that has no swap disk or if performance is more important than increasing the number of VMs runnable on a physical machine.

A key assumption is that the Linux variable vm_committed_space is a reasonable first approximation of memory needed by a domain. This approximation will probably improve over time, but is a good start for now. The variable is bound on the lower end by the recently submitted minimum_target() algorithm patch; thus O-O-M conditions should not occur.

The code is a bit complicated in a couple of places because of race conditions involving xenstored startup relative to turning on selfballooning locally. Because the key variable (vm_committed_space) is not exported by Linux, I implemented a horrible hack which still allows the code to work in a module, however I fully expect that this part of the patch will not be accepted (which will limit the functionality to pvm domains only... probably OK for now).

Quoted 8 lines

Existing balloon functionality which is unchanged:
- Set target for VM from domain0
- Set target inside VM by writing to /proc/xen/balloon Existing balloon info on xenbus which is unchanged:
- /local/domain/X/memory/target
To turn on selfballooning:
- Inside a VM: "echo 1 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 1"

Quoted 3 lines

To turn off selfballooning:
- Inside a VM: "echo 0 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 0"

Quoted 13 lines

New balloon info now on xenbus:
- /local/domain/X/memory/selfballoon [0 or 1]
- /local/domain/X/memory/actual [kB] *
- /local/domain/X/memory/minimum [kB] *
- /local/domain/X/memory/selftarget [kB] * (only valid if selfballoon==1)
* writeable only by balloon driver in X when either selfballooning is first enabled, or target is changed by domain0

Thanks,
Dan

Quoted 6 lines

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

--

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 3 lines · Dan Magenheimer

(Your reply came to me but not to the list... not sure why. So I've attached your full reply below.)

thanks, hope this time it works....

Quoted 20 lines
Quoted 3 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Yes, definitely. If you are creating the swapdisk on an ext3 filesystem, you might try using sparse files. They won't take up much disk space unless/until they get swapped-to. There might be some performance ramifications though. (My testing has been with swap disk as a logical volume so I can't try sparse.)

Quoted 7 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server, normal a server needs about 256MB, but when it needs more, it shouldn't be a problem to give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 7 lines

Exactly what it is intended for!

I'd be interested in how it works for guests with memory=4096 and higher. All of my testing so far has been on a machine with only 2GB of physical memory so I can test lots of guests but no large guests.

I'll test it on monday, now I'm going into my weekend ;) but I think, that I wasn't able to get more than 2GB RAM allocated, but I will test it on monday again.

PS: In my first mail I've attached my whole signatur, I remove it because I get enough spam ;)

Thanks
Torben Viets

Quoted 225 lines

Thanks,
Dan

Quoted 88 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, May 16, 2008 9:49 AM
To: [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory info via xenbus,

Quoted 6 lines · Dan Magenheimer
Quoted 2 lines

thanks for the patch, I was waiting for this feature.

Thanks very much for the testing and feedback! Could you comment on what you plan to use it for? (Keir hasn't accepted it yet, so I am looking for user support ;-)

Ok, our plan is to have a high availbilty xen farm. Now we're beginning with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server, normal a server needs about 256MB, but when it needs more, it shouldn't be a problem to give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 5 lines

First question: Do you have a swap (virtual) disk configured and, if so, how big is it? (Use "swapon -s" and the size shows in KB.) Selfballooning shouldn't be run in a domain with no swap disk. Also, how big is your "memory=" in your vm.cfg file?

#kernel = "/boot/xen-3.2.0/vmlinuz-2.6.18.8-xenU" #kernel = "/boot/vmlinuz-2.6.18.8-xenU"
kernel = "/boot/vmlinuz-selfballooning"
memory = 256
maxmem = 8192
vcpu = 4
name = "test.work.de"
vif = [ 'bridge=xenvlan323' ]
disk = [ 'phy:/dev/sda,hda,w', 'file:/var/swap.img,hdb,w' ] root = "/dev/hda ro"
extra = 'xencons=tty'

swap_size = 256M

Quoted 5 lines

I'm not able to reproduce your dd failure at all, even with bs=2047M (dd doesn't permit larger values for bs).
Your program (I called it "mallocmem") does eventually fail for me but not until i==88. However, I have a 2GB swap disk configured.

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 35 lines

I think both tests are really measuring the total virtual memory space configured, e.g. the sum of physical memory (minus kernel overhead) and configured swap space. I think you will find that both will fail similarly with ballooning off and even on a physical system, just at different points in virtual memory usage. Indeed, by adding additional output to mallocmem, I can see that it fails exactly when it attempts to malloc memory larger than the CommitLimit value in /proc/meminfo. I expect the same is true for the dd test.

Note that CommitLimit DOES go down when memory is ballooned-out from a guest. So your test does point out to me that I should include a warning in the documentation not only that a swap disk should be configured, but also that the swap disk should be configured larger for a guest if selfballooning will be turned on.

Thanks,
Dan

Quoted 15 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: Friday, May 16, 2008 3:36 AM
To: [email protected]
Subject: RE: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

thanks for the patch, I was waiting for this feature.

Quoted 125 lines
Quoted 6 lines
Quoted 6 lines

I've tried this patch and I've seen that if I malloc a great size of memory in time, this fails, but if I malloc a small size first and then resize it slowly, it works.

this highly suffisticated (:p) program I use to test the

ballooning:

Quoted 115 lines
Quoted 114 lines

#include <stdio.h>
#include <unistd.h>

int main () {
void *v;
int i;

  for(i=40; i < 50; ++i) {
    v = malloc((i*32*1024*1024));
    printf("%i\n", i);
    if ( v != NULL) {
      system("cat /proc/xen/balloon");
      sleep(1);
      free(v);
    }

}
}

same effect I've got if I change the blocksize in a dd:

works: dd if=zero of=/test.img count=1 bs=32M doesn't work: dd if=zero of=/test.img count=1 bs=256M

Don't know whether this is the right test for this...

greetings
Torben Viets

Dan Magenheimer wrote

Quoted 38 lines

OK, here's the promised patch. The overall objective of the patch is to enable limited memory load-balancing capabilities as a step toward allowing limited memory overcommit. With this and some other minor hackery, I was able to run as many as 15 lightly loaded 512MB domains on a 2GB system (yes, veerrrryyy slooowwwlly).

Review/comments appreciated.

With this patch, balloon.c communicates (limited) useful memory usage information via xenbus. It also implements "selfballooning" which applies the memory information locally to immediately adjust the balloon, giving up memory when it is not needed and asking for it back when it is needed, implementing a first-come-first-served system-wide ballooning "policy". When a domain asks for memory but none is available, it must use its own configured swap disk, resulting in (potentially severe) performance degradation. Naturally, it is not recommended to turn on selfballooning in a domain that has no swap disk or if performance is more important than increasing the number of VMs runnable on a physical machine.

A key assumption is that the Linux variable vm_committed_space is a reasonable first approximation of memory needed by a domain. This approximation will probably improve over time, but is a good start for now. The variable is bound on the lower end by the recently submitted minimum_target() algorithm patch; thus O-O-M conditions should not occur.

The code is a bit complicated in a couple of places because of race conditions involving xenstored startup relative to turning on selfballooning locally. Because the key variable (vm_committed_space) is not exported by Linux, I implemented a horrible hack which still allows the code to work in a module, however I fully expect that this part of the patch will not be accepted (which will limit the functionality to pvm domains only... probably OK for now).

Quoted 9 lines

Existing balloon functionality which is unchanged:
- Set target for VM from domain0
- Set target inside VM by writing to /proc/xen/balloon Existing balloon info on xenbus which is unchanged:
- /local/domain/X/memory/target
To turn on selfballooning:
- Inside a VM: "echo 1 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 1"

Quoted 4 lines

To turn off selfballooning:
- Inside a VM: "echo 0 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 0"

Quoted 13 lines

New balloon info now on xenbus:
- /local/domain/X/memory/selfballoon [0 or 1]
- /local/domain/X/memory/actual [kB] *
- /local/domain/X/memory/minimum [kB] *
- /local/domain/X/memory/selftarget [kB] * (only valid if selfballoon==1)
* writeable only by balloon driver in X when either selfballooning is first enabled, or target is changed by domain0

Thanks,
Dan

Quoted 7 lines

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

--

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 2 lines
Quoted 2 lines

memory = 256
maxmem = 8192

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

So to run a guest which adjusts between 256MB and 8192MB of memory, you must launch it with 8192MB and balloon it down to 256MB. If Xen does not have 8192MB free at launch, launching the domain will fail.

Dan

Quoted 291 lines

-----Original Message-----
From: Torben Viets [mailto:[email protected]]
Sent: Friday, May 16, 2008 10:51 AM
To: [email protected]
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 3 lines · Dan Magenheimer

(Your reply came to me but not to the list... not sure why. So I've attached your full reply below.)

thanks, hope this time it works....

Quoted 4 lines
Quoted 3 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 12 lines

Yes, definitely. If you are creating the swapdisk on an ext3 filesystem, you might try using sparse files. They won't take up much disk space unless/until they get swapped-to. There might be some performance ramifications though. (My testing has been with swap disk as a logical volume so I can't try sparse.)

Quoted 4 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server,

normal a server

Quoted 6 lines
Quoted 5 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 7 lines

Exactly what it is intended for!

I'd be interested in how it works for guests with memory=4096 and higher. All of my testing so far has been on a machine with only 2GB of physical memory so I can test lots of guests but no large guests.

I'll test it on monday, now I'm going into my weekend ;) but I think, that I wasn't able to get more than 2GB RAM allocated, but I will test it on monday again.

PS: In my first mail I've attached my whole signatur, I remove it because I get enough spam ;)

Thanks
Torben Viets

Quoted 8 lines

Thanks,
Dan

Quoted 4 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, May 16, 2008 9:49 AM
To: [email protected];

[email protected]

Quoted 9 lines
Quoted 9 lines

Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 2 lines · Dan Magenheimer
Quoted 2 lines

thanks for the patch, I was waiting for this feature.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Thanks very much for the testing and feedback! Could you comment on what you plan to use it for? (Keir hasn't accepted it yet, so I am looking for user support ;-)

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server,

normal a server

Quoted 25 lines
Quoted 25 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 5 lines

First question: Do you have a swap (virtual) disk configured and, if so, how big is it? (Use "swapon -s" and the size shows in KB.) Selfballooning shouldn't be run in a domain with no swap disk. Also, how big is your "memory=" in your vm.cfg file?

#kernel = "/boot/xen-3.2.0/vmlinuz-2.6.18.8-xenU" #kernel = "/boot/vmlinuz-2.6.18.8-xenU"
kernel = "/boot/vmlinuz-selfballooning"
memory = 256
maxmem = 8192
vcpu = 4
name = "test.work.de"
vif = [ 'bridge=xenvlan323' ]
disk = [ 'phy:/dev/sda,hda,w', 'file:/var/swap.img,hdb,w' ] root = "/dev/hda ro"
extra = 'xencons=tty'

Quoted 7 lines
Quoted 7 lines

swap_size = 256M

Quoted 4 lines

I'm not able to reproduce your dd failure at all, even with bs=2047M (dd doesn't permit larger values for bs). Your program (I called it "mallocmem") does eventually fail for me but not until i==88. However, I have a 2GB swap disk

configured.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 4 lines

I think both tests are really measuring the total virtual memory space configured, e.g. the sum of physical memory (minus kernel overhead) and configured swap space. I think you will find that both will fail similarly with ballooning off and even on

a physical

Quoted 78 lines
Quoted 78 lines
Quoted 6 lines

system, just at different points in virtual memory usage. Indeed, by adding additional output to mallocmem, I can see that it fails exactly when it attempts to malloc memory larger than the CommitLimit value in /proc/meminfo. I expect the same is true for the dd test.

Quoted 31 lines

Note that CommitLimit DOES go down when memory is ballooned-out from a guest. So your test does point out to me that I should include a warning in the documentation not only that a swap disk should be configured, but also that the swap disk should be configured larger for a guest if selfballooning will be turned on.

Thanks,
Dan

Quoted 21 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: Friday, May 16, 2008 3:36 AM
To: [email protected]
Subject: RE: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

thanks for the patch, I was waiting for this feature.

I've tried this patch and I've seen that if I malloc a great size of memory in time, this fails, but if I malloc a small size first and then resize it slowly, it works.

this highly suffisticated (:p) program I use to test the

ballooning:

Quoted 39 lines
Quoted 39 lines

#include <stdio.h>
#include <unistd.h>

int main () {
void *v;
int i;

  for(i=40; i < 50; ++i) {
    v = malloc((i*32*1024*1024));
    printf("%i\n", i);
    if ( v != NULL) {
      system("cat /proc/xen/balloon");
      sleep(1);
      free(v);
    }

}
}

same effect I've got if I change the blocksize in a dd:

works: dd if=zero of=/test.img count=1 bs=32M doesn't work: dd if=zero of=/test.img count=1 bs=256M

Don't know whether this is the right test for this...

greetings
Torben Viets

Dan Magenheimer wrote

Quoted 9 lines

OK, here's the promised patch. The overall objective of the patch is to enable limited memory load-balancing capabilities as a step toward allowing limited memory overcommit. With this and some other minor hackery, I was able to run as many as 15 lightly loaded 512MB domains on a 2GB system (yes, veerrrryyy slooowwwlly).

Review/comments appreciated.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

With this patch, balloon.c communicates (limited) useful memory usage information via xenbus. It also implements "selfballooning" which applies the memory information locally to immediately adjust the balloon, giving up memory

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

when it is not needed and asking for it back when it is needed, implementing a first-come-first-served system-wide ballooning "policy". When a domain asks for memory but none is available, it must use its own configured swap disk, resulting in (potentially severe) performance degradation. Naturally, it is not recommended to turn on selfballooning in a domain that has no swap disk or if performance is more important than increasing the number of VMs runnable on a

physical machine.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

A key assumption is that the Linux variable vm_committed_space is a reasonable first approximation of memory needed by

a domain.

Quoted 71 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 14 lines

This approximation will probably improve over time, but is a good start for now. The variable is bound on the lower end by the recently submitted minimum_target() algorithm patch; thus O-O-M conditions should not occur.

The code is a bit complicated in a couple of places because of race conditions involving xenstored startup relative to turning on selfballooning locally. Because the key variable (vm_committed_space) is not exported by Linux, I implemented a horrible hack which still allows the code to work in a module, however I fully expect that this part of the patch will not be accepted (which will limit the functionality to pvm domains only... probably OK for now).

Quoted 9 lines

Existing balloon functionality which is unchanged:
- Set target for VM from domain0
- Set target inside VM by writing to /proc/xen/balloon Existing balloon info on xenbus which is unchanged:
- /local/domain/X/memory/target
To turn on selfballooning:
- Inside a VM: "echo 1 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 1"

Quoted 4 lines

To turn off selfballooning:
- Inside a VM: "echo 0 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 0"

Quoted 13 lines

New balloon info now on xenbus:
- /local/domain/X/memory/selfballoon [0 or 1]
- /local/domain/X/memory/actual [kB] *
- /local/domain/X/memory/minimum [kB] *
- /local/domain/X/memory/selftarget [kB] * (only valid if selfballoon==1)
* writeable only by balloon driver in X when either selfballooning is first enabled, or target is changed by domain0

Thanks,
Dan

Quoted 7 lines

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

--

Quoted 9 lines
Quoted 7 lines
Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

hey,

thanks for the tip, I've already memory hotplug activated. Now it works fine with 7 domains, but no one uses more than 256MB... I'd like to test the ballooning with more than 2GB memory but at the moment I'ven't a live machine which needs so much memory...

but with maxmen and hotplug, this defines the maximum or?

greetings
Torben Viets

Quoted 346 lines · Dan Magenheimer
Quoted 3 lines
Quoted 3 lines

memory = 256
maxmem = 8192

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

So to run a guest which adjusts between 256MB and 8192MB of memory, you must launch it with 8192MB and balloon it down to 256MB. If Xen does not have 8192MB free at launch, launching the domain will fail.

Dan

Quoted 238 lines

-----Original Message-----
From: Torben Viets [mailto:[email protected]]
Sent: Friday, May 16, 2008 10:51 AM
To: [email protected]
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory info via xenbus,

Quoted 4 lines · Dan Magenheimer

(Your reply came to me but not to the list... not sure why. So I've attached your full reply below.)

thanks, hope this time it works....

Quoted 17 lines
Quoted 3 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Yes, definitely. If you are creating the swapdisk on an ext3 filesystem, you might try using sparse files. They won't take up much disk space unless/until they get swapped-to. There might be some performance ramifications though. (My testing has been with swap disk as a logical volume so I can't try sparse.)

Quoted 5 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server,

normal a server

Quoted 6 lines
Quoted 6 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 8 lines

Exactly what it is intended for!

I'd be interested in how it works for guests with memory=4096 and higher. All of my testing so far has been on a machine with only 2GB of physical memory so I can test lots of guests but no large guests.

I'll test it on monday, now I'm going into my weekend ;) but I think, that I wasn't able to get more than 2GB RAM allocated, but I will test it on monday again.

PS: In my first mail I've attached my whole signatur, I remove it because I get enough spam ;)

Thanks
Torben Viets

Quoted 10 lines

Thanks,
Dan

Quoted 5 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, May 16, 2008 9:49 AM
To: [email protected];

[email protected]

Quoted 16 lines
Quoted 16 lines

Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 8 lines · Dan Magenheimer
Quoted 3 lines

thanks for the patch, I was waiting for this feature.

Thanks very much for the testing and feedback! Could you comment on what you plan to use it for? (Keir hasn't accepted it yet, so I am looking for user support ;-)

Quoted 5 lines
Quoted 5 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server,

normal a server

Quoted 31 lines
Quoted 31 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 6 lines

First question: Do you have a swap (virtual) disk configured and, if so, how big is it? (Use "swapon -s" and the size shows in KB.) Selfballooning shouldn't be run in a domain with no swap disk. Also, how big is your "memory=" in your vm.cfg file?

#kernel = "/boot/xen-3.2.0/vmlinuz-2.6.18.8-xenU" #kernel = "/boot/vmlinuz-2.6.18.8-xenU"
kernel = "/boot/vmlinuz-selfballooning"
memory = 256
maxmem = 8192
vcpu = 4
name = "test.work.de"
vif = [ 'bridge=xenvlan323' ]
disk = [ 'phy:/dev/sda,hda,w', 'file:/var/swap.img,hdb,w' ] root = "/dev/hda ro"
extra = 'xencons=tty'

swap_size = 256M

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I'm not able to reproduce your dd failure at all, even with bs=2047M (dd doesn't permit larger values for bs). Your program (I called it "mallocmem") does eventually fail for me but not until i==88. However, I have a 2GB swap disk

configured.

Quoted 8 lines
Quoted 8 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 5 lines

I think both tests are really measuring the total virtual memory space configured, e.g. the sum of physical memory (minus kernel overhead) and configured swap space. I think you will find that both will fail similarly with ballooning off and even on

a physical

Quoted 82 lines
Quoted 82 lines
Quoted 6 lines

system, just at different points in virtual memory usage. Indeed, by adding additional output to mallocmem, I can see that it fails exactly when it attempts to malloc memory larger than the CommitLimit value in /proc/meminfo. I expect the same is true for the dd test.

Quoted 33 lines

Note that CommitLimit DOES go down when memory is ballooned-out from a guest. So your test does point out to me that I should include a warning in the documentation not only that a swap disk should be configured, but also that the swap disk should be configured larger for a guest if selfballooning will be turned on.

Thanks,
Dan

Quoted 22 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: Friday, May 16, 2008 3:36 AM
To: [email protected]
Subject: RE: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

thanks for the patch, I was waiting for this feature.

I've tried this patch and I've seen that if I malloc a great size of memory in time, this fails, but if I malloc a small size first and then resize it slowly, it works.

this highly suffisticated (:p) program I use to test the

ballooning:

Quoted 40 lines
Quoted 40 lines

#include <stdio.h>
#include <unistd.h>

int main () {
void *v;
int i;

  for(i=40; i < 50; ++i) {
    v = malloc((i*32*1024*1024));
    printf("%i\n", i);
    if ( v != NULL) {
      system("cat /proc/xen/balloon");
      sleep(1);
      free(v);
    }

}
}

same effect I've got if I change the blocksize in a dd:

works: dd if=zero of=/test.img count=1 bs=32M doesn't work: dd if=zero of=/test.img count=1 bs=256M

Don't know whether this is the right test for this...

greetings
Torben Viets

Dan Magenheimer wrote

Quoted 9 lines

OK, here's the promised patch. The overall objective of the patch is to enable limited memory load-balancing capabilities as a step toward allowing limited memory overcommit. With this and some other minor hackery, I was able to run as many as 15 lightly loaded 512MB domains on a 2GB system (yes, veerrrryyy slooowwwlly).

Review/comments appreciated.

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

With this patch, balloon.c communicates (limited) useful memory usage information via xenbus. It also implements "selfballooning" which applies the memory information locally to immediately adjust the balloon, giving up memory when it is not needed and asking for it back when it is needed,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

implementing a first-come-first-served system-wide ballooning "policy". When a domain asks for memory but none is available, it must use its own configured swap disk, resulting in (potentially severe) performance degradation. Naturally, it is not recommended to turn on selfballooning in a domain that has no swap disk or if performance is more important than increasing the number of VMs runnable on a

Quoted 82 lines

physical machine.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

A key assumption is that the Linux variable vm_committed_space is a reasonable first approximation of memory needed by

a domain.

Quoted 74 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 14 lines

This approximation will probably improve over time, but is a good start for now. The variable is bound on the lower end by the recently submitted minimum_target() algorithm patch; thus O-O-M conditions should not occur.

The code is a bit complicated in a couple of places because of race conditions involving xenstored startup relative to turning on selfballooning locally. Because the key variable (vm_committed_space) is not exported by Linux, I implemented a horrible hack which still allows the code to work in a module, however I fully expect that this part of the patch will not be accepted (which will limit the functionality to pvm domains only... probably OK for now).

Quoted 10 lines

Existing balloon functionality which is unchanged:
- Set target for VM from domain0
- Set target inside VM by writing to /proc/xen/balloon Existing balloon info on xenbus which is unchanged:
- /local/domain/X/memory/target
To turn on selfballooning:
- Inside a VM: "echo 1 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 1"

Quoted 5 lines

To turn off selfballooning:
- Inside a VM: "echo 0 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 0"

Quoted 13 lines

New balloon info now on xenbus:
- /local/domain/X/memory/selfballoon [0 or 1]
- /local/domain/X/memory/actual [kB] *
- /local/domain/X/memory/minimum [kB] *
- /local/domain/X/memory/selftarget [kB] * (only valid if selfballoon==1)
* writeable only by balloon driver in X when either selfballooning is first enabled, or target is changed by domain0

Thanks,
Dan

Quoted 8 lines

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

--

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

Hello,

are there any plans to bring this feature in the xen kernel?

Possible as an expermental marked feature?

I use it about 1 month without any trouble on live systems.

greetings
Viets

Quoted 361 lines · Viets

hey,

thanks for the tip, I've already memory hotplug activated. Now it works fine with 7 domains, but no one uses more than 256MB... I'd like to test the ballooning with more than 2GB memory but at the moment I'ven't a live machine which needs so much memory...

but with maxmen and hotplug, this defines the maximum or?

greetings
Torben Viets

Quoted 334 lines · Dan Magenheimer
Quoted 3 lines
Quoted 3 lines

memory = 256
maxmem = 8192

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

So to run a guest which adjusts between 256MB and 8192MB of memory, you must launch it with 8192MB and balloon it down to 256MB. If Xen does not have 8192MB free at launch, launching the domain will fail.

Dan

Quoted 232 lines

-----Original Message-----
From: Torben Viets [mailto:[email protected]]
Sent: Friday, May 16, 2008 10:51 AM
To: [email protected]
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory info via xenbus,

Quoted 4 lines · Dan Magenheimer

(Your reply came to me but not to the list... not sure why. So I've attached your full reply below.)

thanks, hope this time it works....

Quoted 16 lines
Quoted 3 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Yes, definitely. If you are creating the swapdisk on an ext3 filesystem, you might try using sparse files. They won't take up much disk space unless/until they get swapped-to. There might be some performance ramifications though. (My testing has been with swap disk as a logical volume so I can't try sparse.)

Quoted 4 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server,

normal a server

Quoted 6 lines
Quoted 6 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 8 lines

Exactly what it is intended for!

I'd be interested in how it works for guests with memory=4096 and higher. All of my testing so far has been on a machine with only 2GB of physical memory so I can test lots of guests but no large guests.

I'll test it on monday, now I'm going into my weekend ;) but I think, that I wasn't able to get more than 2GB RAM allocated, but I will test it on monday again.

PS: In my first mail I've attached my whole signatur, I remove it because I get enough spam ;)

Thanks
Torben Viets

Quoted 9 lines

Thanks,
Dan

Quoted 4 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, May 16, 2008 9:49 AM
To: [email protected];

[email protected]

Quoted 16 lines
Quoted 16 lines

Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 8 lines · Dan Magenheimer
Quoted 3 lines

thanks for the patch, I was waiting for this feature.

Thanks very much for the testing and feedback! Could you comment on what you plan to use it for? (Keir hasn't accepted it yet, so I am looking for user support ;-)

Quoted 4 lines
Quoted 4 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we like to use selfballooning, because of peak traffic on a server,

normal a server

Quoted 27 lines
Quoted 27 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory, but have the ability to get rid of memory failures because of peaks.

Quoted 6 lines

First question: Do you have a swap (virtual) disk configured and, if so, how big is it? (Use "swapon -s" and the size shows in KB.) Selfballooning shouldn't be run in a domain with no swap disk. Also, how big is your "memory=" in your vm.cfg file?

#kernel = "/boot/xen-3.2.0/vmlinuz-2.6.18.8-xenU" #kernel = "/boot/vmlinuz-2.6.18.8-xenU"
kernel = "/boot/vmlinuz-selfballooning"
memory = 256
maxmem = 8192
vcpu = 4
name = "test.work.de"
vif = [ 'bridge=xenvlan323' ]
disk = [ 'phy:/dev/sda,hda,w', 'file:/var/swap.img,hdb,w' ] root = "/dev/hda ro"
extra = 'xencons=tty'

Quoted 8 lines
Quoted 8 lines

swap_size = 256M

Quoted 4 lines

I'm not able to reproduce your dd failure at all, even with bs=2047M (dd doesn't permit larger values for bs). Your program (I called it "mallocmem") does eventually fail for me but not until i==88. However, I have a 2GB swap disk

configured.

Quoted 7 lines
Quoted 7 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 4 lines

I think both tests are really measuring the total virtual memory space configured, e.g. the sum of physical memory (minus kernel overhead) and configured swap space. I think you will find that both will fail similarly with ballooning off and even on

a physical

Quoted 82 lines
Quoted 82 lines
Quoted 6 lines

system, just at different points in virtual memory usage. Indeed, by adding additional output to mallocmem, I can see that it fails exactly when it attempts to malloc memory larger than the CommitLimit value in /proc/meminfo. I expect the same is true for the dd test.

Quoted 33 lines

Note that CommitLimit DOES go down when memory is ballooned-out from a guest. So your test does point out to me that I should include a warning in the documentation not only that a swap disk should be configured, but also that the swap disk should be configured larger for a guest if selfballooning will be turned on.

Thanks,
Dan

Quoted 22 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: Friday, May 16, 2008 3:36 AM
To: [email protected]
Subject: RE: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

thanks for the patch, I was waiting for this feature.

I've tried this patch and I've seen that if I malloc a great size of memory in time, this fails, but if I malloc a small size first and then resize it slowly, it works.

this highly suffisticated (:p) program I use to test the

ballooning:

Quoted 40 lines
Quoted 40 lines

#include <stdio.h>
#include <unistd.h>

int main () {
void *v;
int i;

  for(i=40; i < 50; ++i) {
    v = malloc((i*32*1024*1024));
    printf("%i\n", i);
    if ( v != NULL) {
      system("cat /proc/xen/balloon");
      sleep(1);
      free(v);
    }

}
}

same effect I've got if I change the blocksize in a dd:

works: dd if=zero of=/test.img count=1 bs=32M doesn't work: dd if=zero of=/test.img count=1 bs=256M

Don't know whether this is the right test for this...

greetings
Torben Viets

Dan Magenheimer wrote

Quoted 9 lines

OK, here's the promised patch. The overall objective of the patch is to enable limited memory load-balancing capabilities as a step toward allowing limited memory overcommit. With this and some other minor hackery, I was able to run as many as 15 lightly loaded 512MB domains on a 2GB system (yes, veerrrryyy slooowwwlly).

Review/comments appreciated.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

With this patch, balloon.c communicates (limited) useful memory usage information via xenbus. It also implements "selfballooning" which applies the memory information locally to immediately adjust the balloon, giving up memory

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

when it is not needed and asking for it back when it is needed, implementing a first-come-first-served system-wide ballooning "policy". When a domain asks for memory but none is available, it must use its own configured swap disk, resulting in (potentially severe) performance degradation. Naturally, it is not recommended to turn on selfballooning in a domain that has no swap disk or if performance is more important than increasing the number of VMs runnable on a

Quoted 82 lines

physical machine.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

A key assumption is that the Linux variable vm_committed_space is a reasonable first approximation of memory needed by

a domain.

Quoted 74 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 14 lines

This approximation will probably improve over time, but is a good start for now. The variable is bound on the lower end by the recently submitted minimum_target() algorithm patch; thus O-O-M conditions should not occur.

The code is a bit complicated in a couple of places because of race conditions involving xenstored startup relative to turning on selfballooning locally. Because the key variable (vm_committed_space) is not exported by Linux, I implemented a horrible hack which still allows the code to work in a module, however I fully expect that this part of the patch will not be accepted (which will limit the functionality to pvm domains only... probably OK for now).

Quoted 10 lines

Existing balloon functionality which is unchanged:
- Set target for VM from domain0
- Set target inside VM by writing to /proc/xen/balloon Existing balloon info on xenbus which is unchanged:
- /local/domain/X/memory/target
To turn on selfballooning:
- Inside a VM: "echo 1 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 1"

Quoted 5 lines

To turn off selfballooning:
- Inside a VM: "echo 0 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 0"

Quoted 21 lines

New balloon info now on xenbus:
- /local/domain/X/memory/selfballoon [0 or 1]
- /local/domain/X/memory/actual [kB] *
- /local/domain/X/memory/minimum [kB] *
- /local/domain/X/memory/selftarget [kB] * (only valid if selfballoon==1)
* writeable only by balloon driver in X when either selfballooning is first enabled, or target is changed by domain0

Thanks,
Dan

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've OOM's in store Overcommitted so much
(with apologies to the late great Bob Hope)

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw

Hi Viets --

I'm cleaning up a scripts-only version (no balloon driver changes) this week for submission to xen-devel before the 3.3 functionality freeze.

For more info, see:

http://www.xen.org/files/xensummitboston08/MemoryOvercommit-XenSummit2008.pdf

http://wiki.xensource.com/xenwiki/Open_Topics_For_Discussion?action=AttachFile&do=get&target=Memory+Overcommit.pdf

Thanks,
Dan

Quoted 405 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Monday, June 30, 2008 8:25 AM
To: [email protected]; [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

are there any plans to bring this feature in the xen kernel?

Possible as an expermental marked feature?

I use it about 1 month without any trouble on live systems.

greetings
Viets

Quoted 3 lines · Viets

hey,

thanks for the tip, I've already memory hotplug activated.

Now it works

Quoted 1 line

fine with 7 domains, but no one uses more than 256MB... I'd

like to test

Quoted 1 line

the ballooning with more than 2GB memory but at the moment

I'ven't a

Quoted 32 lines

live machine which needs so much memory...

but with maxmen and hotplug, this defines the maximum or?

greetings
Torben Viets

Quoted 24 lines · Dan Magenheimer
Quoted 3 lines
Quoted 3 lines

memory = 256
maxmem = 8192

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

So to run a guest which adjusts between 256MB and 8192MB of memory, you must launch it with 8192MB and balloon it down to 256MB. If Xen does not have 8192MB free at launch, launching the domain will fail.

Dan

Quoted 6 lines

-----Original Message-----
From: Torben Viets [mailto:[email protected]]
Sent: Friday, May 16, 2008 10:51 AM
To: [email protected]
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning

and post memory

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

info via xenbus,

Quoted 4 lines · Dan Magenheimer

(Your reply came to me but not to the list... not sure why. So I've attached your full reply below.)

thanks, hope this time it works....

Quoted 12 lines
Quoted 3 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Yes, definitely. If you are creating the swapdisk on an ext3 filesystem, you might try using sparse files. They won't take up much disk space unless/until they get swapped-to. There might be some performance ramifications though. (My testing has been with swap disk as a logical volume so I can't try sparse.)

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we

like to use

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

selfballooning, because of peak traffic on a server,

normal a server

Quoted 3 lines
Quoted 3 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory,

but have the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

ability to get rid of memory failures because of peaks.

Exactly what it is intended for!

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

I'd be interested in how it works for guests with memory=4096 and higher. All of my testing so far has been on a machine with only 2GB of physical memory so I can test lots of guests but no large guests.

I'll test it on monday, now I'm going into my weekend ;)

but I think,

Quoted 1 line
Quoted 1 line
Quoted 1 line

that I wasn't able to get more than 2GB RAM allocated,

but I will test

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

it on monday again.

PS: In my first mail I've attached my whole signatur, I remove it because I get enough spam ;)

Thanks
Torben Viets

Quoted 9 lines

Thanks,
Dan

Quoted 4 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, May 16, 2008 9:49 AM
To: [email protected];

[email protected]

Quoted 11 lines
Quoted 11 lines

Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 3 lines · Dan Magenheimer
Quoted 3 lines

thanks for the patch, I was waiting for this feature.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Thanks very much for the testing and feedback! Could you comment on what you plan to use it for? (Keir hasn't accepted it yet, so I am looking for user support ;-)

Ok, our plan is to have a high availbilty xen farm. Now we're beginning
with 2 Suns X2200, each has 16GB RAM. The idea, why we

like to use

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

selfballooning, because of peak traffic on a server,

normal a server

Quoted 3 lines
Quoted 3 lines

needs about 256MB, but when it needs more, it shouldn't be a problem to
give it 4GB. The idea is not to overbook the memory,

but have the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

ability to get rid of memory failures because of peaks.

Quoted 1 line

First question: Do you have a swap (virtual) disk

configured and,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

if so, how big is it? (Use "swapon -s" and the size

shows in KB.)

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 4 lines

Selfballooning shouldn't be run in a domain with no swap disk. Also, how big is your "memory=" in your vm.cfg file?

#kernel = "/boot/xen-3.2.0/vmlinuz-2.6.18.8-xenU" #kernel = "/boot/vmlinuz-2.6.18.8-xenU"
kernel = "/boot/vmlinuz-selfballooning"
memory = 256
maxmem = 8192
vcpu = 4
name = "test.work.de"
vif = [ 'bridge=xenvlan323' ]
disk = [ 'phy:/dev/sda,hda,w', 'file:/var/swap.img,hdb,w' ] root = "/dev/hda ro"
extra = 'xencons=tty'

swap_size = 256M

Quoted 4 lines

I'm not able to reproduce your dd failure at all, even with bs=2047M (dd doesn't permit larger values for bs). Your program (I called it "mallocmem") does eventually fail for me but not until i==88. However, I have a 2GB swap disk

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

configured.

Quoted 4 lines
Quoted 4 lines

ah ok, that is my failure, I need a bigger swapdisk ;)

Quoted 1 line

I think both tests are really measuring the total

virtual memory

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

space configured, e.g. the sum of physical memory (minus kernel overhead) and configured swap space. I think you will

find that

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

both will fail similarly with ballooning off and even on

a physical

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

system, just at different points in virtual memory usage. Indeed, by adding additional output to mallocmem, I

can see that

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

it fails exactly when it attempts to malloc memory larger than the CommitLimit value in /proc/meminfo. I expect the same is true for the dd test.

Note that CommitLimit DOES go down when memory is ballooned-out from a guest. So your test does point out to me that I should include a warning in the documentation not only that a

swap disk

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

should be configured, but also that the swap disk should be configured larger for a guest if selfballooning will

be turned on.

Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Quoted 28 lines

Thanks,
Dan

Quoted 22 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of [email protected]
Sent: Friday, May 16, 2008 3:36 AM
To: [email protected]
Subject: RE: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Hello,

thanks for the patch, I was waiting for this feature.

I've tried this patch and I've seen that if I malloc a great size of memory in time, this fails, but if I malloc a small size first and then resize it slowly, it works.

this highly suffisticated (:p) program I use to test the

ballooning:

Quoted 38 lines
Quoted 38 lines

#include <stdio.h>
#include <unistd.h>

int main () {
void *v;
int i;

  for(i=40; i < 50; ++i) {
    v = malloc((i*32*1024*1024));
    printf("%i\n", i);
    if ( v != NULL) {
      system("cat /proc/xen/balloon");
      sleep(1);
      free(v);
    }

}
}

same effect I've got if I change the blocksize in a dd:

works: dd if=zero of=/test.img count=1 bs=32M doesn't work: dd if=zero of=/test.img count=1 bs=256M

Don't know whether this is the right test for this...

greetings
Torben Viets

Dan Magenheimer wrote

Quoted 7 lines

OK, here's the promised patch. The overall objective of the patch is to enable limited memory load-balancing capabilities as a step toward allowing limited memory overcommit. With this and some other minor hackery, I was able to run as many as 15 lightly loaded 512MB domains on a 2GB system (yes, veerrrryyy slooowwwlly).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Review/comments appreciated.

With this patch, balloon.c communicates (limited) useful memory usage information via xenbus. It also implements "selfballooning" which applies the memory information locally to immediately adjust the balloon, giving up memory when it is not needed and asking for it back when it

is needed,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

implementing a first-come-first-served system-wide ballooning "policy". When a domain asks for memory but none is

available,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

it must use its own configured swap disk, resulting in (potentially severe) performance degradation. Naturally, it is not recommended to turn on selfballooning in a domain that has no swap disk or if performance is more important than increasing the number of VMs runnable on a

physical machine.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

A key assumption is that the Linux variable

vm_committed_space

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

is a reasonable first approximation of memory needed by

a domain.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This approximation will probably improve over time, but is a good start for now. The variable is bound on the lower end by the recently submitted minimum_target() algorithm patch; thus O-O-M conditions should not occur.

The code is a bit complicated in a couple of places

because of

Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 8 lines

race conditions involving xenstored startup relative to turning on selfballooning locally. Because the key variable (vm_committed_space) is not exported by Linux, I implemented a horrible hack which still allows the code to work in a module, however I fully expect that this part of the patch will not be accepted (which will limit the functionality to pvm domains only... probably OK for now).

Quoted 10 lines

Existing balloon functionality which is unchanged:
- Set target for VM from domain0
- Set target inside VM by writing to /proc/xen/balloon Existing balloon info on xenbus which is unchanged:
- /local/domain/X/memory/target
To turn on selfballooning:
- Inside a VM: "echo 1 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 1"

Quoted 5 lines

To turn off selfballooning:
- Inside a VM: "echo 0 > /proc/xen/balloon"
- From domain0: "xenstore-write

/local/domain/X/memory/selfballoon 0"

Quoted 10 lines

New balloon info now on xenbus:
- /local/domain/X/memory/selfballoon [0 or 1]
- /local/domain/X/memory/actual [kB] *
- /local/domain/X/memory/minimum [kB] *
- /local/domain/X/memory/selftarget [kB] * (only valid if selfballoon==1)
* writeable only by balloon driver in X when either selfballooning is first enabled, or target is changed by domain0

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Thanks,
Dan

===================================
Thanks... for the memory
I really could use more / My throughput's on the floor The balloon is flat / My swap disk's fat / I've

OOM's in store

Quoted 39 lines
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines

Overcommitted so much
(with apologies to the late great Bob Hope)

--

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 8 lines
Quoted 7 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw
In reply to Dan Magenheimer
Quoted 8 lines · Dan Magenheimer
Quoted 2 lines
Quoted 2 lines

memory = 256
maxmem = 8192

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

Assuming we are talking about PV guests, I think this is wrong. My knowledge is a little dated (mostly 3.1.x series knowledge), but unless it has changed, this should work. As I understand it, what happens is that if you specify like above, dom0 gets ballooned down 256MB, and then your domain is started with 256MB. From there, you should be able to use xm mem-set <domid> <MB> to set the amount of memory in the guest, up to maxmem.

But there is a big caveat, which trips people up all of the time. The xm mem-set command will *not* automatically balloon down dom0 for you. So if you allocated all memory to dom0 on bootup (say, 4GB), then started just this one guest (so now dom0 == 3.75GB, domU == 256MB), and try to xm mem-set, you will fail. If you then xm mem-set 0 3000 (or something), you would then be able to balloon up the domU an additional .75GB.

Chris Lalancette

#8 lore raw
Quoted 16 lines · Chris Lalancette
Quoted 5 lines

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

Assuming we are talking about PV guests, I think this is wrong. My knowledge is
a little dated (mostly 3.1.x series knowledge), but unless it has changed, this
should work. As I understand it, what happens is that if you specify like above, dom0 gets ballooned down 256MB, and then your domain is started with 256MB. From there, you should be able to use xm mem-set <domid> <MB> to set the
amount of memory in the guest, up to maxmem.

Quoted 6 lines

But there is a big caveat, which trips people up all of the time. The xm mem-set command will *not* automatically balloon down dom0 for you. So if you allocated all memory to dom0 on bootup (say, 4GB), then started just this one guest (so now dom0 == 3.75GB, domU == 256MB), and try to xm mem-set, you will fail. If you then xm mem-set 0 3000 (or something), you would then be able to balloon up the domU an additional .75GB.

This is certainly how it is supposed to still work!

-- Keir

#9 lore raw
In reply to Chris Lalancette

I stand corrected... it does work for PV guests... but not for HVM guests (at least not the ones I've tested with). Also changing the PV guest's balloon target will work, instead of mem-set.

Interesting...

What is the mechanism behind this? Is memory-hotplug used? (It appears to not be configured in my pv guest.) Or is the pv kernel actually booted with maxmem MB and the balloon driver immediately steals memory down to "memory="? (I'm wondering, for example, if the number of "struct page"s to handle maxmem is allocated at guest kernel boot, or increased when memory is increased.)

A pointer to the code implementing this mechanism would also be helpful!

Thanks,
Dan

Quoted 46 lines

-----Original Message-----
From: Chris Lalancette [mailto:[email protected]]
Sent: Thursday, May 22, 2008 1:16 AM
To: [email protected]
Cc: Torben Viets; [email protected]
Subject: Re: [Xen-devel] [PATCH] balloon: selfballooning and post memory
info via xenbus,

Quoted 8 lines · Dan Magenheimer
Quoted 2 lines
Quoted 2 lines

memory = 256
maxmem = 8192

By the way, I'm not sure if you knew this, but the above two lines don't work as you might want. The maxmem is ignored. The domain is launched (in this example) with 256MB of memory and (at least without hot-plug memory support in the guest) memory can only be decreased from there, not increased.

Assuming we are talking about PV guests, I think this is wrong. My knowledge is
a little dated (mostly 3.1.x series knowledge), but unless it has changed, this
should work. As I understand it, what happens is that if you specify like
above, dom0 gets ballooned down 256MB, and then your domain is started with
256MB. From there, you should be able to use xm mem-set <domid> <MB> to set the
amount of memory in the guest, up to maxmem.

But there is a big caveat, which trips people up all of the time. The xm
mem-set command will *not* automatically balloon down dom0 for you. So if you
allocated all memory to dom0 on bootup (say, 4GB), then started just this one
guest (so now dom0 == 3.75GB, domU == 256MB), and try to xm mem-set, you will
fail. If you then xm mem-set 0 3000 (or something), you would then be able to
balloon up the domU an additional .75GB.

Chris Lalancette