| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add very simple main page to include/libcgroup.h. It contains just very
basic info and links to the other modules. Feel free to elaborate more on
this, it could contain lot more:
- how to complie with libcgroup (=pkgconfig)?
- how to report errors
- links to samples
- link to home page
- info about threading
etc.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
| |
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
| |
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
| |
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
| |
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
| |
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
| |
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
|
|
| |
Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds the const qualifier to a number of function arguments
(mostly string arguments) so that client libraries can pass their own
const strings to the library without having to cast their const'ness
away.
This also drops a couple of consts where call-by-value is done anyway,
and which hence has no effect and just misleads the users and adds
unnecessary noise to the signal. After all this is C, not C++.
Signed-off-by: Lennart Poettering <lennart@poettering.net>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Later on it might make sense to move around function definitions between
header files. Hence make sure that nobody includes any header file
directly except the main one.
Signed-off-by: Lennart Poettering <lennart@poettering.net>
Reviewed-By: Jan Safranek <jsafrane@redhat.com>
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Changelog:
- since there are no global macros, base.h is gone
- since there is no base.h, all headers need to include <features.h> to get
__BEGIN_DECLS
- new init.h with cgroup_init() and cgroup_get_subsys_mount_point()
- new error.h with error handling enum and related stuff
- use #ifndef _LIBCGROUP_*_H instead _LIBCG_*_H in header guards
- fix few checkpatch complaints (long lines, whitespaces, ...)
The patch includes Makefile and .spec changes. I tested it compiles,
make dist produces tarball with all headers, so does also the rpm.
'make' should automatically catch all changes in new headers and
recompile dependent (=all) sources when any header changes.
libcgroup.h
- does not declare anything, it just includes all the other files. In
future, it might contain base of doxygen documentation (some
introduction etc.)
libcgroup/error.h
- the big enum with errors + error related functions
libcgroup/init.h
- libcgroup_init() and cgroup_get_subsys_mount_point()
libcgroup/config.h
- configuration reading/unloading
libcgroup/groups.h
- group manipulation stuff (create/modify/delete/free, incl. controllers and
get/set values) + definition of struct cgroup (=must be included by
libcgroup/tasks.h, which needs it)
libcgroup/iterators.h
- various walks, *_begin/next/end
libcgroup/tasks.h
- task classification, incl. rules cache manipulation
In addition, I probably removed some #includes, which are not needed now when
looking for the minimal #include set to build the project. I also hope I did not
miss any function declaration or macro...
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
|
| |
Most of the macro definitions in licgroup.h are internal, let's move them
to private header. Applications should not depend on them. The only one
really needed is CG_VALUE_MAX, which is used in struct cgroup_stat.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
| |
The enum with ECG* error codes should be anonymous, as pointed out by
Lennart Poettering.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
| |
Make the error stings const, just to be safe.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
| |
Remove last_errno from public header, that's why we have cgroup_get_last_errno.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
| |
Remove GNU_SOURCE from public headers, it has unpredictable consequences on
applications using libcgroup.h
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fix cgroup_get_value_string problem with *.stat output
the problem was in the low limit for value for the output of stat variables - now there are used the functions cgroup_read_stats_{begin/next/end} for this purpose
bogus output:
./src/tools/cgget -r memory.stat /
/:
memory.stat=cache 1024561152
rss 291270656
pgpgin 1209259
pgpgout 888011
inactive_anon 8192
active_anon 2976481
fixed output:
$ ./src/tools/cgget -r memory.stat /
/:
memory.stat=cache 1024610304
rss 291270656
pgpgin 1209271
pgpgout 888011
inactive_anon 8192
active_anon 297648128
inactive_file 619126784
active_file 399073280
unevictable 24576
hierarchical_memory_limit 9223372036854775807
hierarchical_memsw_limit 9223372036854775807
total_cache 1024610304
total_rss 291270656
total_pgpgin 1209271
total_pgpgout 888011
total_inactive_anon 8192
total_active_anon 297648128
total_inactive_file 619126784
total_active_file 399073280
total_unevictable 24576
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 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch allows users to configure location of cgrulesengd socket before
compilation:
./configure --enable-cgred-socket=/var/run/cgred.socket
In addition, /var/run/cgred.socket is now default location of the socket - this
sounds LSB compliant to me. Feel free to suggest better one.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Hi,
Changelog of v6:
================
* No change.
Changelog of v5:
================
* Rebase the patch to the latest code.
Changelog of v4:
================
* No change.
Changelog of v3:
================
* No change.
Changelog of v2:
================
* New patch.
Description:
============
This patch adds the library function cgroup_register_unchanged_process()
for notifying cgrulesengd daemon of the unchanged process.
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Hi,
Changelog of v6:
================
* No change.
Changelog of v5:
================
* No change.
Changelog of v4:
================
* Add the comment "FIXME: Change the temporary file to configurable one."
* Define the number of allocation.
Changelog of v3:
================
* Set the value 0x1 to CGROUP_DAEMON_UNCHANGE_CHILDREN flag.
Changelog of v2:
================
* New patch.
Description:
============
This patch adds the handler of unchanged process to the cgrulesengd daemon.
By this patch, the daemon does not change a process which is executed by
'cgexec' command, because it is possible to notify the unchanged process to
the daemon by using "unix domain socket".
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Hi,
Changelog of v6:
================
* No change.
Changelog of v5.1:
==================
* BUGFIX: Clear the flags meaning "found a matching rule"
when a process name does not match.
There was a problem that cgexec and cgclassify didn't work correctly
if a user executes cgexec/cgclassify based on /etc/cgrules.conf.
For example, if a root user executes `cgclassify $$` on the following
/etc/cgrules.conf, the process ($$) should be moved to users/root on
cpuset and memory subsystems. But the process was moved to users/root/cp
on memory subsystem only.
Example of /etc/cgrules.conf:
=============================
root:cp cpuset users/root/cp
% memory users/root/cp
root cpuset users/root
% memory users/root
The cause is why the flags meaning "found a matching rule" (uid, gid, and
matched) is not cleared when a process name does not match. This problem
is fixed on this patch.
Changelog of v5:
================
* Rebase the patch to the latest code.
Changelog of v4:
================
* No change.
Changelog of v3:
================
* BUGFIX: Fix the handling of '%' in /etc/cgrules.conf.
Changelog of v2:
================
* Use strcmp() instead of strncmp() for checking a process name strictly.
* Some cleanups.
Description:
============
This patch adds the key "process name" to find a matching rule.
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Hi,
Changelog of v6:
================
* The definations of CGROUP_RULE_MAXKEY and CGROUP_RULE_MAXLINE are
moved to libcgroup-internal.h since no one from outside should be
using them.
Changelog of v5:
================
* Rebase the patch to the latest code.
Changelog of v4:
================
* Use more safety length of a user name for the buffer "username".
* Move the macros min()/max() to src/libcgroup-internal.h for using
in src/api.c also.
Changelog of v3:
================
* Fix unclear buffer of user by memset().
Changelog of v2:
================
* Remove unnecessary memset().
* Some cleanups.
Description:
============
This patch adds the parser of process name in /etc/cgrules.conf.
A new rule based on process name is as the following, and the process
name is stored into the member "procname" in struct cgroup_rule.
<user>:<process name> <controllers> <destination>
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|\
| |
| |
| | |
ssh://balbir_singh@libcg.git.sourceforge.net/gitroot/libcg
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|/
|
|
|
|
| |
updates will be needed and will be done in subsequent cleanups.
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
specific stats. Added Makefile.am updates which I had missed in the
previous post.
New APIs to read controller specific statistics.
This patch introduces 3 new APIs which can be used to read controller
statistics iteratively. (Eg. stats from memory.stat etc)
Reading of stats is initiated by cgroup_read_stats_begin() API, which
returns the first stat of the requested controller in addition to returing
a handle that should be used in subsequent reads.
cgroup_read_stats_next() API can be used to read the remaining stats
one by one. This needs the handle returned by cgroup_read_stats_begin().
cgroup_read_stats_end() API will terminate the stats reading iteration
initiated by cgroup_read_stats_begin().
Changelog:
v2
- Update tests/Makefile.am so that it generates appropriate rules
for tests/read_stats.c in the Makefile. This is in addition to
the manual updates done to the generated file tests/Makefile.in.
v1
- cgroup_read_stats apis now work with relative cgroup path names instead
of absolute path names.
v0
- Initial post.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
|
|
|
|
|
|
|
|
|
| |
Make the shared object version a bit more usable, the notation with double
colons cannot be used on different places (see next patch).
Also run automake && autoconf to refresh the generated stuff.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
|
|
| |
Finally run autoreconf -f -i to generate all the stuff that should be generated
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
|
|
|
|
| |
Add automake makefiles and prepare everything to run, but don't actually
run the automake - it would generate lot of noise, where my manual changes
would get lots.
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|