pid1: add ./configure switch to select default cgroup hierarchy

The default default is set to "legacy", with "hybrid" and "unified"
being the other two alternatives.

There invert the behaviour for systemd.legacy_systemd_cgroup_controller:
if it is not specified on the kernel command line, "hybrid" is used if
selected as the default. If this option is specified, "hybrid" is used if false,
and full "legacy" if true.

Also make all fields in the configure summary lowercase (unless they are
capitalized names) for consistency.

v2:
- update for the fixed interpreation of systemd.legacy_systemd_cgroup_controller
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-02-18 23:13:15 -05:00
parent f08e928720
commit 77fab2a91c
2 changed files with 45 additions and 27 deletions

View file

@ -612,6 +612,21 @@ AC_ARG_WITH([fallback-hostname],
AC_SUBST(FALLBACK_HOSTNAME) AC_SUBST(FALLBACK_HOSTNAME)
AC_DEFINE_UNQUOTED(FALLBACK_HOSTNAME, ["$FALLBACK_HOSTNAME"], [The hostname used if none configured]) AC_DEFINE_UNQUOTED(FALLBACK_HOSTNAME, ["$FALLBACK_HOSTNAME"], [The hostname used if none configured])
# ------------------------------------------------------------------------------
AC_ARG_WITH(default-hierarchy,
AS_HELP_STRING([--with-default-hierarchy=MODE],
[default cgroup hierarchy, defaults to "legacy"]),
[DEFAULT_HIERARCHY="$withval"],
[DEFAULT_HIERARCHY="legacy"])
AS_CASE("$DEFAULT_HIERARCHY",
[legacy], [mode=CGROUP_UNIFIED_NONE],
[hybrid], [mode=CGROUP_UNIFIED_SYSTEMD],
[unified], [mode=CGROUP_UNIFIED_ALL],
AC_MSG_ERROR(Bad default hierarchy mode ${DEFAULT_HIERARCHY}))
AC_DEFINE_UNQUOTED(DEFAULT_HIERARCHY, [$mode], [Default cgroup hierarchy])
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
have_xz=no have_xz=no
AC_ARG_ENABLE(xz, AS_HELP_STRING([--disable-xz], [disable optional XZ support])) AC_ARG_ENABLE(xz, AS_HELP_STRING([--disable-xz], [disable optional XZ support]))
@ -1658,19 +1673,20 @@ AC_MSG_RESULT([
backlight: ${have_backlight} backlight: ${have_backlight}
rfkill: ${have_rfkill} rfkill: ${have_rfkill}
logind: ${have_logind} logind: ${have_logind}
Default KillUserProcesses setting: ${KILL_USER_PROCESSES} default cgroup hierarchy: ${DEFAULT_HIERARCHY}
default KillUserProcesses setting: ${KILL_USER_PROCESSES}
machined: ${have_machined} machined: ${have_machined}
importd: ${have_importd} importd: ${have_importd}
hostnamed: ${have_hostnamed} hostnamed: ${have_hostnamed}
timedated: ${have_timedated} timedated: ${have_timedated}
timesyncd: ${have_timesyncd} timesyncd: ${have_timesyncd}
Default NTP servers: ${NTP_SERVERS} default NTP servers: ${NTP_SERVERS}
time epoch: ${TIME_EPOCH} time epoch: ${TIME_EPOCH}
localed: ${have_localed} localed: ${have_localed}
networkd: ${have_networkd} networkd: ${have_networkd}
resolved: ${have_resolved} resolved: ${have_resolved}
Default DNS servers: ${DNS_SERVERS} default DNS servers: ${DNS_SERVERS}
Default DNSSEC mode: ${DEFAULT_DNSSEC_MODE} default DNSSEC mode: ${DEFAULT_DNSSEC_MODE}
coredump: ${have_coredump} coredump: ${have_coredump}
polkit: ${have_polkit} polkit: ${have_polkit}
efi: ${have_efi} efi: ${have_efi}
@ -1709,27 +1725,27 @@ AC_MSG_RESULT([
rootlib dir: ${with_rootlibdir} rootlib dir: ${with_rootlibdir}
SysV init scripts: ${SYSTEM_SYSVINIT_PATH} SysV init scripts: ${SYSTEM_SYSVINIT_PATH}
SysV rc?.d directories: ${SYSTEM_SYSVRCND_PATH} SysV rc?.d directories: ${SYSTEM_SYSVRCND_PATH}
Build Python: ${PYTHON} build Python: ${PYTHON}
PAM modules dir: ${with_pamlibdir} PAM modules dir: ${with_pamlibdir}
PAM configuration dir: ${with_pamconfdir} PAM configuration dir: ${with_pamconfdir}
D-Bus policy dir: ${with_dbuspolicydir} D-Bus policy dir: ${with_dbuspolicydir}
D-Bus session dir: ${with_dbussessionservicedir} D-Bus session dir: ${with_dbussessionservicedir}
D-Bus system dir: ${with_dbussystemservicedir} D-Bus system dir: ${with_dbussystemservicedir}
Bash completions dir: ${with_bashcompletiondir} bash completions dir: ${with_bashcompletiondir}
Zsh completions dir: ${with_zshcompletiondir} zsh completions dir: ${with_zshcompletiondir}
Extra start script: ${RC_LOCAL_SCRIPT_PATH_START} extra start script: ${RC_LOCAL_SCRIPT_PATH_START}
Extra stop script: ${RC_LOCAL_SCRIPT_PATH_STOP} extra stop script: ${RC_LOCAL_SCRIPT_PATH_STOP}
Adm group: ${have_adm_group} adm group: ${have_adm_group}
Wheel group: ${have_wheel_group} wheel group: ${have_wheel_group}
Debug shell: ${SUSHELL} @ ${DEBUGTTY} debug shell: ${SUSHELL} @ ${DEBUGTTY}
TTY GID: ${TTY_GID} TTY GID: ${TTY_GID}
Maximum system UID: ${SYSTEM_UID_MAX} maximum system UID: ${SYSTEM_UID_MAX}
Maximum system GID: ${SYSTEM_GID_MAX} maximum system GID: ${SYSTEM_GID_MAX}
Certificate root: ${CERTIFICATEROOT} certificate root: ${CERTIFICATEROOT}
Support URL: ${SUPPORT_URL} support URL: ${SUPPORT_URL}
nobody user name: ${NOBODY_USER_NAME} nobody user name: ${NOBODY_USER_NAME}
nobody group name: ${NOBODY_GROUP_NAME} nobody group name: ${NOBODY_GROUP_NAME}
Fallback hostname: ${FALLBACK_HOSTNAME} fallback hostname: ${FALLBACK_HOSTNAME}
CFLAGS: ${OUR_CFLAGS} ${CFLAGS} CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}

View file

@ -2408,23 +2408,24 @@ bool cg_is_unified_wanted(void) {
static thread_local int wanted = -1; static thread_local int wanted = -1;
int r; int r;
bool b; bool b;
const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_ALL;
/* If the hierarchy is already mounted, then follow whatever /* If the hierarchy is already mounted, then follow whatever
* was chosen for it. */ * was chosen for it. */
if (cg_unified_flush() >= 0) if (cg_unified_flush() >= 0)
return cg_all_unified(); return cg_all_unified();
/* Otherwise, let's see what the kernel command line has to /* If we have a cached value, return that. */
* say. Since checking that is expensive, let's cache the
* result. */
if (wanted >= 0) if (wanted >= 0)
return wanted; return wanted;
/* Otherwise, let's see what the kernel command line has to say.
* Since checking is expensive, cache a non-error result. */
r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b); r = proc_cmdline_get_bool("systemd.unified_cgroup_hierarchy", &b);
if (r < 0) if (r < 0)
return false; return is_default;
return (wanted = r > 0 ? b : false); return (wanted = r > 0 ? b : is_default);
} }
bool cg_is_legacy_wanted(void) { bool cg_is_legacy_wanted(void) {
@ -2435,6 +2436,7 @@ bool cg_is_unified_systemd_controller_wanted(void) {
static thread_local int wanted = -1; static thread_local int wanted = -1;
int r; int r;
bool b; bool b;
const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_SYSTEMD;
/* If the unified hierarchy is requested in full, no need to /* If the unified hierarchy is requested in full, no need to
* bother with this. */ * bother with this. */
@ -2446,19 +2448,19 @@ bool cg_is_unified_systemd_controller_wanted(void) {
if (cg_unified_flush() >= 0) if (cg_unified_flush() >= 0)
return cg_unified(SYSTEMD_CGROUP_CONTROLLER); return cg_unified(SYSTEMD_CGROUP_CONTROLLER);
/* Otherwise, let's see what the kernel command line has to /* If we have a cached value, return that. */
* say. Since checking that is expensive, let's cache the
* result. */
if (wanted >= 0) if (wanted >= 0)
return wanted; return wanted;
/* Otherwise, let's see what the kernel command line has to say.
* Since checking is expensive, cache a non-error result. */
r = proc_cmdline_get_bool("systemd.legacy_systemd_cgroup_controller", &b); r = proc_cmdline_get_bool("systemd.legacy_systemd_cgroup_controller", &b);
if (r < 0) if (r < 0)
return false; return is_default;
/* The meaning of the kernel option is reversed wrt. to the return value /* The meaning of the kernel option is reversed wrt. to the return value
* of this function, hence the negation. */ * of this function, hence the negation. */
return (wanted = r > 0 ? !b : false); return (wanted = r > 0 ? !b : is_default);
} }
int cg_weight_parse(const char *s, uint64_t *ret) { int cg_weight_parse(const char *s, uint64_t *ret) {