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 622462

Summary: Not possible to set memory.memsw.limit_in_bytes
Product: Red Hat Enterprise Linux 6 Reporter: schurzi <redhat>
Component: libcgroupAssignee: Ivana Varekova <varekova>
Status: CLOSED ERRATA QA Contact: Petr Beňas <pbenas>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: ajia, jsafrane, ovasik, pbenas, pstehlik, rvokal
Target Milestone: rcKeywords: RHELNAK
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 13:13:11 UTC Type: ---
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: 672300    

Description schurzi 2010-08-09 12:51:40 UTC
Description of problem:
It is not possible to set memory.memsw.limit_in_bytes BEFORE setting memory.limit_in_bytes. The cgconfig init script (and thus the cgconfigparser tool) does not respect this sequence. The root cause is, that memory.memsw.limit_in_bytes can not be smaler than memory.limit_in_bytes.

Version-Release number of selected component (if applicable):
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.0 Beta (Santiago)
# rpm -qa libcgroup
libcgroup-0.36.1-5.el6.x86_64

How reproducible:
Try to start the init script /etc/init.d/cgconfig or use the tool "cgconfigparser -l /etc/cgconfig.conf". cgset is also affected.

The contents of /etc/cgconfig.conf:
--- snip ---
mount {
        memory  = /cgroup/memory;
}

group mysql {
        memory {
                memory.limit_in_bytes=8G;
                memory.memsw.limit_in_bytes=10G;
        }
}
--- snip ---


Steps to Reproduce:
1. copy the contents of the pasted /etc/cgconfig.conf
2. try to run /etc/init.d/cgconfig or cgconfigparser -l /etc/cgconfig.conf

OR

1. mount -t cgroup -o memory none /cgroup/
2. cgcreate -g memory:mysql
3. cgset -r memory.memsw.limit_in_bytes=10G mysql
ERROR: cgset: the group can't be modified

Note that setting memory.limit_in_bytes and after that setting memory.memsw.limit_in_bytes works:
# cgset -r memory.limit_in_bytes=10G mysql
# cgset -r memory.memsw.limit_in_bytes=10G mysql

  
Actual results:
An error is printed out and no cgroups are configured.

# strace -e write,open cgconfigparser -l /etc/cgconfig.conf
...
open("/cgroup/memory/mysql/memory.memsw.limit_in_bytes", O_RDWR) = 4
write(4, "10G", 3)                      = -1 EINVAL (Invalid argument)
...
open("/cgroup/memory/mysql/memory.limit_in_bytes", O_RDWR) = 4
write(4, "8G", 2)                       = 2
...

Expected results:
# strace -e write,open cgconfigparser -l /etc/cgconfig.conf
...
open("/cgroup/memory/mysql/memory.memsw.limit_in_bytes", O_RDWR) = 4
write(4, "10G", 3)                      = 3
...
open("/cgroup/memory/mysql/memory.limit_in_bytes", O_RDWR) = 4
write(4, "8G", 2)                       = 2
...

Additional info:
Don't know, if this is to be accounted as a problem of the tools or the kernel module. Also I am not sure what is the best way to fix this issue. I think there are two possible solutions for this:
- change the order in which the keys are set (in cgconfigparser)
- make setting memory.memsw.limit_in_bytes also set memory.limit_in_bytes to the same value

Comment 2 RHEL Program Management 2010-08-09 13:07:54 UTC
This issue has been proposed when we are only considering blocker
issues in the current Red Hat Enterprise Linux release.

** If you would still like this issue considered for the current
release, ask your support representative to file as a blocker on
your behalf. Otherwise ask that it be considered for the next
Red Hat Enterprise Linux release. **

Comment 3 Jan Safranek 2010-08-11 08:37:53 UTC
There are two issues:

1) kernel expects memory.limit_in_bytes to be set before memory.memsw.limit_in_bytes, wrong order results in the error you see in strace (EINVAL). This probably cannot be fixed, this is how cgroups works in kernel.

2) cgconfigparser writes the values from cgconfig.conf to the kernel in reverse order (the last parameter of a group in cgconfig.conf is written first, as you see in the strace). This is something we can fix.

As temporary workaround, write the parameters cgconfig.conf in reverse order:

group mysql {
        memory {
                memory.memsw.limit_in_bytes=10G;
                memory.limit_in_bytes=8G;
        }
}

Comment 4 schurzi 2010-08-20 20:27:59 UTC
The temporary workaround is working fine, but I would like you to consider this issue a blocker since one can break a configuration by adding valid parameters. 

I understand that he kernel part can't be "fixed" and is working as intended.

But the cgconfigparser code should be fixed in this release an not in a future release.

Comment 5 Jan Safranek 2011-01-12 09:23:35 UTC
cgconfig has been fixed to write parameter values in the same order as they are present in cgconfig.conf

Comment 8 Petr Beňas 2011-01-31 13:04:18 UTC
Reproduced in libcgroup-0.36.1-6.el6 and verified in libcgroup-0.37-1.el6.

Comment 9 errata-xmlrpc 2011-05-19 13:13:11 UTC
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-0577.html