Commit 142f2c8e authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: dump some global properties as well

These are present in every cgroup, so let's dump them.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent cbe8ef4f
...@@ -81,6 +81,13 @@ static const char *freezer_props[] = { ...@@ -81,6 +81,13 @@ static const char *freezer_props[] = {
NULL NULL
}; };
static const char *global_props[] = {
"cgroup.clone_children",
"cgroup.sane_behavior",
"notify_on_release",
NULL
};
/* /*
* This structure describes set of controller groups * This structure describes set of controller groups
* a task lives in. The cg_ctl entries are stored in * a task lives in. The cg_ctl entries are stored in
...@@ -401,43 +408,61 @@ static const char **get_known_properties(char *controller) ...@@ -401,43 +408,61 @@ static const char **get_known_properties(char *controller)
return prop_arr; return prop_arr;
} }
static int add_cgroup_properties(const char *fpath, struct cgroup_dir *ncd, static int dump_cg_props_array(const char *fpath, struct cgroup_dir *ncd,
struct cg_controller *controller) const char **prop_arr)
{ {
int i, j; int j;
char buf[PATH_MAX]; char buf[PATH_MAX];
struct cgroup_prop *prop; struct cgroup_prop *prop;
for (i = 0; i < controller->n_controllers; ++i) { for (j = 0; prop_arr != NULL && prop_arr[j] != NULL; ++j) {
if (snprintf(buf, PATH_MAX, "%s/%s", fpath, prop_arr[j]) >= PATH_MAX) {
pr_err("snprintf output was truncated\n");
return -1;
}
const char **prop_arr = get_known_properties(controller->controllers[i]); if (access(buf, F_OK) < 0 && errno == ENOENT) {
pr_info("Couldn't open %s. This cgroup property may not exist on this kernel\n", buf);
continue;
}
for (j = 0; prop_arr != NULL && prop_arr[j] != NULL; ++j) { prop = create_cgroup_prop(prop_arr[j]);
if (snprintf(buf, PATH_MAX, "%s/%s", fpath, prop_arr[j]) >= PATH_MAX) { if (!prop) {
pr_err("snprintf output was truncated\n"); free_all_cgroup_props(ncd);
return -1; return -1;
} }
if (access(buf, F_OK) < 0 && errno == ENOENT) { if (read_cgroup_prop(prop, buf) < 0) {
pr_info("Couldn't open %s. This cgroup property may not exist on this kernel\n", buf); free_cgroup_prop(prop);
continue; free_all_cgroup_props(ncd);
} return -1;
}
prop = create_cgroup_prop(prop_arr[j]); pr_info("Dumping value %s from %s/%s\n", prop->value, fpath, prop->name);
if (!prop) { list_add_tail(&prop->list, &ncd->properties);
free_all_cgroup_props(ncd); ncd->n_properties++;
return -1; }
}
if (read_cgroup_prop(prop, buf) < 0) { return 0;
free_cgroup_prop(prop); }
free_all_cgroup_props(ncd);
return -1; static int add_cgroup_properties(const char *fpath, struct cgroup_dir *ncd,
} struct cg_controller *controller)
{
int i;
for (i = 0; i < controller->n_controllers; ++i) {
const char **prop_arr = get_known_properties(controller->controllers[i]);
pr_info("Dumping value %s from %s/%s\n", prop->value, fpath, prop->name); if (dump_cg_props_array(fpath, ncd, prop_arr) < 0) {
list_add_tail(&prop->list, &ncd->properties); pr_err("dumping known properties failed");
ncd->n_properties++; return -1;
}
if (dump_cg_props_array(fpath, ncd, global_props) < 0) {
pr_err("dumping global properties failed");
return -1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment