Lines Matching refs:cg
28 struct CGroupInfo *parent = NULL, *cg; in add_cgroup() local
36 cg = hashmap_get(cgroups, path); in add_cgroup()
37 if (cg) { in add_cgroup()
38 *ret = cg; in add_cgroup()
56 cg = new0(struct CGroupInfo, 1); in add_cgroup()
57 if (!cg) in add_cgroup()
61 cg->cgroup_path = (char*) path; in add_cgroup()
63 cg->cgroup_path = strdup(path); in add_cgroup()
64 if (!cg->cgroup_path) { in add_cgroup()
65 free(cg); in add_cgroup()
70 cg->is_const = is_const; in add_cgroup()
71 cg->parent = parent; in add_cgroup()
73 r = hashmap_put(cgroups, cg->cgroup_path, cg); in add_cgroup()
76 free(cg->cgroup_path); in add_cgroup()
77 free(cg); in add_cgroup()
82 LIST_PREPEND(siblings, parent->children, cg); in add_cgroup()
86 *ret = cg; in add_cgroup()
96 struct CGroupInfo *cg; in add_process() local
103 r = add_cgroup(cgroups, path, true, &cg); in add_process()
107 return hashmap_ensure_put(&cg->pids, &trivial_hash_ops, PID_TO_PTR(pid), (void*) name); in add_process()
110 static void remove_cgroup(Hashmap *cgroups, struct CGroupInfo *cg) { in remove_cgroup() argument
112 assert(cg); in remove_cgroup()
114 while (cg->children) in remove_cgroup()
115 remove_cgroup(cgroups, cg->children); in remove_cgroup()
117 hashmap_remove(cgroups, cg->cgroup_path); in remove_cgroup()
119 if (!cg->is_const) in remove_cgroup()
120 free(cg->cgroup_path); in remove_cgroup()
122 hashmap_free(cg->pids); in remove_cgroup()
124 if (cg->parent) in remove_cgroup()
125 LIST_REMOVE(siblings, cg->parent->children, cg); in remove_cgroup()
127 free(cg); in remove_cgroup()
141 struct CGroupInfo *cg; in dump_processes() local
148 cg = hashmap_get(cgroups, cgroup_path); in dump_processes()
149 if (!cg) in dump_processes()
152 if (!hashmap_isempty(cg->pids)) { in dump_processes()
160 pids = newa(pid_t, hashmap_size(cg->pids)); in dump_processes()
162 HASHMAP_FOREACH_KEY(name, pidp, cg->pids) in dump_processes()
165 assert(n == hashmap_size(cg->pids)); in dump_processes()
175 name = hashmap_get(cg->pids, PID_TO_PTR(pids[i])); in dump_processes()
188 more = i+1 < n || cg->children; in dump_processes()
201 if (cg->children) { in dump_processes()
206 children = newa(struct CGroupInfo*, cg->n_children); in dump_processes()
207 LIST_FOREACH(siblings, child, cg->children) in dump_processes()
209 assert(n == cg->n_children); in dump_processes()
245 cg->done = true; in dump_processes()
257 struct CGroupInfo *cg; in dump_extra_processes() local
264 HASHMAP_FOREACH(cg, cgroups) { in dump_extra_processes()
268 if (cg->done) in dump_extra_processes()
271 if (hashmap_isempty(cg->pids)) in dump_extra_processes()
278 if (!GREEDY_REALLOC(pids, n + hashmap_size(cg->pids))) in dump_extra_processes()
281 HASHMAP_FOREACH_KEY(name, pidp, cg->pids) { in dump_extra_processes()
334 struct CGroupInfo *cg; in unit_show_processes() local
397 while ((cg = hashmap_first(cgroups))) in unit_show_processes()
398 remove_cgroup(cgroups, cg); in unit_show_processes()