libxl: fix dom0 balloon logic
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 38 lines · Jim Fehlig
Recent testing on large memory systems revealed a bug in the Xen xl tool's
freemem()function. When autoballooning is enabled,freemem()is used to ensure enough memory is available to start a domain, ballooning dom0 if necessary. When ballooning large amounts of memory from dom0,freemem()would exceed its self-imposed wait time and return an error. Meanwhile, dom0 continued to balloon. Starting the domain later, after sufficient memory was ballooned from dom0, would succeed. The libvirt implementation inlibxlDomainFreeMem()suffers the same bug since it is modeled afterfreemem().In the end, the best place to fix the bug on the Xen side was to slightly change the behavior of
libxl_wait_for_memory_target(). Instead of failing after caller-providedwait_sec, the function now blocks as long as dom0 memory ballooning is progressing. It will return failure only when more memory is needed to reach the target andwait_sechave expired with no progress being made. See xen.git commitfd3aa246. There was a dicussion on how this would affect other libxl apps like libvirthttp://lists.xen.org/archives/html/xen-devel/2015-03/msg00739.html
If libvirt containing this patch was build against a Xen containing the old
libxl_wait_for_memory_target()behavior,libxlDomainFreeMem()will fail after 30 sec and domain creation will be terminated. Without this patch and with oldlibxl_wait_for_memory_target()behavior,libxlDomainFreeMem()does not succeed after 30 sec, but returns success anyway. Domain creation continues resulting in all sorts of fun stuff like cpu soft lockups in the guest OS. It was decided to properly fixlibxl_wait_for_memory_target(), and if anything improve the default behavior of apps using the freemem reference impl in xl.xl was patched to accommodate the change in
libxl_wait_for_memory_target()with xen.git commit883b30a0. This patch does the same in the libxl driver. While at it, I changed the logic to essentially matchfreemem()in$xensrc/tools/libxl/xl_cmdimpl.c. It was a bit cleaner IMO and will make it easier to spot future, potentially interesting divergences.
Quoted 6 lines
Signed-off-by Jim Fehlig <[email protected]>---
V3:
Remove unneeded local variable 'ret' in libxlDomainFreeMem.
ACK
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): 20150402144027.GE15852@wheatley
Quoted 40 lines · Martin Kletzander
Quoted 39 lines · Jim Fehlig
Recent testing on large memory systems revealed a bug in the Xen xl tool's
freemem()function. When autoballooning is enabled,freemem()is used to ensure enough memory is available to start a domain, ballooning dom0 if necessary. When ballooning large amounts of memory from dom0,freemem()would exceed its self-imposed wait time and return an error. Meanwhile, dom0 continued to balloon. Starting the domain later, after sufficient memory was ballooned from dom0, would succeed. The libvirt implementation inlibxlDomainFreeMem()suffers the same bug since it is modeled afterfreemem().In the end, the best place to fix the bug on the Xen side was to slightly change the behavior of
libxl_wait_for_memory_target(). Instead of failing after caller-providedwait_sec, the function now blocks as long as dom0 memory ballooning is progressing. It will return failure only when more memory is needed to reach the target andwait_sechave expired with no progress being made. See xen.git commitfd3aa246. There was a dicussion on how this would affect other libxl apps like libvirthttp://lists.xen.org/archives/html/xen-devel/2015-03/msg00739.html
If libvirt containing this patch was build against a Xen containing the old
libxl_wait_for_memory_target()behavior,libxlDomainFreeMem()will fail after 30 sec and domain creation will be terminated. Without this patch and with oldlibxl_wait_for_memory_target()behavior,libxlDomainFreeMem()does not succeed after 30 sec, but returns success anyway. Domain creation continues resulting in all sorts of fun stuff like cpu soft lockups in the guest OS. It was decided to properly fixlibxl_wait_for_memory_target(), and if anything improve the default behavior of apps using the freemem reference impl in xl.xl was patched to accommodate the change in
libxl_wait_for_memory_target()
with xen.git commit883b30a0. This patch does the same in the libxl driver. While at it, I changed the logic to essentially matchfreemem()in$xensrc/tools/libxl/xl_cmdimpl.c. It was a bit cleaner IMO and will make it easier to spot future, potentially interesting divergences.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Jim Fehlig <[email protected]>---
V3:
Remove unneeded local variable 'ret' in libxlDomainFreeMem.ACK
Thanks! I've pushed this now.
Regards,
Jim