This patch makes the use of controllers available from script more generic.
All possible controllers in Linux kernel are to be kept as enum parameters
and a corresponding mapping is done in both, the script and binary. The
testcases are no more hardcoded with respect to controllers. The function
set_controller() need to be updated with respect to the controllers and
control file.
The challenges yet to be solved are:
(1)Choosing appropriate control file
(2)Choosing appropriate control value dynamicaly.
Balbir Singh [Wed, 17 Dec 2008 15:11:48 +0000 (15:11 +0000)]
libcgroup Test: make-controller-check-generic
The following patch adds support for a dynamical check of controllers and
choosing two of them, which are enabled in the kernel. I have given preference
to the cpu and memory controller if they exist.
I will pass these mounted controllers to the c file(will send implementation in
a next patch) and thus the c file will have no hard coding with respect to any
controller. The reason of chosing script for this part is
1. easy to implement
2. otherwise there wont be any use of script :)
One of my doubts is:
Few controllers(e.g. devices) seems not to be having a control file. Please help
me in finding the control file for each controller. Any link to documentation?
This info I need in the c file.
As per my knowledge the control files are:
*****************************
controller control_file
*****************************
cpu cpu.shares
memory memory.linit_in_bytes
debug
devices
ns
cpuacct
cpuset
Also what type of values can be written to those control files?
I need to take care before i write something stupid to a control file.
Please review the patch and give your valuable comments.
Balbir Singh [Wed, 17 Dec 2008 15:09:32 +0000 (15:09 +0000)]
libcgroup Test: add warnings
Hi,
This patch adds some warnings in case some testcses fail.
When we modify a group with nullcgroup then there is no need to
check if values are changed.
Balbir Singh [Wed, 17 Dec 2008 15:07:35 +0000 (15:07 +0000)]
libcgroup Test: fixed certain rejects
The following patch makes certain cleanups for the patchset to apply without
any rejects. However the lines of code are being changed in one of the next
patches.
Hi
The following patch adds the sanity check in c file for multiple mount case.
The parameter passed to the function decides whether the check is for single
mount or multiple mount.
Balbir Singh [Wed, 17 Dec 2008 15:01:48 +0000 (15:01 +0000)]
libcgroup Test: libcgrouptest-multimnt05
Hi
The following patch adds three testcases for libcg apis create and delete _cgroup()
and wrapper apis for multiple mount case.
The patch creates a valid cgroup structure with two controllers and after
calling to apis performs a check under both controllers.
Balbir Singh [Wed, 17 Dec 2008 15:00:37 +0000 (15:00 +0000)]
libcgroup Test: libcgrouptest-multimnt04
This patch adds a testcase for libcgroup API cgroup_delete_cgroup() testing.
The API is called under the multimount condition(FS_MOUNTED=2) and return
values are checked. The group is checked if it is deleted from the root directory
of the corresponding controller's mountpoint.
Balbir Singh [Wed, 17 Dec 2008 14:59:35 +0000 (14:59 +0000)]
libcgroup Test: libcgrouptest-multimnt03
This patch adds a testcase for libcgroup API cgroup_attach_task() testing.
The API is called under the multimount condition(FS_MOUNTED=2) and return
values are checked. The argument of the api is a valid group under one
controller's(say cpu) mountpoint. This group exist only under one
controller(cpu). So the attached task is checked under this group for this(cpu)
controller and under the root group for the other(memory) controller.
In the second call the argument is a group under other controller(memory)
and hence now task is checked under the two groups of both controllers.
In the third calll we give the argument as a non existing group, so the
return value should be ECGROUPNOTEXIST.
Balbir Singh [Wed, 17 Dec 2008 14:58:42 +0000 (14:58 +0000)]
libcgroup Test: libcgrouptest-multimnt02
This patch adds a testcase for libcgroup API cgroup_create_cgroup() testing.
The API is called under the multimount condition(FS_MOUNTED=2) and return
values are checked. The group is checked if it exists under the root directory
of the corresponding controller's mountpoint.
Balbir Singh [Wed, 17 Dec 2008 14:57:54 +0000 (14:57 +0000)]
libcgroup Test: libcgrouptest-multimnt01
This patch adds a testcase for libcgroup API cgroup_attach_task() testing.
The API is called under the multimount condition(FS_MOUNTED=2) and return
values are checked. The task pid is checked if it exists under the root
group's tasks file of both the mountpoints.
The patch also puts the common code in a function.
Balbir Singh [Wed, 17 Dec 2008 14:56:40 +0000 (14:56 +0000)]
libcgroup Test: multi-mount-script-enhanced
This patch modifies the script to handle multiple mounts. The earlier
functions are modified and new ones are added. There is still some hard
coding with respect to the number of mountpoints and controllers. I will
update this code part once I get an idea of a better design.
Dhaval Giani [Tue, 16 Dec 2008 17:29:38 +0000 (17:29 +0000)]
libcgroup: Add default group to cgconfig
From: Balbir Singh <balbir@linux.vnet.ibm.com>
As discussed in the previous thread
http://article.gmane.org/gmane.comp.lib.libcg.devel/139, we don't have
the concept of default groups and tasks should be able to return back
to their default group when done.
Here is a fix to the cgconfig script to fix the issue. Please review,
comment on it.
Dhaval Giani [Tue, 16 Dec 2008 17:20:11 +0000 (17:20 +0000)]
libcgroup: Fix broken cgred
From: Balbir Singh <balbir@linux.vnet.ibm.com>
cgred is broken, in that there are some checks that fail and we use
--config to start the daemon and that is not supported. We also use
-12 as the signal to killproc.
Dhaval Giani [Tue, 16 Dec 2008 17:14:33 +0000 (17:14 +0000)]
libcgroup: Add default group to cgconfig
From: Balbir Singh <balbir@linux.vnet.ibm.com>
As discussed in the previous thread
http://article.gmane.org/gmane.comp.lib.libcg.devel/139, we don't have
the concept of default groups and tasks should be able to return back
to their default group when done.
Here is a fix to the cgconfig script to fix the issue. Please review,
comment on it.
Balbir Singh [Mon, 1 Dec 2008 09:50:00 +0000 (09:50 +0000)]
From: SanjayKumar J <vjsanjay@gmail.com>
Consistent Error checking for group_admin_perm
Signed-off-by: SanjayKumar J <vjsanjay@gmail.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
[Balbir - change prefix in Makefile to /usr, so that make install does sensible
things]
Dhaval Giani [Mon, 10 Nov 2008 13:10:07 +0000 (13:10 +0000)]
libcgroup: Make cgconfigparser more verbose
As per http://sourceforge.net/tracker/?func=detail&atid=1043649&aid=2128139&group_id=218421
cgconfigparser was not exiting silently for wrong usage. Let's
let the user know they are using wrong syntax.
The automatic classification engine (cgexec, cgclassify, pam_cgroup)
classify tasks. It is useful for an application to know where it has
been classified. I propose to add a new API
cgroup_get_current_controller_path() that returns the current
classification directory for the specified controller. One can easily
add on and build new API that will return paths of all mounted
controllers, but I want to start with something simple and useful.
I've also added a bunch of test cases for the same purpose.
Test output
# ./pathtest.sh
Test FAIL, get path failed for controller cpuset
Test PASS, controller cpu path /default
Test PASS, controller cpuacct path /default
Test PASS, controller memory path /default
Test FAIL, get path failed for controller memrlimit
I mounted just cpu, cpuacct and memory, thus the path for cpuset and
memrlimit could not be found (as expected).
Balbir Singh [Fri, 22 Aug 2008 16:44:17 +0000 (16:44 +0000)]
This patch adds cgroup_create_cgroup_from_parent() API. I've tested it
with a modified version of libcg_ba (basic acceptance tests), that I'll send
out later. I've also fixed a couple of bugs, I'll list them in order and
if desired, I'll split out the patches so that the enhancements can be
separate from the bug fixes
1. Fix cg_create_control_group() to succeed if the directory already exists
2. We can't always append a control_file, we need to open it "r+"
3. It's OK for writing values to a control_file to fail, since some of
them are read-only and some may not exist in hierarchies below the root
4. Skip over directories while trying to read control file's name value pairs
5. In cg_rd_ctlr_file we don't allocate any memory to value, directly fscanf
into it, that's been fixed
6. There might be more fixes that might already be present in trunk, since
I hope I've not redone a lot of the fixes, I had branched of trunk very
recently
Changelog v2
------------
1. Refactor cgroup_free_controllers() and use it in
cgroup_create_cgroup_from_parent()
2. Check for strdup failure
3. Check if dst == src
TODO:
1. Use cg_add_controller() API
2. Use cg_add_value_string() API
I'll send out patches for the TODOs later.
I've also updated the basic acceptance test (libcg_ba.cpp)
Dhaval Giani [Thu, 14 Aug 2008 15:05:48 +0000 (15:05 +0000)]
Fix configuration assert when multiple controllers are enabled
Since we support multiple controllers, asserting is no longer a good
idea.
TODO: Support other controllers, memory, cpu and cpuacct (possibly
cpusets as well). Well, this code is obsolete and will be replaced
by the newer cgroup API.
Dhaval Giani [Thu, 14 Aug 2008 11:10:23 +0000 (11:10 +0000)]
libcgroup: Fix the delete API
The delete call was returning a wrong value even on success.
The reason was because in the fallback path, we try to delete
all the groups again. Now it is possible that a group might
have already been deleted and we return a wrong value.
Change the API to check if the group exists before trying to rmdir
it in the error path.
Dhaval Giani [Wed, 13 Aug 2008 20:04:51 +0000 (20:04 +0000)]
cgclassify: A command line tool to classify/re-classify already running task
From: Vivek Goyal <vgoyal@redhat.com>
o cgclassify, a command line tool to put a list of pids to the right cgroup
based on rules in /etc/cgrules.conf. It can be mainly used for
reclassification of tasks which are already running. Can think of two
use cases.
- During initial bootup, after cgroups are mounted, one needs to
move tasks (started beofore cgroups were mounted) into right
cgroup.
- Once can choose to reclassify the tasks if admin has changed the
rules and thinks a group of tasks should reclassified based on
new rules.
Dhaval Giani [Wed, 13 Aug 2008 20:01:16 +0000 (20:01 +0000)]
cgexec: A command line tool to execute a task in a cgroup
From: Vivek Goyal <vgoyal@redhat.com>
o cgexec, a command line tool for placing the task in right cgroup
in advance so that no help is needed from rules daemon and user can
avoid delay in execution of rules.
Dhaval Giani [Wed, 13 Aug 2008 19:58:05 +0000 (19:58 +0000)]
libcgroup: New API interfaces for task placement
From: Vivek Goyal <vgoyal@redhat.com>
Enhancement to libcg to do following.
- Parse the /etc/cgrules.conf file and place the task in the right cgroup.
- Exported two APIs which can place the task based on /etc/cgrules.conf
or based on cgroup explicitly specified by the caller.
- There can be multiple users.
- PAM module (pam_cgroup)
- cgexec tool
- cgclassify tool
- APIs can be directly used by other cgroup aware user progarams.
- Classification daemon
Dhaval Giani [Wed, 13 Aug 2008 13:33:59 +0000 (13:33 +0000)]
libcgroup: check for return code of fprintf()
From: Vivek Goyal <vgoyal@redhat.com>
o Adding a task to a particular cgroup currently does fprintf() and never
check the return code. Modify it to check for the return code in case
fprintf() and fflush() did not succeed.
o I ran into the issues when i can't add migration thread to
/container/admingroup/tasks and it will fail silently.
Dhaval Giani [Tue, 12 Aug 2008 08:21:08 +0000 (08:21 +0000)]
libcgroup: Extend cgroup_get_cgroup for uids as well.
Now that a new API is available which allows a cgroup structure to
be generated with just a name, extend cgroup_get_cgroup to get the
uids and gids from the fs itself.
Dhaval Giani [Tue, 12 Aug 2008 08:19:24 +0000 (08:19 +0000)]
libcgroup: Add cgroup_?et_value_* APIs
Adding in APIs which allow you to set and get values from a cgroup
controller. Use cgroup_get_controller to get a controller, and then
use cgroup_?et_value_* API for your requirement.
Dhaval Giani [Sat, 9 Aug 2008 09:27:30 +0000 (09:27 +0000)]
libcgroup: Fix the wrapper warnings
Fixes the following warnings
wrapper.c: In function ‘cgroup_add_value_int64’:
wrapper.c:152: warning: format ‘%lld’ expects type ‘long long int’, but argument 4 has type ‘int64_t’
wrapper.c:152: warning: format ‘%lld’ expects type ‘long long int’, but argument 4 has type ‘int64_t’
wrapper.c: In function ‘cgroup_add_value_uint64’:
wrapper.c:186: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 4 has type ‘u_int64_t’
wrapper.c:186: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 4 has type ‘u_int64_t’
Dhaval Giani [Sat, 9 Aug 2008 09:25:22 +0000 (09:25 +0000)]
libcgroup: Fix index values in cgroup_add_value_*
There is a horrible bug in wrapper.c. The loop was causing a segmentation
fault. This is because we were checking for index value as opposed to
i.
This bug was not hit before, because in all our testing, we were
trying out only with CONFIG_FAIR_GROUP_SCHED and we were setting only one
value inside the memory subsystem.
Dhaval Giani [Sat, 9 Aug 2008 09:23:56 +0000 (09:23 +0000)]
libcgroup: Fix segmentation fault in cgroup_init() -take2
An artifact from the time when libcgroup could not handle multiple
cgroup filesystems mounted at multiple points. It is very much possible
a subsystem is not mounted at that point. (FWIW, it is wrong even on a
single mount point, but I am quite surprised that no one hit it yet.)
Dhaval Giani [Wed, 6 Aug 2008 17:47:41 +0000 (17:47 +0000)]
libcgroup: Add new API to get cgroup data structure from filesystem
New API to get the cgroup datastructure from the mounted filesystem.
It accepts the cgroup datastructure with the name of the cgroup
which has to populated across various mountpoints.
TODO:
More testing.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Dan Smith <danms@us.ibm.com> Cc: Paul Menage <menage@google.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@117 4f4bb910-9a46-0410-90c8-c897d4f1cd53
libcgroup: Fix test cases to use CPU controller if available
The test cases used the memory controller. This is not a good idea
since most distro kernels don't enable it by default. For the moment
I'm setting it to use CPU if memory is not found, but in the longer
term I am planning to set it to use CPU first and then memory.
libcgroup: adds sanity check in libcgroup testcases binary
This patch adds a sanity check on cgroup file system info in testcases.
If cgroup filesystem is not mounted and script sends the info as mounted,
then the binar would have failed. This patch handles that.
This patch adds testcases for libcgroup API cgroup_modify_cgroup() testing. The API
is called with filesystem mounted (FS_MOUNTED=1) and return values are checked.
The API is first called with the same cgroup(the one which is existing in the
file system, and with all the same parameters). The second time it is called
with a null cgroup. Third time it is called with a new cgroup having different
controller.
The filesystem is checked if the values have been modified.