[systemd-commits] man/systemd-system.conf.xml man/systemd.resource-control.xml src/core
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Feb 24 14:52:40 PST 2014
man/systemd-system.conf.xml | 31 +++++++++++++++++++++++++------
man/systemd.resource-control.xml | 20 ++++++++++++++------
src/core/main.c | 9 +++++++++
src/core/manager.h | 7 +++++--
src/core/mount.c | 4 +++-
src/core/scope.c | 2 ++
src/core/service.c | 8 ++++----
src/core/slice.c | 1 +
src/core/socket.c | 4 +++-
src/core/swap.c | 4 +++-
src/core/system.conf | 3 +++
src/core/unit.c | 19 ++++++++++++++++++-
src/core/unit.h | 3 ++-
13 files changed, 92 insertions(+), 23 deletions(-)
New commits:
commit 085afe36cb823e7d5b8c5f3ef21ebb9639bac78b
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Feb 24 23:50:10 2014 +0100
core: add global settings for enabling CPUAccounting=, MemoryAccounting=, BlockIOAccounting= for all units at once
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index f3a89ad..a7dfc03 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -292,7 +292,7 @@
<varname>TimeoutStartSec=</varname>,
<varname>TimeoutStopSec=</varname> and
<varname>RestartSec=</varname> (for
- service units, see
+ services, see
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for details on the per-unit
settings). For non-service units,
@@ -301,18 +301,20 @@
<varname>TimeoutSec=</varname> value.
</para></listitem>
</varlistentry>
+
<varlistentry>
<term><varname>DefaultStartLimitInterval=</varname></term>
<term><varname>DefaultStartLimitBurst=</varname></term>
- <listitem><para>Configure the default start rate
- limiting, as configured per-service by
- <varname>StartLimitInterval=</varname> and
+ <listitem><para>Configure the default
+ unit start rate limiting, as
+ configured per-service by
+ <varname>StartLimitInterval=</varname>
+ and
<varname>StartLimitBurst=</varname>. See
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for details on the per-service
- settings).
- </para></listitem>
+ settings.</para></listitem>
</varlistentry>
<varlistentry>
@@ -338,6 +340,23 @@
</varlistentry>
<varlistentry>
+ <term><varname>DefaultCPUAccounting=</varname></term>
+ <term><varname>DefaultBlockIOAccounting=</varname></term>
+ <term><varname>DefaultMemoryAccounting=</varname></term>
+
+ <listitem><para>Configure the default
+ resource accounting settings, as
+ configured per-unit by
+ <varname>CPUAccounting=</varname>,
+ <varname>BlockIOAccounting=</varname>
+ and
+ <varname>MemoryAccounting=</varname>. See
+ <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+ for details on the per-unit
+ settings.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>DefaultLimitCPU=</varname></term>
<term><varname>DefaultLimitFSIZE=</varname></term>
<term><varname>DefaultLimitDATA=</varname></term>
diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml
index e923b6d..c3fd5fc 100644
--- a/man/systemd.resource-control.xml
+++ b/man/systemd.resource-control.xml
@@ -105,8 +105,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<para>Turn on CPU usage accounting for this unit. Takes a
boolean argument. Note that turning on CPU accounting for
one unit might also implicitly turn it on for all units
- contained in the same slice and for all its parent slices and
- the units contained therein.</para>
+ contained in the same slice and for all its parent slices
+ and the units contained therein. The system default for this
+ setting maybe controlled with
+ <varname>DefaultCPUAccounting=</varname> in
+ <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
</listitem>
</varlistentry>
@@ -132,8 +135,10 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<para>Turn on process and kernel memory accounting for this
unit. Takes a boolean argument. Note that turning on memory
accounting for one unit might also implicitly turn it on for
- all units contained in the same slice and for all its parent
- slices and the units contained therein.</para>
+ all its parent slices. The system default for this setting
+ maybe controlled with
+ <varname>DefaultMemoryAccounting=</varname> in
+ <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
</listitem>
</varlistentry>
@@ -164,8 +169,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<para>Turn on Block IO accounting for this unit. Takes a
boolean argument. Note that turning on block IO accounting
for one unit might also implicitly turn it on for all units
- contained in the same slice and all for its parent slices and
- the units contained therein.</para>
+ contained in the same slice and all for its parent slices
+ and the units contained therein. The system default for this
+ setting maybe controlled with
+ <varname>DefaultBlockIOAccounting=</varname> in
+ <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
</listitem>
</varlistentry>
diff --git a/src/core/main.c b/src/core/main.c
index 4e24f85..d3581fc 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -107,6 +107,9 @@ static uint64_t arg_capability_bounding_set_drop = 0;
static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
static Set* arg_syscall_archs = NULL;
static FILE* arg_serialization = NULL;
+static bool arg_default_cpu_accounting = false;
+static bool arg_default_blockio_accounting = false;
+static bool arg_default_memory_accounting = false;
static void nop_handler(int sig) {}
@@ -673,6 +676,9 @@ static int parse_config_file(void) {
{ "Manager", "DefaultLimitNICE", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_NICE] },
{ "Manager", "DefaultLimitRTPRIO", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_RTPRIO] },
{ "Manager", "DefaultLimitRTTIME", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_RTTIME] },
+ { "Manager", "DefaultCPUAccounting", config_parse_bool, 0, &arg_default_cpu_accounting },
+ { "Manager", "DefaultBlockIOAccounting", config_parse_bool, 0, &arg_default_blockio_accounting },
+ { "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting },
{}
};
@@ -1591,6 +1597,9 @@ int main(int argc, char *argv[]) {
m->default_timeout_stop_usec = arg_default_timeout_stop_usec;
m->default_start_limit_interval = arg_default_start_limit_interval;
m->default_start_limit_burst = arg_default_start_limit_burst;
+ m->default_cpu_accounting = arg_default_cpu_accounting;
+ m->default_blockio_accounting = arg_default_blockio_accounting;
+ m->default_memory_accounting = arg_default_memory_accounting;
m->runtime_watchdog = arg_runtime_watchdog;
m->shutdown_watchdog = arg_shutdown_watchdog;
m->userspace_timestamp = userspace_timestamp;
diff --git a/src/core/manager.h b/src/core/manager.h
index 948ea98..9dee48d 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -212,12 +212,15 @@ struct Manager {
ExecOutput default_std_output, default_std_error;
- usec_t default_restart_usec, default_timeout_start_usec,
- default_timeout_stop_usec;
+ usec_t default_restart_usec, default_timeout_start_usec, default_timeout_stop_usec;
usec_t default_start_limit_interval;
unsigned default_start_limit_burst;
+ bool default_cpu_accounting;
+ bool default_memory_accounting;
+ bool default_blockio_accounting;
+
struct rlimit *rlimit[RLIMIT_NLIMITS];
/* non-zero if we are reloading or reexecuting, */
diff --git a/src/core/mount.c b/src/core/mount.c
index a0cea1e..814674a 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -141,6 +141,8 @@ static void mount_init(Unit *u) {
kill_context_init(&m->kill_context);
cgroup_context_init(&m->cgroup_context);
+ unit_cgroup_context_init_defaults(u, &m->cgroup_context);
+
if (unit_has_name(u, "-.mount")) {
/* Don't allow start/stop for root directory */
u->refuse_manual_start = true;
@@ -577,7 +579,7 @@ static int mount_add_extras(Mount *m) {
if (r < 0)
return r;
- r = unit_exec_context_defaults(u, &m->exec_context);
+ r = unit_exec_context_patch_defaults(u, &m->exec_context);
if (r < 0)
return r;
diff --git a/src/core/scope.c b/src/core/scope.c
index 16758fe..be2a637 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -54,6 +54,8 @@ static void scope_init(Unit *u) {
cgroup_context_init(&s->cgroup_context);
kill_context_init(&s->kill_context);
+ unit_cgroup_context_init_defaults(u, &s->cgroup_context);
+
UNIT(s)->ignore_on_isolate = true;
UNIT(s)->ignore_on_snapshot = true;
}
diff --git a/src/core/service.c b/src/core/service.c
index ca71788..6977774 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -147,9 +147,9 @@ static void service_init(Unit *u) {
kill_context_init(&s->kill_context);
cgroup_context_init(&s->cgroup_context);
- RATELIMIT_INIT(s->start_limit,
- u->manager->default_start_limit_interval,
- u->manager->default_start_limit_burst);
+ unit_cgroup_context_init_defaults(u, &s->cgroup_context);
+
+ RATELIMIT_INIT(s->start_limit, u->manager->default_start_limit_interval, u->manager->default_start_limit_burst);
s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID;
}
@@ -1235,7 +1235,7 @@ static int service_load(Unit *u) {
return r;
}
- r = unit_exec_context_defaults(u, &s->exec_context);
+ r = unit_exec_context_patch_defaults(u, &s->exec_context);
if (r < 0)
return r;
}
diff --git a/src/core/slice.c b/src/core/slice.c
index 1e42df2..ae9a54b 100644
--- a/src/core/slice.c
+++ b/src/core/slice.c
@@ -43,6 +43,7 @@ static void slice_init(Unit *u) {
assert(u->load_state == UNIT_STUB);
cgroup_context_init(&s->cgroup_context);
+ unit_cgroup_context_init_defaults(u, &s->cgroup_context);
}
static void slice_done(Unit *u) {
diff --git a/src/core/socket.c b/src/core/socket.c
index 0ccda2f..8e39032 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -96,6 +96,8 @@ static void socket_init(Unit *u) {
kill_context_init(&s->kill_context);
cgroup_context_init(&s->cgroup_context);
+ unit_cgroup_context_init_defaults(u, &s->cgroup_context);
+
s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
}
@@ -338,7 +340,7 @@ static int socket_add_extras(Socket *s) {
if (r < 0)
return r;
- r = unit_exec_context_defaults(u, &s->exec_context);
+ r = unit_exec_context_patch_defaults(u, &s->exec_context);
if (r < 0)
return r;
diff --git a/src/core/swap.c b/src/core/swap.c
index 24c4611..96cf38a 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -124,6 +124,8 @@ static void swap_init(Unit *u) {
kill_context_init(&s->kill_context);
cgroup_context_init(&s->cgroup_context);
+ unit_cgroup_context_init_defaults(u, &s->cgroup_context);
+
s->parameters_proc_swaps.priority = s->parameters_fragment.priority = -1;
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
@@ -352,7 +354,7 @@ static int swap_load(Unit *u) {
return r;
}
- r = unit_exec_context_defaults(u, &s->exec_context);
+ r = unit_exec_context_patch_defaults(u, &s->exec_context);
if (r < 0)
return r;
}
diff --git a/src/core/system.conf b/src/core/system.conf
index 7a2d7b4..5be158d 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -31,6 +31,9 @@
#DefaultStartLimitInterval=10s
#DefaultStartLimitBurst=5
#DefaultEnvironment=
+#DefaultCPUAccounting=no
+#DefaultBlockIOAccounting=no
+#DefaultMemoryAccounting=no
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=
diff --git a/src/core/unit.c b/src/core/unit.c
index 1bbcb39..9d54147 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2777,13 +2777,30 @@ void unit_ref_unset(UnitRef *ref) {
ref->unit = NULL;
}
-int unit_exec_context_defaults(Unit *u, ExecContext *c) {
+int unit_cgroup_context_init_defaults(Unit *u, CGroupContext *c) {
+ assert(u);
+ assert(c);
+
+ /* Copy in the manager defaults into the cgroup context,
+ * _before_ the rest of the settings have been initialized */
+
+ c->cpu_accounting = u->manager->default_cpu_accounting;
+ c->blockio_accounting = u->manager->default_blockio_accounting;
+ c->memory_accounting = u->manager->default_memory_accounting;
+
+ return 0;
+}
+
+int unit_exec_context_patch_defaults(Unit *u, ExecContext *c) {
unsigned i;
int r;
assert(u);
assert(c);
+ /* Patch in the manager defaults into the exec context,
+ * _after_ the rest of the settings have been initialized */
+
/* This only copies in the ones that need memory */
for (i = 0; i < RLIMIT_NLIMITS; i++)
if (u->manager->rlimit[i] && !c->rlimit[i]) {
diff --git a/src/core/unit.h b/src/core/unit.h
index 808929e..34afe93 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -602,7 +602,8 @@ void unit_ref_unset(UnitRef *ref);
#define UNIT_DEREF(ref) ((ref).unit)
#define UNIT_ISSET(ref) (!!(ref).unit)
-int unit_exec_context_defaults(Unit *u, ExecContext *c);
+int unit_exec_context_patch_defaults(Unit *u, ExecContext *c);
+int unit_cgroup_context_init_defaults(Unit *u, CGroupContext *c);
ExecContext *unit_get_exec_context(Unit *u) _pure_;
KillContext *unit_get_kill_context(Unit *u) _pure_;
More information about the systemd-commits
mailing list