From: Michal Koutný Date: Fri, 1 May 2020 12:00:42 +0000 (+0200) Subject: cgroup: Cleanup function usage X-Git-Tag: v247-rc1~366^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9ef594454d41adf28b2cbc900cb7c781ce40160;p=thirdparty%2Fsystemd.git cgroup: Cleanup function usage Some masks shouldn't be needed externally, so keep their functions in the module (others would fit there too but they're used in tests) to think twice if something would depend on them. Drop unused function cg_attach_many_everywhere. Use cgroup_realized instead of cgroup_path when we actually ask for realized. This should not cause any functional changes. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 860f36052b7..a6a9e0c7d4a 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -1495,6 +1495,14 @@ CGroupMask unit_get_delegate_mask(Unit *u) { return CGROUP_MASK_EXTEND_JOINED(c->delegate_controllers); } +static CGroupMask unit_get_subtree_mask(Unit *u) { + + /* Returns the mask of this subtree, meaning of the group + * itself and its children. */ + + return unit_get_own_mask(u) | unit_get_members_mask(u); +} + CGroupMask unit_get_members_mask(Unit *u) { assert(u); @@ -1532,7 +1540,7 @@ CGroupMask unit_get_siblings_mask(Unit *u) { return unit_get_subtree_mask(u); /* we are the top-level slice */ } -CGroupMask unit_get_disable_mask(Unit *u) { +static CGroupMask unit_get_disable_mask(Unit *u) { CGroupContext *c; c = unit_get_cgroup_context(u); @@ -1557,14 +1565,6 @@ CGroupMask unit_get_ancestor_disable_mask(Unit *u) { return mask; } -CGroupMask unit_get_subtree_mask(Unit *u) { - - /* Returns the mask of this subtree, meaning of the group - * itself and its children. */ - - return unit_get_own_mask(u) | unit_get_members_mask(u); -} - CGroupMask unit_get_target_mask(Unit *u) { CGroupMask mask; @@ -2177,7 +2177,7 @@ static int unit_realize_cgroup_now_disable(Unit *u, ManagerState state) { /* The cgroup for this unit might not actually be fully * realised yet, in which case it isn't holding any controllers * open anyway. */ - if (!m->cgroup_path) + if (!m->cgroup_realized) continue; /* We must disable those below us first in order to release the diff --git a/src/core/cgroup.h b/src/core/cgroup.h index be9632d8b66..9ac5c8bfc0b 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -203,8 +203,6 @@ CGroupMask unit_get_own_mask(Unit *u); CGroupMask unit_get_delegate_mask(Unit *u); CGroupMask unit_get_members_mask(Unit *u); CGroupMask unit_get_siblings_mask(Unit *u); -CGroupMask unit_get_subtree_mask(Unit *u); -CGroupMask unit_get_disable_mask(Unit *u); CGroupMask unit_get_ancestor_disable_mask(Unit *u); CGroupMask unit_get_target_mask(Unit *u); diff --git a/src/shared/cgroup-setup.c b/src/shared/cgroup-setup.c index cd2ba6149e3..856e7762960 100644 --- a/src/shared/cgroup-setup.c +++ b/src/shared/cgroup-setup.c @@ -655,23 +655,6 @@ int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_m return 0; } -int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, cg_migrate_callback_t path_callback, void *userdata) { - Iterator i; - void *pidp; - int r = 0; - - SET_FOREACH(pidp, pids, i) { - pid_t pid = PTR_TO_PID(pidp); - int q; - - q = cg_attach_everywhere(supported, path, pid, path_callback, userdata); - if (q < 0 && r >= 0) - r = q; - } - - return r; -} - int cg_migrate_v1_controllers(CGroupMask supported, CGroupMask mask, const char *from, cg_migrate_callback_t to_callback, void *userdata) { CGroupController c; CGroupMask done; diff --git a/src/shared/cgroup-setup.h b/src/shared/cgroup-setup.h index 72c2b6ee6a5..43ce32e30d3 100644 --- a/src/shared/cgroup-setup.h +++ b/src/shared/cgroup-setup.h @@ -28,7 +28,6 @@ int cg_migrate_recursive_fallback(const char *cfrom, const char *pfrom, const ch int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path); int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_migrate_callback_t callback, void *userdata); -int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, cg_migrate_callback_t callback, void *userdata); int cg_migrate_v1_controllers(CGroupMask supported, CGroupMask mask, const char *from, cg_migrate_callback_t to_callback, void *userdata); int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root); int cg_trim_v1_controllers(CGroupMask supported, CGroupMask mask, const char *path, bool delete_root);