summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* This patch adds to cgget option -a:Ivana Hutarova Varekova2010-02-101-14/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | v2: removed bunch of unnecessary error messages This patch adds to cgget option -a: -a print the variables for all controllers which consists given cgroup EXAMPLE: $ ./cgget -a /daemons /daemons: cpuset.memory_spread_slab=0 cpuset.memory_spread_page=0 cpuset.memory_pressure=0 cpuset.memory_migrate=0 cpuset.sched_relax_domain_level=-1 cpuset.sched_load_balance=1 cpuset.mem_hardwall=0 cpuset.mem_exclusive=0 cpuset.cpu_exclusive=0 cpuset.mems= cpuset.cpus= cpuacct.stat=user 0 system 0 cpuacct.usage_percpu=0 0 cpuacct.usage=0 Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* adds new option -g to cgget commandIvana Hutarova Varekova2010-02-101-42/+152
| | | | | | | | | | | | | | | | | | | adds new option -g to cgget command * the option has one argument - controller * cgget -g devices / returns the values of all variables of controller devices * the option could be used multiple times EXAMLES: $ ./cgget -n -g cpu -r cpuset.mems / cpu.rt_period_us=1000000 cpu.rt_runtime_us=950000 cpu.shares=1024 cpuset.mems=0 Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* api for generating the list of variables of given controllerIvana Hutarova Varekova2010-02-102-0/+26
| | | | | | | | | | | | | | | api for generating the list of variables of given controller: changelog - v2: fixed the space on the end of lines * int cgroup_get_value_name_count(struct cgroup_controller, *controller) functions return the number of variables in "controller" * char *cgroup_get_value_name(struct cgroup_controller *controller, int index) function return the "index" variable of "controller" Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* [PATCH-v2] Add the write error handling to cg_set_control_value().Ken'ichi Ohmichi2010-01-281-2/+9
| | | | | | | | | | | | | | Changelog since v1: o Use fopen/fprintf/fclose instead of open/write/close. o Add the error handling against fclose. cg_set_control_value() is the function for setting a value to a file of cgroup file system. And current function does not handle the error of writing to a file. So we cannot know whether setting value is enable or not. This patch add the error handling for knowing it. Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* libcgroup: Modify the APIs to use the namespaceDhaval Giani2010-01-071-1/+7
| | | | | | | | | | | Since every API builds its patch via build_path, updating that function should be enough. Changes from v1: 1. Append the namespace only if it is defined. This will remove an additional "/" which would be introduced otherwise. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Setup the namespace datastructuresDhaval Giani2010-01-073-3/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch handles the validation of the newer configuration files. Some of the rules to be followed 1. We cannot have more controllers in the namespcae section than already mounted. 2. If more than one controller are mounted at the same point, then they will have the same namespace. In case it is not explicitly mentioned, the subsystems at the mount point will be set to the same namespace. This does not mean that controllers mounted at different points need to have the same namespace. Changes from v4: 1. Changed a variable name from mount to mount_path 2. Added more comments Changes from v3: 1. Removed most of the strdups 2. Fixed return values for errors Changes from v2: 1. mount and namespace keyword cannot come in the same file. Changes from v1: 1. Fix a bug where if a namespace was not defined, we were not exiting 2. Comment the validate namespace function 3. Make some of the variables more descriptive 4. Make namespace thread specific Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Introduce the new namespace keywordDhaval Giani2010-01-074-7/+79
| | | | | | | | | | | | | | | This patch introduces a new keywork NAMESPACE which allow cgroups to be created starting from a certain point as mentioned by the administrator. This is provided via the configuration file. Newer APIs will use this feature. Changes from v1: 1. Attempted to fix the indentation 2. Change a variable name Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* libcgroup: Remove assert in cgroup_strerror()Dhaval Giani2010-01-041-1/+1
| | | | | | | Since we add new errors after ECGSENTINEL, it makes no sense to have the assert in place. Remove the assert. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Make cgclear quiert when there is nothing to clear.Jan Safranek2009-12-221-0/+3
| | | | | | | Cgclear clears and unmounts all controllers. Therefore I think it's not an error when there is nothing to clear and unmount. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Remove trailing space from lssubsys outputJan Safranek2009-12-221-2/+2
| | | | | | | Remove trailing space from lssubsys output, it can confuse scripts. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix reading of empty parameter valuesJan Safranek2009-12-221-3/+7
| | | | | | | | | | | When a group parameter has empty value (like uninitialized cpuset.cpus), libcgroup does not return this parameter value - it returns ECGROUPVALUENOTEXIST instead. I think reading whole parameter file instead of just '%s' is the right thing to do - it helps also with multiline values, like cpuacct.stat. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* Fix error text on failed reading of parameter.Jan Safranek2009-12-221-1/+1
| | | | | | | | | | ECGROUPVALUENOTEXIST is translated by cgroup_strerr to "Cgroup trying to set value for control that does not exist". This is wrong, because the error code is being returned also when *reading* non-existing value, I propose "Cgroup, requested group parameter does not exist". Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* cgget toolJan Safranek2009-12-222-1/+197
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a tool to query for parameter values. The syntax is very similar to cgset, including IMHO ugly group specification without list of controllers. Usage: cgget [-nv] -r <param. name> [-r <param. name>] [...] <path to group> [...] -n - no headers -v - print values only (no parameter names) Example: $ cgget -r cpuset.cpus / /second /: cpuset.cpus=0-1 /second: cpuset.cpus=1 $ cgget -nv -r cpuset.cpus / /second 0-1 1 Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* libcgroup: trivial: Fix typoDhaval Giani2009-12-161-1/+1
| | | | | | opened is spelled as opened and not opend Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix an invalid access to yytext.Ken'ichi Ohmichi2009-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, I tested "cgconfig" service with a big /etc/cgconfig.conf file, and the service failed by signal SIGSEGV. There are two problems. The first is that "cgconfig" service fails with a big /etc/cgconfig.conf file. The second is that the error handling is stopped by signal SIGSEGV. This patch fixes the second problem. The following is the gdb output of the problem. You can see the problem happens in yyerror(). # gdb cgconfigparser (gdb) run -l /etc/cgconfig.conf Starting program: /usr/local/sbin/cgconfigparser -l /etc/cgconfig.conf [Thread debugging using libthread_db enabled] [New Thread 139764254320624 (LWP 15169)] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 139764254320624 (LWP 15169)] 0x00007f1d66bd1604 in yyerror (s=0x7f1d66bd955a "syntax error") at parse.y:30 30 fprintf(stderr, "error at line number %d at %c:%s", line_no, *yytext, (gdb) bt #0 0x00007f1d66bd1604 in yyerror (s=0x7f1d66bd955a "syntax error") at parse.y:30 #1 0x00007f1d66bd1a9e in yyparse () at parse.c:1689 #2 0x00007f1d66bd79b5 in cgroup_config_load_config ( pathname=<value optimized out>) at config.c:467 #3 0x00000000004008a3 in main (argc=3, argv=0x7fffa20c8358) at cgconfig.c:60 (gdb) This problem is due to an invalid access to yytext, and this patch fixes it. (If you need a big /etc/cgconfig.conf file for reproducing the problem, please let me know it. I will send it to you without the mailing list.) Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix a memory leak in "cgconfig" service.Ken'ichi Ohmichi2009-12-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, When I operated "cgconfig" service on valgrind, I found a memory leak like the following: # cat /etc/cgconfig.conf mount { cpuset = /cgroup/cpuset; cpu = /cgroup/cpu; memory = /cgroup/memory; } group user000 { cpuset { cpuset.cpus = 0; cpuset.mems = 0; } } group user000/sleep000 { cpuset { cpuset.cpus = 0; cpuset.mems = 0; } } # valgrind --tool=memcheck --leak-check=yes cgconfigparser -l /etc/cgconfig.conf ==13095== Memcheck, a memory error detector. ==13095== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al. ==13095== Using LibVEX rev 1658, a library for dynamic binary translation. ==13095== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP. ==13095== Using valgrind-3.2.1, a dynamic binary instrumentation framework. ==13095== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al. ==13095== For more details, rerun with: -v ==13095== ==13095== ==13095== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1) ==13095== malloc/free: in use at exit: 43,062 bytes in 10 blocks. ==13095== malloc/free: 129 allocs, 119 frees, 85,399 bytes allocated. ==13095== For counts of detected errors, rerun with: -v ==13095== searching for pointers to 10 not-freed blocks. ==13095== checked 6,795,480 bytes. ==13095== ==13095== 28 bytes in 2 blocks are definitely lost in loss record 1 of 5 ==13095== at 0x4A0590B: realloc (vg_replace_malloc.c:306) ==13095== by 0x4C0CC24: yyparse (parse.y:117) ==13095== by 0x4C12914: cgroup_config_load_config (config.c:467) ==13095== by 0x4008A2: main (cgconfig.c:60) ==13095== ==13095== LEAK SUMMARY: ==13095== definitely lost: 28 bytes in 2 blocks. ==13095== possibly lost: 0 bytes in 0 blocks. ==13095== still reachable: 43,034 bytes in 8 blocks. ==13095== suppressed: 0 bytes in 0 blocks. ==13095== Reachable blocks (those to which a pointer was found) are not shown. ==13095== To see them, rerun with: --show-reachable=yes # This patch fixes the memory leak. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix compilation outside of source directoryJan Safranek2009-12-164-5/+5
| | | | | | | | | | | | | | | Configure script can be invoked outside of source directory, which allows to compile sources without spoiling the source directory with compilation artifacts (like .o files). This patch tries to fix our Makefiles to allow this to work. You can test it in current GIT checkout (in the root dir): # mkdir build; cd build; ../configure; make As result, you should see all binary files in the 'build' directory. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix cgroup_get_all_controller_{begin, next, end} apiIvana Hutarova Varekova2009-12-161-9/+0
| | | | | | | remove the cgroup_initialized need from all of them - not needed Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* lssubsys: new option -a,--allIvana Hutarova Varekova2009-12-161-6/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds new option to lssubsys command lssubsys with this option displays moreover controllers which are not mounted The patch change the behavior of lssubsys a bit - there is no error message if controllers are not mounted and lssubsys is called. Example: $ ./lssubsys -a devices cpuset,cpuacct ns cpu $ ./lssubsys -am devices /mnt/cgroups/devices cpuset,cpuacct /mnt/cgroups/cpuset ns cpu $ ./lssubsys Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix a cgconfig behavior of wrong /etc/cgconfig.conf.Ken'ichi Ohmichi2009-11-112-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changelog since v2: o Avoid breaking ABI by changing the ECGCONFIGPARSEFAIL value. Changelog since v1: o Change a parser error value of /etc/cgconfig.conf to ECGCONFIGPARSEFAIL. The cgconfig service succeeds even if there are something wrong in /etc/cgconfig.conf. For example, it succeeds even if specifying not-existing user (nouser) as a perm.task.uid like the following: # cat /etc/cgconfig.conf mount { cpuset = /mnt/cgroups/cpuset; memory = /mnt/cgroups/memory; } group root { perm { task { uid = nouser; gid = root; } admin { uid = root; gid = root; } } cpuset { cpuset.cpus = 0; cpuset.mems = 0; } memory { memory.use_hierarchy = 1; memory.limit_in_bytes = 1000000000000; } } # # service cgconfig start Starting cgconfig service: parsing failed at line number 10 [ OK ] # echo $? 0 # That is not a good behavior and the cgconfig service should fail if there are something wrong in /etc/cgconfig.conf. This patch fixes the behavior. In the above case, the behavior is changed like the following by this patch: # service cgconfig start Starting cgconfig service: parsing failed at line number 10 Loading configuration file /etc/cgconfig.conf failed Cgroup parsing failed Failed to parse /etc/cgconfig.conf [FAILED] # Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Define ECGRULESPARSEFAIL for the parser error of cgrules.conf.Ken'ichi Ohmichi2009-11-111-2/+2
| | | | | | | | | | | | | | | Changelog since v2: o Define ECGRULESPARSEFAIL for avoiding breaking ABI. Changelog since v1: o A new patch [Cleanup: Rename ECGROUPPARSEFAIL to ECGRULESPARSEFAIL.] Now ECGROUPPARSEFAIL is defined for a parser error of /etc/cgrules.conf and this patch defines ECGRULESPARSEFAIL for the same value for clarifying its meaning. Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add copyright header to cgcreateIvana Hutarova Varekova2009-11-111-0/+15
| | | | | Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Allow cgcreate to create unlimited nr. of groupsJan Safranek2009-11-011-8/+17
| | | | | | | | | Don't limit the number of groups cgcreate can create, allocate them dynamically. The size of allocated space for the group is only aproximate, but still should be better than hard CG_HIER_MAX. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Allow cgdelete to process unlimited nr. of groupsJan Safranek2009-11-011-8/+18
| | | | | | | | Don't limit the number of groups cgdelete can remove, allocate them dynamically. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Remove the CG_HIER_MAX from tools-commonJan Safranek2009-11-017-11/+22
| | | | | | | | | | | | Some libcgroup tools are limited to CG_HIER_MAX arguments. This hard limit is suitable only to some of the tools, namely cgdelete and cgcreate should not be limited to any particular numbers of groups to create/delete. This patches removes the hard limit from tools-common.c and puts it to the individual tools. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Minor improvements and refactoring of lscgroupsBalbir Singh2009-10-231-12/+13
| | | | | | | | This patch removes the excess "/"'s and makes the output more readable. Please test on your systems as well. Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* adds lscgroup toolIvana Hutarova Varekova2009-10-092-1/+298
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Description: create tool which shows cgroups which are on system: Usage: lscgroup [<controllers>:<path>] [...] list all cgroups Changes since V1(the previous versions was not enumerated): * fix the format of comments which have more than 1 line * printf of help -> fprintf(stdout,... * change the sequence of processing of cgroups on input (now first) and internal controller list(first in the previous version), now the cgroups are output in order in which they are put to input * fix return values/error messages - now if the controller is not mount the tool return error - it returns 0 otherwise Changes since V2 * fix problem with slash characters ( $ lscgroup cpu:/1/2 cpu:/1/2/ cpu:/1/2/1 $ lscgroup cpu:1/2 cpu:/2/ cpu:/2/1 ) Changes since V3 * rename the variables (dp1 -> cgroup_dir_path, dp2 -> input_dir_path) * improve the coding style Examples: $ lscgroup devices:/ devices:/sysdefault cpuset,cpuacct:/ cpuset,cpuacct:/sysdefault cpuset,cpuacct:/daemons cpuset,cpuacct:/daemons/ftp $ lscgroup cpuset:/ cpuset,cpuacct:/ cpuset,cpuacct:/sysdefault cpuset,cpuacct:/daemons cpuset,cpuacct:/daemons/ftp $ lscgroup cpuset:/daemons cpuset,cpuacct:/daemons/ cpuset,cpuacct:/daemons/ftp Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Restrict the effective range of SIGUSR2 signal.Ken'ichi Ohmichi2009-10-041-30/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, If a cgrulesengd daemon receives a SIGUSR2 signal (for reloading rules configuration) while waiting in select(), a daemon finishes incorrectly due to an "Interrupted system call" error. If applying a patch "Add the strings of errno to cgrulesengd daemon's message." and running `service cgred reload`, you can see the message "selecting error: Interrupted system call". This patch fixes the problem. There were some problems the deadlock happens related to a SIGUSR2 signal and they have been fixed by the followings already: * [PATCH] Fix the deadlock of vsyslog() call. http://libcg.git.sourceforge.net/git/gitweb.cgi?p=libcg;a=commit;h=70111cd03653c3ceab9d907c14fa35e5881b2735 * [PATCH] Fix the deadlock of rl_lock. http://libcg.git.sourceforge.net/git/gitweb.cgi?p=libcg;a=commit;h=0241c6f1df5068c006f756005c8e7faa63058c27 The above two patches fixed the problems by protecting the important codes from receiving a SIGUSR2 signal. But this way was not good, because the protecting code will be necessary if increasing the important codes. Instead of protecting the important codes, this patch restricts the effective range of receiving SIGUSR2 signal. So we will not need to add a new protecting code by this patch. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add the strings of errno to cgrulesengd daemon's message.Ken'ichi Ohmichi2009-10-041-11/+12
| | | | | | | | | | | | | | | | Hi, This patch adds the strings of errno to cgrulesengd daemon's message. For investigating a problem that cgrulesengd daemon finishes by `service cgred reload`, I added the strings of errno to the daemon's message. This strings were useful for investigating. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* adds lssubsys toolIvana Hutarova Varekova2009-08-292-1/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Description: Show controller, which are mounted/which are on input and if option -m is used shows the mount point on which are mounted: Changes since V1(the previous versions was not enumerated): * fix the size of array cont_name - so no allocation and c_max variable removed * change the sequence of processing of controllers list on input (now first) and internal controller list(first in the previous version), now the controllers are output in order in which they are put to input * fix return values/error messages - now if the controller is not mount the tool return error - it returns 0 otherwise Changes since V2 * fix the format of comments which have more than 1 line Changes since V3 * printf of help -> fprintf(stdout, Syntax: lssubsys [-m] [controller1] [controller2] [...] -m - show mount points Examples: $lssubsys -m cpuacct cpuset,cpuacct /mnt/cgroups/cpuset $ lssubsys devices cpuset,cpuacct Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Remove VERSION macro from api.cJan Safranek2009-08-291-11/+0
| | | | | | | | | The macro and assosicated cg_version is not used anywhere and it generates warning: api.c:58:1: warning: "VERSION" redefined Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Remove unnecessary includes from libcgroup.hJan Safranek2009-08-293-0/+3
| | | | | | | | libcgroup.h includes some header files, which are not then used. These should be removed, resp. moved to the source files where they are actually needed. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Shorten error text of ECGOTHERJan Safranek2009-08-291-4/+1
| | | | | | | | | | | | | | | Let's reformat cgroup_strerror output from Cgroup generic error, error message: Device or resource busy to shorter and clearer Device or resource busy The patch assumes that _GNU_SOURCE is defined. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Fix compile errorDhaval Giani2009-08-061-1/+1
| | | | | | The correct error code is ECGOTHER and not CGOTHER Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* add api for generating the list of all controllers (not only mount ones)Ivana Hutarova Varekova2009-08-062-0/+79
| | | | | | | | | | | | | | | | | | | | | | this patch add api for generating the list of all controllers (not only mount ones) - it uses three functions: cgroup_get_all_controller_begin cgroup_get_all_controller_next cgroup_get_all_controller_end and structure: struct controller_data { char name[FILENAME_MAX]; int hierarchy; int num_cgroups; int enabled; }; the data are read from /proc/cgroups file Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com> Reviewed-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Refactor cgclear to use new recursive deleteJan Safranek2009-08-061-92/+14
| | | | | | | | | | | | Let's rework cgroup_config_unload_controller to use the brand new recursive removal of groups. It saves *lot of* fopen() and fclose() calls: On my (semi-broken) Fedora 11 with 196 running processes and 3 cgroup hierarchies, the old cgclear does 668 open("*/tasks"). With the optimized cgclear, I can see just 22 open("*/tasks") calls. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add cgdelete toolJan Safranek2009-08-062-1/+147
| | | | | | | | | | | | | | | | | The cgdelete command line tool removes given control groups. Usage: cgdelete [-r] <controllers>:<group> [...] # I have group 1 with many subgroups: $ cgdelete cpu,freezer:1 cgdelete: cannot remove group '1': Cgroup generic error, error message: Device or resource busy $ cgdelete -r cpu,freezer:1 $ Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add recursive cgroup_delete_cgroup_ext.Jan Safranek2009-08-062-26/+125
| | | | | | | | | | | | | | | | | | | Changelog: - add braces to cgroup_delete_cgroup_ext to improve readability - use enum instead of macro to define flags The new function allows to recursively delete whole tree of groups. There is new infrastructure created around (cg_delete_cgroup_controller_recursive). It has inconsistent behavior when root group removal is requested - it removes all children (if requested), but does not remove the root itself and returns success value. This allows simple rewrite of cgclear functions to use this function. Original cgroup_delete_cgroup now leads to cgroup_delete_cgroup_ext. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Split cgroup removal to separate functions.Jan Safranek2009-08-061-49/+154
| | | | | | | | | | | | | | | | | | | | | | | Changelog: - simplify error handling in cg_move_task_files cgroup_delete_cgroup does all the stuff on it's own. This patch refactors the function and moves the parts with complete error handling. The new functions are cg_delete_cgroup_controller and cg_move_task_files. They are not necessarily needed, but it simplifies error handling and clearly distinguishes functionality of cgroup_delete_cgroup. Purpose of the functions should be clearly specified in the doxygen comments. Especially note that cg_delete_cgroup_controller wants already opened file, where all tasks should be moved - this is optimization, which will be used in subsequent patches. I could use cgroup_get_task_* and cgroup_attach_task, which would look definitely nicer, but it would lead to lot of fopen() and fclose() calls. Let me know what do you think about it. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* RFC: Fix cgroup_find_parent functionJan Safranek2009-08-061-31/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | There are more issues with cgroup_find_parent function: 1. The cgroup_find_parent expects, that it's argument is group in cg_mount_table[0] controller, which is not always the case. IMHO the function should accept complete struct cgroup and find real parent. 2. when checking the st_dev of the group and it's parent to prevent "underflow" to real filesystem, actually the parent and it's parent are checked instead of group and it's parent. In addition, I enhanced the function to return real error code when something goes wrong. Open question is, if the function should return just char* as parent's name or whole struct cgroup*. The second case is more natural - we should work with groups and not group names, but in some cases just the name is needed and whole cgroup creation would be unnecessary overhead (I have prepared cgcdelete tool, which needs just parent's name). Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* removes copy_name_value_from_rules to wrapperIvana Varekova2009-08-064-56/+64
| | | | | | | | | move copy_name_value_from_rules procedure to wrapper.c file and add the header to libcgroup-internal.h Signed-off-by: Ivana Varekova <varekova@redhat.com> Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add a process name to the log of cgrulesengd daemon.Ken'ichi Ohmichi2009-07-071-5/+6
| | | | | | | | | | | | | | | Hi, Current cgrulesengd daemon changes the cgroup of each process by a rule based on uid, gid, and process name. And it is good that the log of the daemon contains a process name with uid and gid. This patch adds a process name to the log message. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Reduce "Cgroup change for PID:X, UID:X, GID:X FAILED!" messages.Ken'ichi Ohmichi2009-07-071-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog since v1: =================== * Rebase the latest code. * Cleanup. The log message "Cgroup change for PID:X, UID:X, GID:X FAILED!" is output by cgrulesengd daemon, even if a process finished already and that is not a problem. This patch prevents the daemon from outputting this spam log message. * Reference [PATCH 2/2] Reduce "Cgroup change for PID:X, UID:X, GID:X FAILED!" messages. http://sourceforge.net/mailarchive/message.php?msg_name=4A10EE7E.60403%40mxs.nes.nec.co.jp Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: find better name for CGRULE_CGRED_TEMP_FILEJan Safranek2009-07-012-5/+5
| | | | | | | | Rename CGRULE_CGRED_TEMP_FILE to CGRULE_CGRED_SOCKET_PATH to better describe the macro usage - it's not a temporary file, it's a socket. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix cgroup_find_matching_rule() call.Ken'ichi Ohmichi2009-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Hi, If compiling the latest code (8cc1d9743201cb9ae9a5286c898b9d47e318ed46), the following warning messages are printed. The problem is due to invalid call of cgroup_find_matching_rule_uid_gid(). Instead of this function call, cgroup_find_matching_rule() should be called as "[PATCH-v6 03/11] Add the key "process name" to find a matching rule.". $ make [snip] api.c: In function 'cgroup_change_cgroup_flags': api.c:1994: warning: passing argument 3 of 'cgroup_find_matching_rule_uid_gid' from incompatible pointer type api.c: At top level: api.c:1923: warning: 'cgroup_find_matching_rule' defined but not used [snip] $ * Reference: "[PATCH-v6 03/11] Add the key "process name" to find a matching rule." http://sourceforge.net/mailarchive/message.php?msg_name=4A44617E.9060002%40mxs.nes.nec.co.jp Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix too many program name in the usage message of "cgset" command.Ken'ichi Ohmichi2009-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Hi, If compiling the latest code (8cc1d9743201cb9ae9a5286c898b9d47e318ed46), the following warning messages are printed. $ make [snip] cgset.c: In function 'usage': cgset.c:123: warning: too many arguments for format [snip] $ This patch fixes too many program name in the usage message of "cgset" command. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Add --copy-from option to cgsetIvana Varekova2009-06-291-5/+69
| | | | | | | Add copy-from option to cgset Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Change the handling of options, add --helpIvana Varekova2009-06-291-6/+35
| | | | | | | | | | Change the handling of options - add the possibility to use long options - add --help option - change the type of c (see man 3 getopt_long) Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Change the generation of cgroupIvana Varekova2009-06-291-43/+74
| | | | | | | | | | | | | | | - This patch change the system of generating cgroup to 1/ create one src cgroup 2/ for each input cgroup name cgroup_copy_cgroup the name-value data from original one This method is better because the name-values pairs should not be parsed several times. And this method will be used in new coption --copy-from too (the src group will be find in option) move the part in which src is generated to separate function Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* cgset: Add cgset_SOURCES to MakefileIvana Varekova2009-06-291-0/+2
| | | | | | | Add cgset_SOURCES to Makefile Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>