summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorTejun Heo <htejun@fb.com>2016-08-15 18:13:36 -0400
committerSven Eden <yamakuzure@gmx.net>2017-07-05 08:50:51 +0200
commit682a7fe521cc3d983dc6c690cbc107a3c8a13344 (patch)
tree8c16dd3f24e69ea96cc13a3d5aa553b8557c79fa /src/core
parentd4ce8390c5aa345602b51099e9d3ed3b74d3ec4d (diff)
core: rename cg_unified() to cg_all_unified()
A following patch will update cgroup handling so that the elogind controller (/sys/fs/cgroup/elogind) can use the unified hierarchy even if the kernel resource controllers are on the legacy hierarchies. This would require distinguishing whether all controllers are on cgroup v2 or only the elogind controller is. In preparation, this patch renames cg_unified() to cg_all_unified(). This patch doesn't cause any functional changes.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/cgroup.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 56f065fdb..a7bb97985 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1247,7 +1247,7 @@ int unit_watch_cgroup(Unit *u) {
return 0;
/* Only applies to the unified hierarchy */
- r = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
+ r = cg_all_unified();
if (r < 0)
return log_unit_error_errno(u, r, "Failed detect whether the unified hierarchy is used: %m");
if (r == 0)
@@ -1647,7 +1647,7 @@ int unit_watch_all_pids(Unit *u) {
if (!u->cgroup_path)
return -ENOENT;
- if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) > 0) /* On unified we can use proper notifications */
+ if (cg_all_unified() > 0) /* On unified we can use proper notifications */
return 0;
return unit_watch_pids_in_path(u, u->cgroup_path);
@@ -1721,7 +1721,7 @@ static int on_cgroup_inotify_event(sd_event_source *s, int fd, uint32_t revents,
int manager_setup_cgroup(Manager *m) {
_cleanup_free_ char *path = NULL;
CGroupController c;
- int r, all_unified, systemd_unified;
+ int r, unified;
char *e;
assert(m);
@@ -1762,17 +1762,11 @@ int manager_setup_cgroup(Manager *m) {
if (r < 0)
return log_error_errno(r, "Cannot find cgroup mount point: %m");
- all_unified = cg_all_unified();
- systemd_unified = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
-
- if (all_unified < 0 || systemd_unified < 0)
- return log_error_errno(all_unified < 0 ? all_unified : systemd_unified,
- "Couldn't determine if we are running in the unified hierarchy: %m");
-
- if (all_unified > 0)
+ unified = cg_all_unified();
+ if (unified < 0)
+ return log_error_errno(r, "Couldn't determine if we are running in the unified hierarchy: %m");
+ if (unified > 0)
log_debug("Unified cgroup hierarchy is located at %s.", path);
- else if (systemd_unified > 0)
- log_debug("Unified cgroup hierarchy is located at %s. Controllers are on legacy hierarchies.", path);
else
log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path);
@@ -1780,7 +1774,7 @@ int manager_setup_cgroup(Manager *m) {
const char *scope_path;
/* 3. Install agent */
- if (systemd_unified) {
+ if (unified) {
/* In the unified hierarchy we can get
* cgroup empty notifications via inotify. */
@@ -1858,7 +1852,7 @@ int manager_setup_cgroup(Manager *m) {
return log_error_errno(errno, "Failed to open pin file: %m");
/* 6. Always enable hierarchical support if it exists... */
- if (!all_unified)
+ if (!unified)
(void) cg_set_attribute("memory", "/", "memory.use_hierarchy", "1");
}