mirror of
https://github.com/systemd/systemd.git
synced 2025-01-18 10:04:04 +03:00
cgroup v2: DefaultCPUAccounting=yes if CPU controller isn't required
We now don't enable the CPU controller just for CPU accounting if we are on 4.15+ and using pure unified hierarchy, as this is provided externally to the CPU controller. This makes CPUAccounting=yes essentially free, so enabling it by default when it's cheap seems like a good idea.
This commit is contained in:
parent
94ddb08d74
commit
a88c5b8ac4
@ -307,8 +307,9 @@
|
||||
<varname>TasksAccounting=</varname>, <varname>IOAccounting=</varname> and <varname>IPAccounting=</varname>. See
|
||||
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
for details on the per-unit settings. <varname>DefaultTasksAccounting=</varname> defaults to yes,
|
||||
<varname>DefaultMemoryAccounting=</varname> to &MEMORY_ACCOUNTING_DEFAULT;, the other four settings to
|
||||
no.</para></listitem>
|
||||
<varname>DefaultMemoryAccounting=</varname> to &MEMORY_ACCOUNTING_DEFAULT;. <varname>DefaultCPUAccounting=</varname>
|
||||
defaults to yes if enabling CPU accounting doesn't require the CPU controller to be enabled (Linux 4.15+ using the
|
||||
unified hierarchy for resource control), otherwise it defaults to no. The other three settings default to no.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "capability-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "clock-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "cpu-set-util.h"
|
||||
@ -119,7 +120,7 @@ static nsec_t arg_timer_slack_nsec = NSEC_INFINITY;
|
||||
static usec_t arg_default_timer_accuracy_usec = 1 * USEC_PER_MINUTE;
|
||||
static Set* arg_syscall_archs = NULL;
|
||||
static FILE* arg_serialization = NULL;
|
||||
static bool arg_default_cpu_accounting = false;
|
||||
static int arg_default_cpu_accounting = -1;
|
||||
static bool arg_default_io_accounting = false;
|
||||
static bool arg_default_ip_accounting = false;
|
||||
static bool arg_default_blockio_accounting = false;
|
||||
@ -702,7 +703,7 @@ static int parse_config_file(void) {
|
||||
{ "Manager", "DefaultLimitNICE", config_parse_rlimit, RLIMIT_NICE, arg_default_rlimit },
|
||||
{ "Manager", "DefaultLimitRTPRIO", config_parse_rlimit, RLIMIT_RTPRIO, arg_default_rlimit },
|
||||
{ "Manager", "DefaultLimitRTTIME", config_parse_rlimit, RLIMIT_RTTIME, arg_default_rlimit },
|
||||
{ "Manager", "DefaultCPUAccounting", config_parse_bool, 0, &arg_default_cpu_accounting },
|
||||
{ "Manager", "DefaultCPUAccounting", config_parse_tristate, 0, &arg_default_cpu_accounting },
|
||||
{ "Manager", "DefaultIOAccounting", config_parse_bool, 0, &arg_default_io_accounting },
|
||||
{ "Manager", "DefaultIPAccounting", config_parse_bool, 0, &arg_default_ip_accounting },
|
||||
{ "Manager", "DefaultBlockIOAccounting", config_parse_bool, 0, &arg_default_blockio_accounting },
|
||||
@ -751,7 +752,14 @@ static void set_manager_defaults(Manager *m) {
|
||||
m->default_restart_usec = arg_default_restart_usec;
|
||||
m->default_start_limit_interval = arg_default_start_limit_interval;
|
||||
m->default_start_limit_burst = arg_default_start_limit_burst;
|
||||
|
||||
/* On 4.15+ with unified hierarchy, CPU accounting is essentially free as it doesn't require the CPU
|
||||
* controller to be enabled, so the default is to enable it unless we got told otherwise. */
|
||||
if (arg_default_cpu_accounting >= 0)
|
||||
m->default_cpu_accounting = arg_default_cpu_accounting;
|
||||
else
|
||||
m->default_cpu_accounting = cpu_accounting_is_cheap();
|
||||
|
||||
m->default_io_accounting = arg_default_io_accounting;
|
||||
m->default_ip_accounting = arg_default_ip_accounting;
|
||||
m->default_blockio_accounting = arg_default_blockio_accounting;
|
||||
|
Loading…
x
Reference in New Issue
Block a user