summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* libcgroup: Introduce an API to get the mount point of a specific subsystemDhaval Giani2009-06-264-1/+40
| | | | | | | | | Introduce an API which will query the mount table and return the mount point of a specific subsystem. This is needed in the case when the user knows which subsystem he wants the details of, which would make the use of the get_controller* APIs cumbersome. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix some warnings.Ken'ichi Ohmichi2009-06-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Hi, The latest source (commit: 5ea9a7819b717a83af03aa2ea234f105ed717589) outputs some following warnings: $ make [snip] api.c: In function 'cgroup_walk_tree_begin': api.c:2350: warning: passing argument 3 of 'cg_walk_node' makes integer from pointer without a cast api.c:2315: warning: unused variable 'fts' [snip] $ This patch fixes them. 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>
* libcgroup: Fix a missing goto in clean cgroups APIDhaval Giani2009-06-221-0/+1
| | | | | | | Jan pointed out that there was a goto missing in the error handling paths. Fix that bug. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* libcgroup: Introduce a unload cgroups APIDhaval Giani2009-06-225-1/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | This API will unload the cgroups created in the cgroupfs and unmount and delete the filesystem mount point. The action is equivalent to what is done currently in service cgconfig stop. The reason for this API is to make sure we don't end up with a asymmetric library API subset. Today an application program can programatically through cgroup_config_load_config() load a configuration file, but has no means to cleanup (including all temporarily created groups). changes from v3 1. Address Jan's comments from http://article.gmane.org/gmane.comp.lib.libcg.devel/1105 changes from v2 1. Fix a leak as noted by Bharata 2. Address Balbir's review comments at http://article.gmane.org/gmane.comp.lib.libcg.devel/1080 changes from v1 1. Change the name of the function to cgroup_unload_cgroups 2. Change the name of the executatble to cgclear 3. Split out the funtions Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* libcgroup: Introduce get_controller APIDhaval Giani2009-06-185-1/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | This set of APIs will allow the caller to query the mount table and find out what controller is mounted at what path. Test program has been included in the patch. Running the test program results in [dhaval@gondor tests]$ ../libtool --mode=execute ./get_controller Controller cpu is mounted at /cgroup Controller cpuacct is mounted at /cgroup Controller memory is mounted at /cgroup1 [dhaval@gondor tests]$ Which is the setup on this system. Changes from v2 1. Remove the incorrect comments as pointed out by Bharata Changes from v1 1. Use a new structure as mentioned by bharata to return the values. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Cc: Jan Safranek <jsafrane@redhat.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* libcgroup: Use double pointers everywhere in the get_task APIsDhaval Giani2009-06-183-9/+8
| | | | | | | | As Jan Safranek pointed out, it is better to have double pointers everywhere in the get_task API to keep consistency. Do the same. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* libcgroup: Introduce post order walkDhaval Giani2009-06-183-4/+41
| | | | | | | | | | With the introduction of the flags, we now actually make use of them. This patch adds a post mode and modifies the test case to also do a post order walk. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* libcgroup: Add flags to the walk_tree handleDhaval Giani2009-06-183-10/+69
| | | | | | | | | | | | | | Introduce a cgroup_tree_handle structure so that we can track flags for the walk_tree operation. In a number of cases we would prefer to walk the tree in postorder as opposed to pre-order which is the current default. This patch does the addition. Changes since V1: 1. Added checks for !handle as suggested by Bharata Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* cgconfigparser: Change mkdir in cgroup_config_mount_fs to mkdir -pDhaval Giani2009-06-183-7/+5
| | | | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=502687 mentioned that the directory was not getting created when a cgconfig start was being run. This is was because we failed the mkdir. The mkdir for directories at depth was not succeeding. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Adds cgset man pageIvana Varekova2009-06-182-1/+28
| | | | | | | This patch adds cgset man page - it includes Makefile changes Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* This patch adds cgset toolIvana Varekova2009-06-182-1/+179
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds cgset tool, which sets parameters of controllers for given cgroup based on input name-variable pairs - the syntax is: cgset -r <name=value> <relative path to cgroup> ------------------------------------------------- EXAMPLES: $ cgcreate -g cpuset:test1 $ cgset -r cpuset.cpus=1 test $ cat ./test/cpuset.cpus 1 $ cgcreate -g cpuset:test1 -g cpuset:test2 $ cgset -r cpuset.cpus=0 test1 test2 $ cat /mnt/cgroups/cpuset/test1/cpuset.cpus 0 $ cat /mnt/cgroups/cpuset/test2/cpuset.cpus 0 Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Prevent to add multiple versions of the same controller to mount_tableIvana Varekova2009-06-181-0/+18
| | | | | | | | | | | | This patche add a test to cgroup_init function, which prevent to add multiple records for the same controller (this is a problem eg. in cgroup_get_cgroup function - which looks to mount table and add all relevant controllers using cgroup_add_controller function and when the function calls cgroup_add_cgroup function twice on the same controller, it returns error so the result is cgroup_get_cgroup failed). Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Integrate similar code to cgroup_get_uid_gid_from_procfs().Ken'ichi Ohmichi2009-06-086-140/+68
| | | | | | | | | | | | | | CHANGELOG of v2.1: ================ * Rebase the patch for commit '340feae163c4797a6cb1247b3812c1ccdc52fa41'. There are some similar functions for getting process's data (uid, gid) from /proc/<pid>/status file, so this patch integrates these functions into one cgroup_get_uid_gid_from_procfs(). Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Remove unnecessary 'err' value.Ken'ichi Ohmichi2009-06-081-3/+1
| | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * New patch. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Rename "name" to "username" in struct cgroup_rule.Ken'ichi Ohmichi2009-06-082-9/+10
| | | | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * No change. To add the member "procname" to struct cgroup_rule by later patch, this patch renames the member "name" to "username" for the clarification. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Add cg_skip_unused_charactors_in_rule().Ken'ichi Ohmichi2009-06-081-16/+29
| | | | | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * No change. The loop in cgroup_parse_rules() is a little long now, and it is not easy to read the loop. Then, This patch shortens the loop for the readability. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Use sizeof() in memset().Ken'ichi Ohmichi2009-06-081-23/+5
| | | | | | | | | | | | | Changelog of v3: ================ * Remove unnecessary memset(). fgets()/sscanf() does not care what is in the buffer, and it is unnecessary to clear the buffer before. Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: Remove unnecessary strlen() in strncpy().Ken'ichi Ohmichi2009-06-081-2/+3
| | | | | | | | | | | | | | | | Hi, CHANGELOG of v2: ================ * Specify the buffer size of 'user' instead of strlen(). It actually walks through 'user' twice, once to compute length by strlen() and then this patch specifies the buffer size of 'user' instead. Reported-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Reviewed-By: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Adds cgcreate man pageIvana Varekova2009-06-032-1/+44
| | | | | | This patch adds cgcreate man page - it includes Makefile.in changes Signed-off-by: Ivana Varekova <varekova@redhat.com>
* This patch adds cgcreate toolIvana Varekova2009-06-032-1/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds cgcreate tool, which creates cgroups based on input parameters - the syntax is: cgcreate -t <tuid>:<tgid> -a <agid>:<auid> -g <list of controllers>:<relative path to cgroup> where: -a enables user to define admin gid and uid (implicit values are the same values which are in the parent directory) -t enables user to define task gid and uid (implicit values are the same values which are in parent directory) -g sets pairs list of controllers-relative path to cgroup ------------------------------------------------- EXAMPLES: * ../../libtool --mode=execute ./cgcreate -a :varekova -g cpuacct:first * ll /mnt/cgroups/cpuacct | grep first drwxrwxr-x 2 root varekova 0 2009-06-03 09:14 first * ll /mnt/cgroups/cpuacct/first/* -rwxrwxr-x 1 root varekova 0 2009-06-03 09:14 /mnt/cgroups/cpuacct/first/cpuacct.usage -rwxrwxr-x 1 root varekova 0 2009-06-03 09:14 /mnt/cgroups/cpuacct/first/notify_on_release -rwxrwxr-x 1 root varekova 0 2009-06-03 09:14 /mnt/cgroups/cpuacct/first/tasks * ../../libtool --mode=execute ./cgcreate -a varekova:root -t varekova:varekova -g cpuacct:second * ll /mnt/cgroups/cpuacct/ | grep second drwxrwxr-x 2 varekova root 0 2009-06-03 09:13 second * ll /mnt/cgroups/cpuacct/second total 0 -rwxrwxr-x 1 varekova root 0 2009-06-03 09:13 cpuacct.usage -rwxrwxr-x 1 varekova root 0 2009-06-03 09:13 notify_on_release -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:13 tasks * ../../libtool --mode=execute ./cgcreate -a varekova:varekova -g cpuacct:third -g cpuacct:fourth * ll /mnt/cgroups/cpuacct | grep h drwxrwxr-x 2 varekova varekova 0 2009-06-03 09:18 fourth drwxrwxr-x 2 varekova varekova 0 2009-06-03 09:18 third * ll /mnt/cgroups/cpuacct/*h* /mnt/cgroups/cpuacct/fourth: total 0 -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 cpuacct.usage -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 notify_on_release -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 tasks /mnt/cgroups/cpuacct/third: total 0 -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 cpuacct.usage -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 notify_on_release -rwxrwxr-x 1 varekova varekova 0 2009-06-03 09:18 tasks Signed-off-by: Ivana Varekova <varekova@redhat.com>
* libcgroup: Export cgroup_get_controller APIDhaval Giani2009-06-032-0/+3
| | | | | | | | | libcgroup: Export cgroup_get_controller API This wrapper was not exposed for some reason earlier. Make it available from the library. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Add cgroup_free_group_spec procedureIvana Varekova2009-05-292-0/+32
| | | | | | | | Add cgroup_free_group_spec procedure which free cgroups_group_spec variable. Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* parse_cgroup_spec function does not initializesd allocated memoryIvana Varekova2009-05-291-1/+1
| | | | | | | | | parse_cgroup_spec function does not initializesd allocated memory this patch allocate it to zero so there is no problem with uninitialized values. Signed-off-by: Ivana Varekova <varekova@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Merge branch 'devel/automake-updates' of git://fedorapeople.org/~jsafrane/libcgDhaval Giani2009-05-295-369/+67
|\
| * Check for PAM headers and librariesdevel/automake-updatesJan Safranek2009-05-251-0/+14
| | | | | | | | | | | | | | When PAM module is enabled, configure script should check if necessary headers and libraries are available. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
| * Add options to enable/disable various build targets.Jan Safranek2009-05-254-2/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | By default, everything is compiled. I want to add options to ./configure, which can selectively disable tools, daemon and pam module. The library itself is mandatory component and cannot be disabled. Usage: ./configure --help ./configure --disable-tools --disable-pam --disable-daemon Signed-off-by: Jan Safranek <jsafrane@redhat.com>
| * Remove missing fileJan Safranek2009-05-251-367/+0
|/ | | | | | | File named 'missing' is generated by automake (or libtool?), it's not necessary to have it in git. Signed-off-by: Jan Safranek <jsafrane@redhat.com>
* configure.in problem with byacc and flexIvana Varekova2009-05-231-3/+8
| | | | | | | | | | | | | | | | fix the problem - can be applied now :) configure.in file wrongly handles YACC and LEX variables so ./configure exit succesfully, but make fails. The problems are: * it enables configuration even if no yacc is installed (it is necessary for make) - YACC is set to byacc in this case * the configure.in enables configuration if no lex is installed (it is again necessary for succesfull make) - in this case YAC is set to ":" i Signed-off-by: Ivana Varekova <varekova@redhat.com> Acked-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix the deadlock of rl_lock.Ken'ichi Ohmichi2009-05-221-7/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Changelog of v2: - Add the description of the problematic call sequence. - There is not any change in the code. [PATCH-v2] Fix the deadlock of rl_lock. For avoiding the deadlock, protect cdgroup_change_cgroup_uid_gid_flags() by blocking SIGUSR2 signal. The problematic call sequence is the following: ---------------------------------------------------------------------- * CGRULESENGD DAEMON * << cgre_flash_rules() is the signal handler for SIGUSR2 signal >> cgre_create_netlink_socket_process_msg() << Receive a UID/GID event packet >> cgre_handle_msg() cgre_process_event() cgroup_change_cgroup_uid_gid_flags() cgroup_find_matching_rule_uid_gid() pthread_rwlock_wrlock(&rl_lock); << Get the lock of rl_lock >> << Receive a SIGUSR2 signal, and switch to cgre_flash_rules() >> cgre_flash_rules() cgroup_reload_cached_rules() cgroup_parse_rules() pthread_rwlock_wrlock(&rl_lock); << deadlock ! >> ---------------------------------------------------------------------- A cgrulesengd daemon needs a lock of rl_lock for referring configuration buffer. On the other way, the daemon reloads configuration file when receiving SIGUSR2 signal, and it needs the same lock in cgroup_parse_rules(). So cgroup_change_cgroup_uid_gid_flags() should be protected from SIGUSR2 signal for avoiding the deadlock. 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>
* Fix the deadlock of vsyslog() call.Ken'ichi Ohmichi2009-05-221-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, I found the deadlock problem that a cgrulesengd daemon stalls if service "cgred" is reloaded while many UID events happen. The following is the gdb output by attaching the stalling daemon: (gdb) bt #0 0x0000003b298dd918 in __lll_mutex_lock_wait () from /lib64/libc.so.6 #1 0x0000003b298ce847 in _L_lock_646 () from /lib64/libc.so.6 #2 0x0000003b298ce2da in __vsyslog_chk () from /lib64/libc.so.6 #3 0x0000000000401533 in flog (level=5, format=0x402778 "Reloading rules configuration.") at cgrule sengd.c:130 #4 0x00000000004015d1 in cgre_flash_rules (signum=<value optimized out>) at cgrulesengd.c:644 #5 <signal handler called> #6 0x0000003b298d27b5 in send () from /lib64/libc.so.6 #7 0x0000003b298ce3a0 in __vsyslog_chk () from /lib64/libc.so.6 #8 0x0000000000401533 in flog (level=4, format=0x402b82 "Failed to open %s") at cgrulesengd.c:130 #9 0x0000000000401cc7 in cgre_process_event (ev=0x7fff8ad11cc4, type=4) at cgrulesengd.c:161 #10 0x0000000000401fd5 in cgre_create_netlink_socket_process_msg () at cgrulesengd.c:486 #11 0x00000000004023ca in main (argc=1, argv=<value optimized out>) at cgrulesengd.c:878 (gdb) We can see __vsyslog_chk() is called twice, because the daemon recieved a SIGUSR2 signal in __vsyslog_chk(). In __vsyslog_chk(), "syslog_lock" is locked by __libc_lock_lock(syslog_lock). So I think vsyslog() should be protected by blocking the signal, and this patch fixes the problem by doing it. 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 the infinite loop of cgrulesengddaemon.Ken'ichi Ohmichi2009-05-191-2/+3
| | | | | | | | | | | | | Hi, This patch clarifies the infinite loop. 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> Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Cleanup: make the indent of cgroup_init()shallower.Ken'ichi Ohmichi2009-05-181-22/+20
| | | | | | | | | | | | | Hi, This patch makes the indent of cgroup_init() shallower for the readability. 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>
* Add fclose() calls into egid_of_pid().Ken'ichi Ohmichi2009-05-181-0/+2
| | | | | | | | | | | | | Hi, This patch adds necessary fclose() calls into egid_of_pid(). Thanks Ken'ichi Ohmichi Reported-by: Masayuki Igawa <igawa@mxs.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>
* libcgrouptest: Fix the cgroup_dbg macroDhaval Giani2009-05-181-1/+1
| | | | | | | | | | | | | | | | libcgrouptest: Fix the cgroup_dbg macro On compiling with CGROUP_DEBUG enabled, compile was failing. libcgrouptest01.c: In function ‘main’: libcgrouptest01.c:57: error: expected ‘)’ before ‘...’ token libcgrouptest01.c:64: error: expected ‘)’ before ‘...’ token libcgrouptest01.c:68: error: expected ‘)’ before ‘...’ token make[2]: *** [libcgrouptest01.o] Error 1 Fix this error. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Specify the full path of cgrulesengd command in cgred.Ken'ichi Ohmichi2009-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Hi, I installed libcgroup by `make install`, and the service "cgred" didn't work like the following: # service cgred start Starting CGroup Rules Engine Daemon... /bin/bash: cgrulesengd: command not found [FAILED] # The cause is why the function "daemon" cannot find cgrulesengd command. This patch fixes the problem by specifying the full path of cgrulesengd 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>
* Fix the error handling if failing to open/etc/cgrules.conf.Ken'ichi Ohmichi2009-05-181-4/+5
| | | | | | | | | | | | | Hi, If failing to open /etc/cgrules.conf in cgroup_parse_rules(), rl_lock should be unlocked. This patch fixes the code for doing it. 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>
* This patch fixes a trivial comment typo about the cgred.Masayuki Igawa2009-05-141-1/+1
| | | | | Signed-off-by: Masayuki Igawa <igawa@mxs.nes.nec.co.jp> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* There is the problem that cgrulesengd cannot get Gid from /proc/PID/status,Masayuki Igawa2009-05-141-2/+0
| | | | | | | | | | | | | | | | because the function breaks just after getting Uid data: $ cat /proc/$$/status [snip] Uid: 500 500 500 500 Gid: 500 500 500 500 [snip] $ This patch fixes this problem. Signed-off-by: Masayuki Igawa <igawa@mxs.nes.nec.co.jp> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Fix the path of cgrulesengd command.Ken'ichi Ohmichi2009-05-081-2/+2
| | | | | | | Change the binary path for cgred to sbindir Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Generate paths in initscripts by configure scriptJan Safranek2009-05-084-8/+9
| | | | | | | | | | | | | | | Change the hardcoded paths in initscripts to dynamically generated ones. The real executable path $bindir can be constructed using $prefix and $exec_prefix variables, therefore it's necessary to define also these two. The patch includes removal of old initscripts from git - they are generated from .in file now. I did not run autoreconf, I think the generated junk is being removed from git soon. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
* Fix ECGOTHER error messageIvana Varekova2009-05-081-2/+2
| | | | | | | | | | | | For now the result is eg.: Cgroup generic error, see errno: error message: No such file or directory this patch remove outdated "see errno: " part. second version 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>
* Fix of cgexec error handlingIvana Varekova2009-05-081-1/+2
| | | | | | | | | | | Fix of cgexec error handling - with this patch cgexec return the right error message - not only cg internal error value re-generated 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>
* I tested a cgrlesengd daemon with huge load, which makes many 'su',Ken'ichi Ohmichi2009-05-082-4/+8
| | | | | | | | | | | | | | | in long time. And the daemon was killed by an OOM killer. So the daemon has memory leak. This patch fixes this problem. The daemon allocates memory at cg_prepare_cgroup(), but it does not free the memory. This patch adds necessary free() to cgroup_change_ cgroup_path by calling cgroup_free_controllers(). In addition, this patch adds free()s for handling error and flushes the counters of the allocations in cgroup_free_controllers(). Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Changelog v2:\"Ken'ichi Ohmichi\2009-05-082-1/+105
| | | | | | | | | | | | | | | | | | | | | | | * Use clock_gettime(2) for getting timestamp since a system boot. * Change parent_info's memory to dynamic allocation. This patch is for changing the cgroup of a forked process while parent changing. This patch adds the following sequence: 1. Store both the timestamp and the process-id when changing the cgroup. 2. If receiving a PROC_EVENT_FORK packet, check its parent-pid and its timestamp. 3. If its parent-pid and the stored process-id are same and its timestamp is older than the stored timestamp, change the cgroup of forked process. Thanks Ken'ichi Ohmichi Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* I have been testing a cgrulesengd daemon and I noticed it fails to\"Ken'ichi Ohmichi\2009-05-081-60/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | change the cgroup of child occasionally. I tested it by following configulation file: /etc/cgrules.conf: user01 cpuset group01/user01 % memory group01/user01 A cpuset subsystem and a memory subsystem are mounted on different mount points, and a cgrulesengd daemon manages each subsystem. I login this environment as a user "user01", and each susbystem's tasks file is the following: # cat /mnt/cgroups/cpuset/group01/user01/tasks 31801 31805 31806 # # cat /mnt/cgroups/memory/group01/user01/tasks 31801 31805 # # pstree -p 32105 sshd(31801)---sshd(31805)---bash(31806) # They should be the same, but they are different. I investigated this problem, and I found the cause. The reason is that the process(31806) was forked just after writing the process(31805) to a cpuset subsystem's tasks file: <1> The UID/GID CHANGE event of the process 31805 happens. <2> The daemon writes "31805" to a cpuset subsystem's tasks file. <3> The process 31806 is forked, and it appears on a cpuset subsystem's tasks file. <4> The daemon writes "31805" to a memory subsystem's tasks file. <5> The process 31806 does not appears on a memory subsystem's tasks file. For solving this problem, I propose the following sequence. 1. Store both the timestamp and the process-id when the step <4>. 2. If receiving a PROC_EVENT_FORK packet, check its parent-pid and its timestamp. 3. If its parent-pid and the stored process-id are same and its timestamp is older than the stored timestamp, change the cgroup of forked process. Changelog of v2: * Change only [PATCH 2/2] and there is not any changes in [PATCH 1/2]. This patch adds the method for getting euid/egid from /proc/<pid>/status file. For changing the cgroup of a forked process, the method is usefull because a PROC_EVENT_FORK packet does not inform of its euid and its egid. Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
* Merge branch 'master' of ↵Balbir Singh2009-04-245-3/+147
|\ | | | | | | ssh://balbir_singh@libcg.git.sourceforge.net/gitroot/libcg
| * libcgroup: Correct the version to which the statistics API belongDhaval Giani2009-04-221-3/+3
| | | | | | | | | | | | | | These APIs were not available in v0.33. They will be a part of v0.34 however. Make the change in libcgroup.map reflecting this. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
| * libcgroup: Add test cases for new get_task APIDhaval Giani2009-04-222-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the test case for the new API. This test takes one argument, the group name. Sample run on my system with this test case returns, [dhaval@gondor tests]$ ../libtool --mode=execute ./walk_task a Printing the details of groups a Pid is 6092 Pid is 11315 Pid is 11318 Pid is 11319 Pid is 11324 Pid is 13234 [dhaval@gondor tests]$ Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
| * libcgroup: Add new API to walk tasksDhaval Giani2009-04-223-0/+93
| | | | | | | | | | | | | | | | | | Add a new API to iterate through the tasks file to get the list of all the tasks in a cgroup. Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
* | Merge branch 'master' of ↵Balbir Singh2009-04-215-72/+70
|\| | | | | | | ssh://balbir_singh@libcg.git.sourceforge.net/gitroot/libcg