Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 619037 - balloon.free: dom0_alloc should be in KiB
balloon.free: dom0_alloc should be in KiB
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: xen (Show other bugs)
5.5
All Linux
low Severity medium
: rc
: ---
Assigned To: Xen Maintainance List
Virtualization Bugs
: Regression
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-28 08:31 EDT by Andrew Jones
Modified: 2011-01-13 17:23 EST (History)
4 users (show)

See Also:
Fixed In Version: xen-3.0.3-115.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-01-13 17:23:16 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
balloon.free: dom0_alloc should be in KiB (1.84 KB, patch)
2010-07-28 08:54 EDT, Andrew Jones
no flags Details | Diff
balloon.free: dom0_alloc should be in KiB (1.59 KB, patch)
2010-07-28 10:32 EDT, Andrew Jones
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0031 normal SHIPPED_LIVE xen bug fix and enhancement update 2011-01-12 10:59:24 EST

  None (edit)
Description Andrew Jones 2010-07-28 08:31:16 EDT
dom0_alloc is getting set in MiB, but all uses of it expect it to be in
KiB, except for the setMemoryTarget() call. A fresh look at dom0's
allocation should be used at that point anyway. Change dom0_alloc to KiB
and change the setMemoryTarget() to use the current allocation divided
by 1024. This change matches upstream.
Comment 1 Andrew Jones 2010-07-28 08:54:05 EDT
Created attachment 434998 [details]
balloon.free: dom0_alloc should be in KiB
Comment 2 Andrew Jones 2010-07-28 10:32:04 EDT
Created attachment 435035 [details]
balloon.free: dom0_alloc should be in KiB
Comment 3 Andrew Jones 2010-07-28 10:33:05 EDT
I self NACKed the original version of this patch since the dom0_origMem concept makes more sense. We should reset dom0's memory back that way it was if the dom0 ballooning fails.
Comment 4 Miroslav Rezanina 2010-07-29 07:54:30 EDT
Fix for BZ #580509 miss the dom0_alloc assignment. So this patch fixes regression introduced by that fix.
Comment 9 Andrew Jones 2010-08-19 10:34:06 EDT
Note to QA how to test:

1) Disable dom0 ballooning by setting (dom0-min-mem 0) to zero in /etc/xen/xend-config.sxp
2) Set dom0's memory with 'xm mem-set' to "total memory" - 750M
3) Boot a guest with 500M memory
4) Attempt to 'xm mem-set' the guest to 1G
5) The ballooning will fail with our without the patch (there's not enough free memory and no dom0 ballooning enabled)
6) Check the xend logs and you should see without the patch that we attempt multiple times to get the memory since we didn't know we should fail immediately due to the improper calculation, with the patch it should fail immediately

I didn't try this myself, but I'm pretty sure that's what will happen based on the code.

Drew
Comment 11 Yufang Zhang 2010-08-24 08:51:41 EDT
(In reply to comment #9)
> Note to QA how to test:
> 
> 1) Disable dom0 ballooning by setting (dom0-min-mem 0) to zero in
> /etc/xen/xend-config.sxp
> 2) Set dom0's memory with 'xm mem-set' to "total memory" - 750M
> 3) Boot a guest with 500M memory
> 4) Attempt to 'xm mem-set' the guest to 1G
> 5) The ballooning will fail with our without the patch (there's not enough free
> memory and no dom0 ballooning enabled)
> 6) Check the xend logs and you should see without the patch that we attempt
> multiple times to get the memory since we didn't know we should fail
> immediately due to the improper calculation, with the patch it should fail
> immediately
> 
> I didn't try this myself, but I'm pretty sure that's what will happen based on
> the code.
> 
> Drew

Hi Andrew, 

I am confused about your steps. If dom0-min-mem is set as 0, code path will never get to dom0.setMemoryTarget(dom0_origMem / 1024), but just throw out a exception. Am I right?

Yufang
Comment 12 Andrew Jones 2010-08-24 09:18:18 EDT
(In reply to comment #11)
> I am confused about your steps. If dom0-min-mem is set as 0, code path will
> never get to dom0.setMemoryTarget(dom0_origMem / 1024), but just throw out a
> exception. Am I right?

We're not testing

dom0.setMemoryTarget(dom0_origMem / 1024)

That part of the patch is just a necessary change in order to correct the size there, after truly correcting the size above.

We're testing

132         if dom0_min_mem > 0:
133             max_free_mem = total_mem - dom0_min_mem
134         else:
135             max_free_mem = total_mem - dom0_alloc

which is broken without this patch (since total_mem is in KB), and then max_free_mem is used to calculate 'retries' which is used to decide whether or not we even try to balloon. As I outlined above in my test steps, before this patch we will try multiple times and then fail (you need to look in the logs to see that). With this patch we will fail immediately (no trying logs). In both cases you'll fail with 

"Not enough free memory and dom0_min_mem is 0"

which is probably the exception you're referring to.  Please check the code again and you'll see what I mean.

Andrew
Comment 13 Yufang Zhang 2010-08-25 02:02:30 EDT
(In reply to comment #12)
> (In reply to comment #11)
> > I am confused about your steps. If dom0-min-mem is set as 0, code path will
> > never get to dom0.setMemoryTarget(dom0_origMem / 1024), but just throw out a
> > exception. Am I right?
> 
> We're not testing
> 
> dom0.setMemoryTarget(dom0_origMem / 1024)
> 
> That part of the patch is just a necessary change in order to correct the size
> there, after truly correcting the size above.
> 
> We're testing
> 
> 132         if dom0_min_mem > 0:
> 133             max_free_mem = total_mem - dom0_min_mem
> 134         else:
> 135             max_free_mem = total_mem - dom0_alloc
> 
> which is broken without this patch (since total_mem is in KB), and then
> max_free_mem is used to calculate 'retries' which is used to decide whether or
> not we even try to balloon. As I outlined above in my test steps, before this
> patch we will try multiple times and then fail (you need to look in the logs to
> see that). With this patch we will fail immediately (no trying logs). In both
> cases you'll fail with 
> 
> "Not enough free memory and dom0_min_mem is 0"
> 
> which is probably the exception you're referring to.  Please check the code
> again and you'll see what I mean.
> 
> Andrew

Thanks Andrew, I got what you mean. Testing this bug with xen-3.0.3-114 and xen-3.0.3-115 according to your steps in comment #9:

1. Disable dom0 ballooning by setting (dom0-min-mem 0) to zero in
/etc/xen/xend-config.sxp
2. Set dom0's memory with 'xm mem-set' to "total memory" - 4096M
3. Create a guest with memory set as 512M  

ballooning failed on both xen-3.0.3-114 and xen-3.0.3-115. But for xen-3.0.3-114, ballooning tried for 20 times until failed, as shown in xend.log:

[2010-08-24 22:52:25 xend 2596] DEBUG (balloon:154) Balloon: 391432 KiB free; 0 to scrub; need 524288; retries: 20.
[2010-08-24 22:52:46 xend.XendDomainInfo 2596] ERROR (XendDomainInfo:219) Domain construction failed
Traceback (most recent call last):
  File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 212, in create
    vm.initDomain()
  File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 2078, in initDomain
    balloon.free(memory + shadow + vtd_mem)
  File "/usr/lib64/python2.4/site-packages/xen/xend/balloon.py", line 181, in free
    raise VmError(('Not enough free memory and dom0_min_mem is 0, so '

For xen-3.0.3-115, ballooning failed immediately.

So change this bug to VERIFIED.
Comment 15 errata-xmlrpc 2011-01-13 17:23:16 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0031.html

Note You need to log in before you can comment on or make changes to this bug.