From: Zbigniew Jędrzejewski-Szmek Date: Fri, 19 Aug 2016 23:00:25 +0000 (-0400) Subject: Merge pull request #3965 from htejun/systemd-controller-on-unified X-Git-Tag: v232~274 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2056ec192742d45aa72a851dbd22ad1fe0bc91a2;p=thirdparty%2Fsystemd.git Merge pull request #3965 from htejun/systemd-controller-on-unified --- 2056ec192742d45aa72a851dbd22ad1fe0bc91a2 diff --cc src/basic/cgroup-util.c index 25ef8a5c76e,1ef1de0604e..9b44c5a7a59 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@@ -2333,6 -2356,50 +2356,50 @@@ bool cg_is_legacy_wanted(void) return !cg_is_unified_wanted(); } + bool cg_is_unified_systemd_controller_wanted(void) { + static thread_local int wanted = -1; + int r, unified; + + /* If the unified hierarchy is requested in full, no need to + * bother with this. */ + if (cg_is_unified_wanted()) + return 0; + + /* If the hierarchy is already mounted, then follow whatever + * was chosen for it. */ + unified = cg_unified(SYSTEMD_CGROUP_CONTROLLER); + if (unified >= 0) + return unified; + + /* Otherwise, let's see what the kernel command line has to + * say. Since checking that is expensive, let's cache the + * result. */ + if (wanted >= 0) + return wanted; + + r = get_proc_cmdline_key("systemd.legacy_systemd_cgroup_controller", NULL); - if (r > 0) { ++ if (r > 0) + wanted = false; - } else { ++ else { + _cleanup_free_ char *value = NULL; + + r = get_proc_cmdline_key("systemd.legacy_systemd_cgroup_controller=", &value); + if (r < 0) + return true; + + if (r == 0) + wanted = true; + else + wanted = parse_boolean(value) <= 0; + } + + return wanted; + } + + bool cg_is_legacy_systemd_controller_wanted(void) { + return cg_is_legacy_wanted() && !cg_is_unified_systemd_controller_wanted(); + } + int cg_weight_parse(const char *s, uint64_t *ret) { uint64_t u; int r; diff --cc src/basic/cgroup-util.h index f1617a16be9,5d9bee50f52..1a61c7ad22a --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@@ -112,10 -112,13 +112,17 @@@ static inline bool CGROUP_BLKIO_WEIGHT_ (x >= CGROUP_BLKIO_WEIGHT_MIN && x <= CGROUP_BLKIO_WEIGHT_MAX); } +/* Default resource limits */ +#define DEFAULT_TASKS_MAX_PERCENTAGE 15U /* 15% of PIDs, 4915 on default settings */ +#define DEFAULT_USER_TASKS_MAX_PERCENTAGE 33U /* 33% of PIDs, 10813 on default settings */ + + typedef enum CGroupUnified { + CGROUP_UNIFIED_UNKNOWN = -1, + CGROUP_UNIFIED_NONE = 0, /* Both systemd and controllers on legacy */ + CGROUP_UNIFIED_SYSTEMD = 1, /* Only systemd on unified */ + CGROUP_UNIFIED_ALL = 2, /* Both systemd and controllers on unified */ + } CGroupUnified; + /* * General rules: *