From bd8f585b9996667db89764ece1cacf37672e3223 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 24 Mar 2014 16:22:34 +0100 Subject: [PATCH] core: add a setting to globally control the default for timer unit accuracy --- man/systemd-system.conf.xml | 28 +++++++++++++++++++++++++--- src/core/main.c | 3 +++ src/core/manager.c | 1 + src/core/manager.h | 2 ++ src/core/system.conf | 1 + src/core/timer.c | 2 +- src/core/user.conf | 1 + 7 files changed, 34 insertions(+), 4 deletions(-) diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml index a7dfc0329..e2b2bd8b6 100644 --- a/man/systemd-system.conf.xml +++ b/man/systemd-system.conf.xml @@ -259,8 +259,8 @@ TimerSlackNSec= Sets the timer slack - in nanoseconds for PID 1 which is then - inherited to all executed processes, + in nanoseconds for PID 1, which is + inherited by all executed processes, unless overridden individually, for example with the TimerSlackNSec= @@ -268,7 +268,8 @@ see systemd.exec5). The timer slack controls the accuracy of - wake-ups triggered by timers. See + wake-ups triggered by system + timers. See prctl2 for more information. Note that in contrast to most other time span @@ -279,6 +280,27 @@ too. + + DefaultTimerAccuracySec= + + Sets the default + accuracy of timer units. This controls + the global default for the + AccuracySec= + setting of timer units, see + systemd.timer5 + for + details. AccuracySec= + set in individual units override the + global default for the specific + unit. Defaults to 1min. Note that the + accuracy of timer units is also + affected by the configured timer slack + for PID 1, see + TimerSlackNSec= + above. + + DefaultTimeoutStartSec= DefaultTimeoutStopSec= diff --git a/src/core/main.c b/src/core/main.c index e0fbb6e14..41605ee8d 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -108,6 +108,7 @@ static char **arg_default_environment = NULL; static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {}; static uint64_t arg_capability_bounding_set_drop = 0; static nsec_t arg_timer_slack_nsec = (nsec_t) -1; +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; @@ -686,6 +687,7 @@ static int parse_config_file(void) { { "Manager", "SystemCallArchitectures", config_parse_syscall_archs, 0, &arg_syscall_archs }, #endif { "Manager", "TimerSlackNSec", config_parse_nsec, 0, &arg_timer_slack_nsec }, + { "Manager", "DefaultTimerAccuracySec", config_parse_sec, 0, &arg_default_timer_accuracy_usec }, { "Manager", "DefaultStandardOutput", config_parse_output, 0, &arg_default_std_output }, { "Manager", "DefaultStandardError", config_parse_output, 0, &arg_default_std_error }, { "Manager", "DefaultTimeoutStartSec", config_parse_sec, 0, &arg_default_timeout_start_usec }, @@ -1635,6 +1637,7 @@ int main(int argc, char *argv[]) { } m->confirm_spawn = arg_confirm_spawn; + m->default_timer_accuracy_usec = arg_default_timer_accuracy_usec; m->default_std_output = arg_default_std_output; m->default_std_error = arg_default_std_error; m->default_restart_usec = arg_default_restart_usec; diff --git a/src/core/manager.c b/src/core/manager.c index a3ff85c86..224106c66 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -428,6 +428,7 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) { m->running_as = running_as; m->exit_code = _MANAGER_EXIT_CODE_INVALID; + m->default_timer_accuracy_usec = USEC_PER_MINUTE; m->idle_pipe[0] = m->idle_pipe[1] = m->idle_pipe[2] = m->idle_pipe[3] = -1; diff --git a/src/core/manager.h b/src/core/manager.h index 38f1c89c9..14cdf8151 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -241,6 +241,8 @@ struct Manager { bool default_memory_accounting; bool default_blockio_accounting; + usec_t default_timer_accuracy_usec; + struct rlimit *rlimit[_RLIMIT_MAX]; /* non-zero if we are reloading or reexecuting, */ diff --git a/src/core/system.conf b/src/core/system.conf index 5be158d9f..65a35a068 100644 --- a/src/core/system.conf +++ b/src/core/system.conf @@ -23,6 +23,7 @@ #CapabilityBoundingSet= #SystemCallArchitectures= #TimerSlackNSec= +#DefaultTimerAccuracySec=1min #DefaultStandardOutput=journal #DefaultStandardError=inherit #DefaultTimeoutStartSec=90s diff --git a/src/core/timer.c b/src/core/timer.c index 62baf5785..6c853044a 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -48,7 +48,7 @@ static void timer_init(Unit *u) { t->next_elapse_monotonic_or_boottime = (usec_t) -1; t->next_elapse_realtime = (usec_t) -1; - t->accuracy_usec = USEC_PER_MINUTE; + t->accuracy_usec = u->manager->default_timer_accuracy_usec; } void timer_free_values(Timer *t) { diff --git a/src/core/user.conf b/src/core/user.conf index f19ac7528..8c7ecde72 100644 --- a/src/core/user.conf +++ b/src/core/user.conf @@ -14,6 +14,7 @@ #LogLocation=no #SystemCallArchitectures= #TimerSlackNSec= +#DefaultTimerAccuracySec=1min #DefaultStandardOutput=inherit #DefaultStandardError=inherit #DefaultTimeoutStartSec=90s -- 2.30.2