|
|
a19bc6 |
From fc7fdb72096d2baeec3238a0ef324569a05da4ae Mon Sep 17 00:00:00 2001
|
|
|
a19bc6 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
a19bc6 |
Date: Fri, 13 Nov 2015 17:13:55 +0100
|
|
|
a19bc6 |
Subject: [PATCH] core: add new DefaultTasksMax= setting for system.conf
|
|
|
a19bc6 |
|
|
|
a19bc6 |
This allows initializing the TasksMax= setting of all units by default
|
|
|
a19bc6 |
to some fixed value, instead of leaving it at infinity as before.
|
|
|
a19bc6 |
|
|
|
a19bc6 |
Cherry-picked from: 0af20ea2ee2af2bcf2258e7a8e1a13181a6a75d6
|
|
|
a19bc6 |
Related: #1337244
|
|
|
a19bc6 |
---
|
|
|
a19bc6 |
man/systemd-system.conf.xml | 13 ++++++++++++-
|
|
|
a19bc6 |
man/systemd.resource-control.xml | 5 ++++-
|
|
|
a19bc6 |
src/core/dbus-manager.c | 1 +
|
|
|
a19bc6 |
src/core/load-fragment-gperf.gperf.m4 | 2 +-
|
|
|
a19bc6 |
src/core/load-fragment.c | 7 ++++---
|
|
|
a19bc6 |
src/core/main.c | 3 +++
|
|
|
a19bc6 |
src/core/manager.h | 1 +
|
|
|
a19bc6 |
src/core/system.conf | 2 ++
|
|
|
a19bc6 |
src/core/unit.c | 3 +++
|
|
|
a19bc6 |
src/shared/cgroup-util.c | 3 ++-
|
|
|
a19bc6 |
10 files changed, 33 insertions(+), 7 deletions(-)
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
|
|
|
c62b8e |
index d367ccd130..53e8ff665a 100644
|
|
|
a19bc6 |
--- a/man/systemd-system.conf.xml
|
|
|
a19bc6 |
+++ b/man/systemd-system.conf.xml
|
|
|
a19bc6 |
@@ -1,4 +1,4 @@
|
|
|
a19bc6 |
-
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
|
|
|
a19bc6 |
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
|
|
a19bc6 |
|
|
|
181b3f |
@@ -319,6 +319,17 @@
|
|
|
181b3f |
for details on the per-unit settings.</para></listitem>
|
|
|
a19bc6 |
</varlistentry>
|
|
|
a19bc6 |
|
|
|
181b3f |
+ <varlistentry>
|
|
|
a19bc6 |
+ <term><varname>DefaultTasksMax=</varname></term>
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
+ <listitem><para>Configure the default value for the per-unit
|
|
|
a19bc6 |
+ <varname>TasksMax=</varname> setting. See
|
|
|
a19bc6 |
+ <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
a19bc6 |
+ for details. This setting applies to all unit types that
|
|
|
a19bc6 |
+ support resource control settings, with the exception of slice
|
|
|
a19bc6 |
+ units.</para></listitem>
|
|
|
a19bc6 |
+ </varlistentry>
|
|
|
a19bc6 |
+
|
|
|
181b3f |
<varlistentry>
|
|
|
a19bc6 |
<term><varname>DefaultLimitCPU=</varname></term>
|
|
|
a19bc6 |
<term><varname>DefaultLimitFSIZE=</varname></term>
|
|
|
a19bc6 |
diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml
|
|
|
c62b8e |
index 6b9329bbee..217105ee5a 100644
|
|
|
a19bc6 |
--- a/man/systemd.resource-control.xml
|
|
|
a19bc6 |
+++ b/man/systemd.resource-control.xml
|
|
|
a19bc6 |
@@ -231,7 +231,10 @@
|
|
|
a19bc6 |
see
|
|
|
a19bc6 |
url="https://www.kernel.org/doc/Documentation/cgroups/pids.txt">pids.txt</ulink>.</para>
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- <para>Implies <literal>TasksAccounting=true</literal>.</para>
|
|
|
a19bc6 |
+ <para>Implies <literal>TasksAccounting=true</literal>. The
|
|
|
a19bc6 |
+ system default for this setting may be controlled with
|
|
|
a19bc6 |
+ <varname>DefaultTasksMax=</varname> in
|
|
|
a19bc6 |
+ <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
|
|
|
a19bc6 |
</listitem>
|
|
|
a19bc6 |
</varlistentry>
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
|
|
c62b8e |
index 7ba1b519ea..c92f8c6bfc 100644
|
|
|
a19bc6 |
--- a/src/core/dbus-manager.c
|
|
|
a19bc6 |
+++ b/src/core/dbus-manager.c
|
|
|
a19bc6 |
@@ -2039,6 +2039,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
|
|
|
a19bc6 |
SD_BUS_WRITABLE_PROPERTY("ShutdownWatchdogUSec", "t", bus_property_get_usec, bus_property_set_usec, offsetof(Manager, shutdown_watchdog), 0),
|
|
|
a19bc6 |
SD_BUS_PROPERTY("ControlGroup", "s", NULL, offsetof(Manager, cgroup_root), 0),
|
|
|
a19bc6 |
SD_BUS_PROPERTY("SystemState", "s", property_get_system_state, 0, 0),
|
|
|
a19bc6 |
+ SD_BUS_PROPERTY("DefaultTasksMax", "t", NULL, offsetof(Manager, default_tasks_max), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
a19bc6 |
|
|
|
a19bc6 |
SD_BUS_METHOD("GetUnit", "s", "o", method_get_unit, SD_BUS_VTABLE_UNPRIVILEGED),
|
|
|
a19bc6 |
SD_BUS_METHOD("GetUnitByPID", "u", "o", method_get_unit_by_pid, SD_BUS_VTABLE_UNPRIVILEGED),
|
|
|
a19bc6 |
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
|
|
|
c62b8e |
index 26e4c618ee..b2fe627af3 100644
|
|
|
a19bc6 |
--- a/src/core/load-fragment-gperf.gperf.m4
|
|
|
a19bc6 |
+++ b/src/core/load-fragment-gperf.gperf.m4
|
|
|
a19bc6 |
@@ -126,7 +126,7 @@ $1.BlockIODeviceWeight, config_parse_blockio_device_weight, 0,
|
|
|
a19bc6 |
$1.BlockIOReadBandwidth, config_parse_blockio_bandwidth, 0, offsetof($1, cgroup_context)
|
|
|
a19bc6 |
$1.BlockIOWriteBandwidth, config_parse_blockio_bandwidth, 0, offsetof($1, cgroup_context)
|
|
|
a19bc6 |
$1.TasksAccounting, config_parse_bool, 0, offsetof($1, cgroup_context.tasks_accounting)
|
|
|
a19bc6 |
-$1.TasksMax, config_parse_tasks_max, 0, offsetof($1, cgroup_context)
|
|
|
a19bc6 |
+$1.TasksMax, config_parse_tasks_max, 0, offsetof($1, cgroup_context.tasks_max)
|
|
|
a19bc6 |
$1.Delegate, config_parse_bool, 0, offsetof($1, cgroup_context.delegate)'
|
|
|
a19bc6 |
)m4_dnl
|
|
|
a19bc6 |
Unit.Description, config_parse_unit_string_printf, 0, offsetof(Unit, description)
|
|
|
a19bc6 |
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
|
|
|
c62b8e |
index 7d2e737d05..c1ffee2c7e 100644
|
|
|
a19bc6 |
--- a/src/core/load-fragment.c
|
|
|
a19bc6 |
+++ b/src/core/load-fragment.c
|
|
|
a19bc6 |
@@ -3081,12 +3081,11 @@ int config_parse_tasks_max(
|
|
|
a19bc6 |
void *data,
|
|
|
a19bc6 |
void *userdata) {
|
|
|
a19bc6 |
|
|
|
a19bc6 |
- CGroupContext *c = data;
|
|
|
a19bc6 |
- uint64_t u;
|
|
|
a19bc6 |
+ uint64_t *tasks_max = data, u;
|
|
|
a19bc6 |
int r;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
if (isempty(rvalue) || streq(rvalue, "infinity")) {
|
|
|
a19bc6 |
- c->tasks_max = (uint64_t) -1;
|
|
|
a19bc6 |
+ *tasks_max = (uint64_t) -1;
|
|
|
a19bc6 |
return 0;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -3096,6 +3095,8 @@ int config_parse_tasks_max(
|
|
|
a19bc6 |
return 0;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+ *tasks_max = u;
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
return 0;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/core/main.c b/src/core/main.c
|
|
|
c62b8e |
index aca05a5358..50c9714f78 100644
|
|
|
a19bc6 |
--- a/src/core/main.c
|
|
|
a19bc6 |
+++ b/src/core/main.c
|
|
|
a19bc6 |
@@ -118,6 +118,7 @@ static bool arg_default_blockio_accounting = false;
|
|
|
a19bc6 |
static bool arg_default_memory_accounting = false;
|
|
|
a19bc6 |
static EmergencyAction arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE;
|
|
|
a19bc6 |
static bool arg_default_tasks_accounting = false;
|
|
|
a19bc6 |
+static uint64_t arg_default_tasks_max = (uint64_t) -1;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
static void nop_handler(int sig) {}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -678,6 +679,7 @@ static int parse_config_file(void) {
|
|
|
a19bc6 |
{ "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting },
|
|
|
a19bc6 |
{ "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action },
|
|
|
a19bc6 |
{ "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting },
|
|
|
a19bc6 |
+ { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max },
|
|
|
a19bc6 |
{}
|
|
|
a19bc6 |
};
|
|
|
a19bc6 |
|
|
|
a19bc6 |
@@ -1688,6 +1690,7 @@ int main(int argc, char *argv[]) {
|
|
|
a19bc6 |
m->default_blockio_accounting = arg_default_blockio_accounting;
|
|
|
a19bc6 |
m->default_memory_accounting = arg_default_memory_accounting;
|
|
|
a19bc6 |
m->default_tasks_accounting = arg_default_tasks_accounting;
|
|
|
a19bc6 |
+ m->default_tasks_max = arg_default_tasks_max;
|
|
|
a19bc6 |
m->runtime_watchdog = arg_runtime_watchdog;
|
|
|
a19bc6 |
m->shutdown_watchdog = arg_shutdown_watchdog;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
diff --git a/src/core/manager.h b/src/core/manager.h
|
|
|
c62b8e |
index 96dcd83dc0..e91e7bd8b3 100644
|
|
|
a19bc6 |
--- a/src/core/manager.h
|
|
|
a19bc6 |
+++ b/src/core/manager.h
|
|
|
a19bc6 |
@@ -263,6 +263,7 @@ struct Manager {
|
|
|
a19bc6 |
bool default_blockio_accounting;
|
|
|
a19bc6 |
bool default_tasks_accounting;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
+ uint64_t default_tasks_max;
|
|
|
a19bc6 |
usec_t default_timer_accuracy_usec;
|
|
|
a19bc6 |
|
|
|
a19bc6 |
struct rlimit *rlimit[_RLIMIT_MAX];
|
|
|
a19bc6 |
diff --git a/src/core/system.conf b/src/core/system.conf
|
|
|
c62b8e |
index a11f599038..91ef01cd0f 100644
|
|
|
a19bc6 |
--- a/src/core/system.conf
|
|
|
a19bc6 |
+++ b/src/core/system.conf
|
|
|
a19bc6 |
@@ -40,6 +40,8 @@
|
|
|
a19bc6 |
#DefaultCPUAccounting=no
|
|
|
a19bc6 |
#DefaultBlockIOAccounting=no
|
|
|
a19bc6 |
#DefaultMemoryAccounting=no
|
|
|
a19bc6 |
+#DefaultTasksAccounting=no
|
|
|
a19bc6 |
+#DefaultTasksMax=
|
|
|
a19bc6 |
#DefaultLimitCPU=
|
|
|
a19bc6 |
#DefaultLimitFSIZE=
|
|
|
a19bc6 |
#DefaultLimitDATA=
|
|
|
a19bc6 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
c62b8e |
index 2fcb4fbf07..6a2ad6ed38 100644
|
|
|
a19bc6 |
--- a/src/core/unit.c
|
|
|
a19bc6 |
+++ b/src/core/unit.c
|
|
|
a19bc6 |
@@ -127,6 +127,9 @@ static void unit_init(Unit *u) {
|
|
|
a19bc6 |
cc->blockio_accounting = u->manager->default_blockio_accounting;
|
|
|
a19bc6 |
cc->memory_accounting = u->manager->default_memory_accounting;
|
|
|
a19bc6 |
cc->tasks_accounting = u->manager->default_tasks_accounting;
|
|
|
a19bc6 |
+
|
|
|
a19bc6 |
+ if (u->type != UNIT_SLICE)
|
|
|
a19bc6 |
+ cc->tasks_max = u->manager->default_tasks_max;
|
|
|
a19bc6 |
}
|
|
|
a19bc6 |
|
|
|
a19bc6 |
ec = unit_get_exec_context(u);
|
|
|
a19bc6 |
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
|
|
|
c62b8e |
index cf757d2b23..c5d9e4bb58 100644
|
|
|
a19bc6 |
--- a/src/shared/cgroup-util.c
|
|
|
a19bc6 |
+++ b/src/shared/cgroup-util.c
|
|
|
a19bc6 |
@@ -1606,7 +1606,8 @@ static const char mask_names[] =
|
|
|
a19bc6 |
"cpuacct\0"
|
|
|
a19bc6 |
"blkio\0"
|
|
|
a19bc6 |
"memory\0"
|
|
|
a19bc6 |
- "devices\0";
|
|
|
a19bc6 |
+ "devices\0"
|
|
|
a19bc6 |
+ "pids\0";
|
|
|
a19bc6 |
|
|
|
a19bc6 |
int cg_create_everywhere(CGroupControllerMask supported, CGroupControllerMask mask, const char *path) {
|
|
|
a19bc6 |
CGroupControllerMask bit = 1;
|