2.6.28 and balloon driver
I am playing with 2.6.28 on xen. Nice! Thanks Jeremy!
But I have a minor gripe...
The balloon driver now is accessed via a sysfs file, for example:
# SIZE=cat /sys/devices/system/xen_memory/xen_memory0/target_kb
# echo $SIZE # echo $SIZE > /sys/devices/system/xen_memory/xen_memory0/target_kb
SIZE does indeed get current memory size in kbytes, but if one tries to pass SIZE (or slightly smaller value) back, all hell breaks loose because:
1) Despite the name, the value written must be in bytes, not kbytes
2) There is no "safety minimum", so writing the same value back actually reduces memory by a factor of 1024!
I realize behavior (1) is backwards-compatible with the existing /proc/xen/balloon behavior, but at least that filename doesn't imply a unit size.
For (2), as sysadmins grow comfortable with the "safety minimum" that's been implemented in upstream xen now for nearly a year, (users can do:
# echo 0 > /proc/xen/balloon
and it still works), some people upgrading to a 2.6.28 kernel are in for a nasty surprise.
<gripe off>
More on 2.6.28 and balloon driver
Can't prove it yet, but it appears that when 2.6.28 is ballooned to use less memory, the pages aren't actually returned to the domain's available pool of memory in Xen.
I've got some code (to be posted soon) that does an alloc_domheap_pages(d,0,0) after domain d balloons to use less memory. The code works with linux-2.6.18-xen and linux-2.6.27-xen, but not with 2.6.28... the allocate fails.
Any good reason why this might be different? Or should I dig for a bug / code difference?
Also, I am still on xen 3.3.0+ so if this was fixed later, please let me know.
Dan
RE: More on 2.6.28 and balloon driver
Hi Jeremy --
It appears that in the upstream balloon driver, the call to HYPERVISOR_update_va_mapping is missing from decrease_reservation. I think as a result, the balloon driver is eating memory but not releasing it to Xen, thus rendering the balloon driver essentially useless. (Can be observed via xentop.)
Is this just a bug/oversight, or was there maybe a problem pushing this code upstream?
Thanks,
Dan
P.S. Also please see related balloon driver thread on xen-devel yesterday (Jan 06).
Quoted 32 lines
-----Original Message-----
From: Dan Magenheimer
Sent: Tuesday, January 06, 2009 5:53 PM
To: Xen-Devel (E-mail)
Subject: [Xen-devel] More on 2.6.28 and balloon driverCan't prove it yet, but it appears that when 2.6.28 is ballooned to use less memory, the pages aren't actually returned to the domain's available pool of memory in Xen.
I've got some code (to be posted soon) that does an
alloc_domheap_pages(d,0,0)after domain d balloons to use less memory. The code works with linux-2.6.18-xen and linux-2.6.27-xen, but not with 2.6.28... the allocate fails.Any good reason why this might be different? Or should I dig for a bug / code difference?
Also, I am still on xen 3.3.0+ so if this was fixed later, please let me know.
Dan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
RE: More on 2.6.28 and balloon driver
Quoted 6 lines
It appears that in the upstream balloon driver, the call to
HYPERVISOR_update_va_mappingis missing fromdecrease_reservation. I think as a result, the balloon driver is eating memory but not releasing it to Xen, thus rendering the balloon driver essentially useless. (Can be observed via xentop.)
Limited testing, but it appears that adding it back in with this simple patch to linux-2.6.28 makes ballooning work properly.
As the code is lifted from the original Xen balloon driver, I'm not sure I need this, but:
Dan
P.S. Attachement is same, provided in case my mailer messes up this >80-char-width patch.
drivers/xen/balloon.c renamed from drivers/xen/balloon.c.orig +5 -0
@@ -296,6 +296,11 @@ frame_list[i] =pfn_to_mfn (pfn);scrub_page (page); + + ret =HYPERVISOR_update_va_mapping ( + (unsigned long )__va (pfn <<PAGE_SHIFT ), +__pte_ma (0 ),0 ); +BUG_ON (ret); }/* Ensure that ballooned highmem pages don't have kmaps. */
drivers/xen/balloon.c renamed from drivers/xen/balloon.c.orig +5 -0
@@ -296,6 +296,11 @@ frame_list[i] =pfn_to_mfn (pfn);scrub_page (page); + + ret =HYPERVISOR_update_va_mapping ( + (unsigned long )__va (pfn <<PAGE_SHIFT ), +__pte_ma (0 ),0 ); +BUG_ON (ret); }/* Ensure that ballooned highmem pages don't have kmaps. */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: More on 2.6.28 and balloon driver
Quoted 8 lines · Dan Magenheimer
Quoted 7 lines
It appears that in the upstream balloon driver, the call to
HYPERVISOR_update_va_mappingis missing fromdecrease_reservation. I think as a result, the balloon driver is eating memory but not releasing it to Xen, thus rendering the balloon driver essentially useless. (Can be observed via xentop.)
Quoted 4 lines
Limited testing, but it appears that adding it back in with this simple patch to linux-2.6.28 makes ballooning work properly.
Thanks. That's a pretty embarrassing oversight :/
Quoted 5 lines
As the code is lifted from the original Xen balloon driver, I'm not sure I need this, but:
Signed-off-by Dan Magenheimer <[email protected]>
Yeah, the S-o-b line is a way to keep track of who a patch went via. It's "I assert that I'm allowed to post this patch". In theory you'd include the previous S-o-b lines (if any), but a reference to the source repo/version would be enough in this case.
J
Quoted 27 lines
Dan
P.S. Attachement is same, provided in case my mailer messes up this >80-char-width patch.drivers/xen/balloon.c renamed from drivers/xen/balloon.c.orig +5
-1@@ -296,6 +296,11 @@ frame_list[i] =pfn_to_mfn (pfn);scrub_page (page); + + ret =HYPERVISOR_update_va_mapping ( + (unsigned long )__va (pfn <<PAGE_SHIFT ), +__pte_ma (0 ),0 ); +BUG_ON (ret); }/* Ensure that ballooned highmem pages don't have kmaps. */ ------------------------------------------------------------------------_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Dan Magenheimer
I am playing with 2.6.28 on xen. Nice! Thanks Jeremy!
But I have a minor gripe...
The balloon driver now is accessed via a sysfs file, for example:
# SIZE=
cat /sys/devices/system/xen_memory/xen_memory0/target_kb
Quoted 8 lines
# echo $SIZE # echo $SIZE > /sys/devices/system/xen_memory/xen_memory0/target_kbSIZE does indeed get current memory size in kbytes, but if one tries to pass SIZE (or slightly smaller value) back, all hell breaks loose because:
1) Despite the name, the value written must be in bytes, not kbytes
Looks like the write function uses memparse which understands the M, K etc suffixes and defaults to bytes. The ability to say balloon to <n>M is quite nice but for the sake of consistency with the name it's probably preferable to just treat the value as a number of Kbytes.
Quoted 2 lines
2) There is no "safety minimum", so writing the same value back actually reduces memory by a factor of 1024!
I guess this just needs porting forward.
Can you provide patches for both these issues?
Ian.
Quoted 20 lines
I realize behavior (1) is backwards-compatible with the existing
/proc/xen/balloonbehavior, but at least that filename doesn't imply a unit size.For (2), as sysadmins grow comfortable with the "safety minimum" that's been implemented in upstream xen now for nearly a year, (users can do:
# echo 0 > /proc/xen/balloonand it still works), some people upgrading to a 2.6.28 kernel are in for a nasty surprise.
<gripe off>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Ian Campbell writes ("Re: [Xen-devel] 2.6.28 and balloon driver"):
Quoted 4 lines
Looks like the write function uses memparse which understands the M, K etc suffixes and defaults to bytes. The ability to say balloon to <n>M is quite nice but for the sake of consistency with the name it's probably preferable to just treat the value as a number of Kbytes.
Since you're changing the name anyway, can't we change the users of the file to understand the new units too ?
Ie, I think we should have
/sys/devices/system/xen_memory/xen_memory0/targe
which when read produces a number of bytes and which uses the default memparse function. If nothing else this is more likely to be something upstream mind less.
Ian.
Quoted 2 lines
Since you're changing the name anyway, can't we change the users of the file to understand the new units too ?
The patch should be easy, it's the change to backwards compatibility that should be discussed, both for xen distros and now for upstream Linux as well. I suspect this isn't used much (yet) but don't know.
Writing bytes to a sysfs entry called target_kb is a bug I think. Is there precedence for having one sysfs entry for reading and another for writing (the same value)?
Quoted 4 lines
Quoted 2 lines
2) There is no "safety minimum", so writing the same value back actually reduces memory by a factor of 1024!
I guess this just needs porting forward.
I vaguely recalled and so went and found this post from Jeremy:
http://lists.xensource.com/archives/html/xen-devel/2008-04/msg00144.html
(so Jeremy cc'ed)
So is it better to have the existing static model, or none at all, or discuss and implement something better?
One option might be to have a writable sysfs min-mem which defaults to the computed-from-maxmem value (from Jan's patch) but can be overridden**. That way, just changing target won't accidentally cause OOMs but more aggressive ballooning can also be done.
Dan
** and bytes? kb? mb? :-)
Quoted 27 lines
-----Original Message-----
From: Ian Jackson [mailto:[email protected]]
Sent: Wednesday, January 07, 2009 4:42 AM
To: Ian Campbell
Cc: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] 2.6.28 and balloon driverIan Campbell writes ("Re: [Xen-devel] 2.6.28 and balloon driver"):
Quoted 1 line
Looks like the write function uses memparse which
understands the M, K
Quoted 1 line
etc suffixes and defaults to bytes. The ability to say
balloon to <n>M
Quoted 2 lines
is quite nice but for the sake of consistency with the name it's probably preferable to just treat the value as a number of Kbytes.
Since you're changing the name anyway, can't we change the users of the file to understand the new units too ?
Ie, I think we should have
/sys/devices/system/xen_memory/xen_memory0/targe
which when read produces a number of bytes and which uses the default memparse function. If nothing else this is more likely to be something upstream mind less.Ian.
Quoted 7 lines · Dan Magenheimer
I am playing with 2.6.28 on xen. Nice! Thanks Jeremy!
But I have a minor gripe...
The balloon driver now is accessed via a sysfs file, for example:
# SIZE=
cat /sys/devices/system/xen_memory/xen_memory0/target_kb
Quoted 8 lines
# echo $SIZE # echo $SIZE > /sys/devices/system/xen_memory/xen_memory0/target_kbSIZE does indeed get current memory size in kbytes, but if one tries to pass SIZE (or slightly smaller value) back, all hell breaks loose because:
1) Despite the name, the value written must be in bytes, not kbytes
Looks like the write function uses memparse which understands the M, K etc suffixes and defaults to bytes. The ability to say balloon to <n>M is quite nice but for the sake of consistency with the name it's probably preferable to just treat the value as a number of Kbytes.
Quoted 2 lines
2) There is no "safety minimum", so writing the same value back actually reduces memory by a factor of 1024!
I guess this just needs porting forward.
Can you provide patches for both these issues?
Ian.
Quoted 15 lines
I realize behavior (1) is backwards-compatible with the existing
/proc/xen/balloonbehavior, but at least that filename doesn't imply a unit size.For (2), as sysadmins grow comfortable with the "safety minimum" that's been implemented in upstream xen now for nearly a year, (users can do:
# echo 0 > /proc/xen/balloonand it still works), some people upgrading to a 2.6.28 kernel are in for a nasty surprise.
<gripe off>
Quoted 24 lines · Dan Magenheimer
Quoted 3 lines
Since you're changing the name anyway, can't we change the users of the file to understand the new units too ?
The patch should be easy, it's the change to backwards compatibility that should be discussed, both for xen distros and now for upstream Linux as well. I suspect this isn't used much (yet) but don't know.
Writing bytes to a sysfs entry called
target_kbis a bug I think. Is there precedence for having one sysfs entry for reading and another for writing (the same value)?Quoted 4 lines
Quoted 2 lines
2) There is no "safety minimum", so writing the same value back actually reduces memory by a factor of 1024!
I guess this just needs porting forward.
I vaguely recalled and so went and found this post from Jeremy:
http://lists.xensource.com/archives/html/xen-devel/2008-04/msg00144.html
(so Jeremy cc'ed)
Quoted 7 lines
So is it better to have the existing static model, or none at all, or discuss and implement something better?
One option might be to have a writable sysfs min-mem which defaults to the computed-from-maxmem value (from Jan's patch) but can be overridden**. That way, just changing target won't accidentally cause OOMs but more aggressive ballooning can also be done.
I think that's definitely the right thing, and I'd just started familiarizing myself with the balloon driver source with the intent to add that functionality. An appliance or "instant-on" vm starting from a saved snapshot state would want to aggressively balloon memory down to the absolute minimum before saving and then balloon on restore. The computed-from-maxmem min-mem value doesn't work very well for this use case.
-- Trolle
Dan
Quoted 80 lines
** and bytes? kb? mb? :-)
Quoted 27 lines
-----Original Message-----
From: Ian Jackson [mailto:[email protected]]
Sent: Wednesday, January 07, 2009 4:42 AM
To: Ian Campbell
Cc: Dan Magenheimer; Xen-Devel (E-mail)
Subject: Re: [Xen-devel] 2.6.28 and balloon driverIan Campbell writes ("Re: [Xen-devel] 2.6.28 and balloon driver"):
Quoted 1 line
Looks like the write function uses memparse which
understands the M, K
Quoted 1 line
etc suffixes and defaults to bytes. The ability to say
balloon to <n>M
Quoted 2 lines
is quite nice but for the sake of consistency with the name it's probably preferable to just treat the value as a number of Kbytes.
Since you're changing the name anyway, can't we change the users of the file to understand the new units too ?
Ie, I think we should have
/sys/devices/system/xen_memory/xen_memory0/targe
which when read produces a number of bytes and which uses the default memparse function. If nothing else this is more likely to be something upstream mind less.Ian.
Quoted 7 lines · Dan Magenheimer
I am playing with 2.6.28 on xen. Nice! Thanks Jeremy!
But I have a minor gripe...
The balloon driver now is accessed via a sysfs file, for example:
# SIZE=
cat /sys/devices/system/xen_memory/xen_memory0/target_kbQuoted 8 lines
# echo $SIZE # echo $SIZE > /sys/devices/system/xen_memory/xen_memory0/target_kbSIZE does indeed get current memory size in kbytes, but if one tries to pass SIZE (or slightly smaller value) back, all hell breaks loose because:
1) Despite the name, the value written must be in bytes, not kbytes
Looks like the write function uses memparse which understands the M, K etc suffixes and defaults to bytes. The ability to say balloon to <n>M is quite nice but for the sake of consistency with the name it's probably preferable to just treat the value as a number of Kbytes.
Quoted 2 lines
2) There is no "safety minimum", so writing the same value back actually reduces memory by a factor of 1024!
I guess this just needs porting forward.
Can you provide patches for both these issues?
Ian.
Quoted 14 lines
I realize behavior (1) is backwards-compatible with the existing
/proc/xen/balloonbehavior, but at least that filename doesn't imply a unit size.For (2), as sysadmins grow comfortable with the "safety minimum" that's been implemented in upstream xen now for nearly a year, (users can do:
# echo 0 > /proc/xen/balloonand it still works), some people upgrading to a 2.6.28 kernel are in for a nasty surprise.
Quoted 8 lines
Quoted 1 line
<gripe off>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel