Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1106656

Summary: Docker run --memory value doesn't match cgroup value
Product: Red Hat Enterprise Linux 7 Reporter: Chris Evich <cevich>
Component: dockerAssignee: Matthew Heon <mheon>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.0CC: bsarathy, dwalsh, gouyang, jrieden, lsu, sghosh
Target Milestone: rcKeywords: Documentation
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-18 20:45:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1109938    

Description Chris Evich 2014-06-09 17:00:46 UTC
Description of problem:
Some values to the --memory option result in an exact match to the cgroup value, others are slightly off.  If expected, then this could be fixed with a documentation update.

Version-Release number of selected component (if applicable):
docker-0.11.1-10.el7.x86_64

How reproducible:
very

Steps to Reproduce:

docker run -d -t -m 524889 some_image bash
...
cat /sys/fs/cgroup/memory/system.slice/.../memory.limit_in_bytes 
5246976

Same result for --memory 524889 value suffixes of:
b and B  => cgroup: 5246976
k and K  => cgroup: 5368721408

Suffixes for 'm' and 'g' seem to correctly represent specified value.

Actual results:
Values specified on command line sometimes don't match value in cgroup file

Expected results:
Values from command line should match value in cgroup file, a message should
be printed or logged if the value is altered, and/or value manipulation/conformity rules should be documented for the --memory option.

Comment 1 Guohua Ouyang 2014-06-10 01:56:53 UTC
I think I caught this, the memory size must be a multiper of 4096.

I tested below:
set memory limits    crgoup memory limits
=================    ========================
1024m                1073741824
1g                   1073741824
1048576k             1073741824
1073741824           1073741824
1048576              1048576
1024575              1048576
1048577              1052672 (1048576 + 4096)
1052673              1056768 (1052672 + 4096)
=================    ========================

so this should be not a bug.

Comment 2 Guohua Ouyang 2014-06-10 02:13:41 UTC
for the example in the bug, 524889 is between 524288 ~ 528384, so the value in cgroups should be the later.

#docker run -d -t -m 524889 some_image bash

# cat docker-dd95e808b318c29f3f79266118768d4cd196f3a9f2eea88bc8d473a71b58b27d.scope/memory.limit_in_bytes 
528384

>>>528384 - 524288 (1024*4*(524889 / 4096)
4096

Comment 3 Chris Evich 2014-06-10 14:59:48 UTC
Great, thanks for confirming.  Moving this to 'low' severity then since it'll just be a short documentation/man page update then.  I'd suggest something like:

The value may be rounded up to the next multiple of the host's memory page size(?) (typically 4k) unless an exact multiple is given.

Comment 4 Matthew Heon 2014-06-25 16:47:59 UTC
Patch sent to upstream for this (https://github.com/dotcloud/docker/pull/6680). Should appear in our builds of docker-1.0 for RHEL7 soon.

Comment 5 Daniel Walsh 2014-06-27 16:26:44 UTC
Fixed in docker-1.0

Comment 10 errata-xmlrpc 2014-09-18 20:45:44 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1266.html