From e0c46a736412b79b94a21f8512a769b9212b9adf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Feb 2018 19:59:53 +0100 Subject: [PATCH 1/2] pid1: turn memory accounting on by default now After discussions with @htejun it appears it's OK now to enable memory accounting by default for all units without affecting system performance too badly. facebook has made good experiences with deploying memory accounting across their infrastructure. This hence turns MemoryAccounting= from opt-in to opt-out, similar to how TasksAccounting= is already handled. The other accounting options remain off, their performance impact is too big still. --- NEWS | 16 ++++++++++++++++ man/systemd-system.conf.xml | 4 ++-- src/core/main.c | 2 +- src/core/manager.c | 1 + src/core/system.conf | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 2021a23501..b799c19f3b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,21 @@ systemd System and Service Manager +CHANGES WITH 238 in spe: + + * The MemoryAccounting= unit property now defaults to on. After + discussions with the upstream control group maintainers we learnt + that the negative impact of cgroup memory accounting on current + kernels is finally relatively minimal, so that it should be safe to + enable this by default without affecting system performance too + much. Besides memory accounting only tasks accounting is turned on by + default, all other forms of resource accounting (CPU, IO, IP) remain + off for now, because it's not clear yet that their impact is small + enough to move from opt-in to opt-out for them, too. We recommend + downstreams to leave memory accounting on by default, however in some + situations it might be wise to revert this change of defaults, in + particular on very resource constrained systems or when support for + old kernels is a necessity. + CHANGES WITH 237: * Some keyboards come with a zoom see-saw or rocker which until now got diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml index 08f6c91901..d875a3c46f 100644 --- a/man/systemd-system.conf.xml +++ b/man/systemd-system.conf.xml @@ -338,8 +338,8 @@ CPUAccounting=, BlockIOAccounting=, MemoryAccounting=, TasksAccounting= and IPAccounting=. See systemd.resource-control5 - for details on the per-unit settings. DefaultTasksAccounting= defaults to on, the other - four settings to off. + for details on the per-unit settings. DefaultTasksAccounting= and + DefaultMemoryAccounting= default to on, the other three settings to off. diff --git a/src/core/main.c b/src/core/main.c index 56200a8fad..f518656af3 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -135,7 +135,7 @@ static bool arg_default_cpu_accounting = false; static bool arg_default_io_accounting = false; static bool arg_default_ip_accounting = false; static bool arg_default_blockio_accounting = false; -static bool arg_default_memory_accounting = false; +static bool arg_default_memory_accounting = true; static bool arg_default_tasks_accounting = true; static uint64_t arg_default_tasks_max = UINT64_MAX; static sd_id128_t arg_machine_id = {}; diff --git a/src/core/manager.c b/src/core/manager.c index 5021e00b87..27b041c6d2 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -673,6 +673,7 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) { m->unit_file_scope = scope; m->exit_code = _MANAGER_EXIT_CODE_INVALID; m->default_timer_accuracy_usec = USEC_PER_MINUTE; + m->default_memory_accounting = true; m->default_tasks_accounting = true; m->default_tasks_max = UINT64_MAX; m->default_timeout_start_usec = DEFAULT_TIMEOUT_USEC; diff --git a/src/core/system.conf b/src/core/system.conf index 6b86eac33d..51a6e83ecf 100644 --- a/src/core/system.conf +++ b/src/core/system.conf @@ -42,7 +42,7 @@ #DefaultIOAccounting=no #DefaultIPAccounting=no #DefaultBlockIOAccounting=no -#DefaultMemoryAccounting=no +#DefaultMemoryAccounting=yes #DefaultTasksAccounting=yes #DefaultTasksMax=15% #DefaultLimitCPU= From 444d5863334e3f6a4b415ae72d815dead4f73444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 15 Feb 2018 11:43:08 +0100 Subject: [PATCH 2/2] meson: add -Dmemory-accounting-default=true|false This makes it easy to set the default for distributions and users which want to default to off because they primarily use older kernels. --- NEWS | 18 +++++++++--------- man/custom-entities.ent.in | 1 + man/systemd-system.conf.xml | 10 +++++++--- meson.build | 5 +++++ meson_options.txt | 2 ++ src/core/main.c | 2 +- src/core/manager.c | 2 +- src/core/meson.build | 6 +++--- src/core/{system.conf => system.conf.in} | 2 +- 9 files changed, 30 insertions(+), 18 deletions(-) rename src/core/{system.conf => system.conf.in} (96%) diff --git a/NEWS b/NEWS index b799c19f3b..22372a8296 100644 --- a/NEWS +++ b/NEWS @@ -6,15 +6,15 @@ CHANGES WITH 238 in spe: discussions with the upstream control group maintainers we learnt that the negative impact of cgroup memory accounting on current kernels is finally relatively minimal, so that it should be safe to - enable this by default without affecting system performance too - much. Besides memory accounting only tasks accounting is turned on by - default, all other forms of resource accounting (CPU, IO, IP) remain - off for now, because it's not clear yet that their impact is small - enough to move from opt-in to opt-out for them, too. We recommend - downstreams to leave memory accounting on by default, however in some - situations it might be wise to revert this change of defaults, in - particular on very resource constrained systems or when support for - old kernels is a necessity. + enable this by default without affecting system performance. Besides + memory accounting only task accounting is turned on by default, all + other forms of resource accounting (CPU, IO, IP) remain off for now, + because it's not clear yet that their impact is small enough to move + from opt-in to opt-out. We recommend downstreams to leave memory + accounting on by default if kernel 4.14 or higher is are primarily + used. On very resource constrained systems or when support for old + kernels is a necessity, -Dmemory-accounting-default=false can be used + to revert this change. CHANGES WITH 237: diff --git a/man/custom-entities.ent.in b/man/custom-entities.ent.in index 9ea92384aa..a1dbf7133f 100644 --- a/man/custom-entities.ent.in +++ b/man/custom-entities.ent.in @@ -6,3 +6,4 @@ + diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml index d875a3c46f..fca9690092 100644 --- a/man/systemd-system.conf.xml +++ b/man/systemd-system.conf.xml @@ -1,6 +1,9 @@ + "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ + +%entities; +]>