chiark / gitweb /
core: add a setting to globally control the default for timer unit accuracy
authorLennart Poettering <lennart@poettering.net>
Mon, 24 Mar 2014 15:22:34 +0000 (16:22 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 24 Mar 2014 15:24:07 +0000 (16:24 +0100)
man/systemd-system.conf.xml
src/core/main.c
src/core/manager.c
src/core/manager.h
src/core/system.conf
src/core/timer.c
src/core/user.conf

index a7dfc0329c6891e62875cf56521d9eb315a39924..e2b2bd8b6f75846c01e405d5bb5aff330efbe3d0 100644 (file)
                                 <term><varname>TimerSlackNSec=</varname></term>
 
                                 <listitem><para>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
                                 <varname>TimerSlackNSec=</varname>
                                 see
                                 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>). The
                                 timer slack controls the accuracy of
-                                wake-ups triggered by timers. See
+                                wake-ups triggered by system
+                                timers. See
                                 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
                                 for more information. Note that in
                                 contrast to most other time span
                                 too.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><varname>DefaultTimerAccuracySec=</varname></term>
+
+                                <listitem><para>Sets the default
+                                accuracy of timer units. This controls
+                                the global default for the
+                                <varname>AccuracySec=</varname>
+                                setting of timer units, see
+                                <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+                                for
+                                details. <varname>AccuracySec=</varname>
+                                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
+                                <varname>TimerSlackNSec=</varname>
+                                above.</para></listitem>
+                        </varlistentry>
+
                         <varlistentry>
                                 <term><varname>DefaultTimeoutStartSec=</varname></term>
                                 <term><varname>DefaultTimeoutStopSec=</varname></term>
index e0fbb6e147b851f9d56d86be3715eb3088764e84..41605ee8d5cd37aee787a9116ef76bef2b9e0582 100644 (file)
@@ -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;
index a3ff85c86e3237da1a90a0dbf4b36209b257a9cb..224106c660796edc62cbc91a4dbf6b2ca606dd8e 100644 (file)
@@ -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;
 
index 38f1c89c930c6889701b20e3352acb20fcbd1949..14cdf81512878c6cdafdbd3040796ef58d7a8c70 100644 (file)
@@ -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, */
index 5be158d9f5b6b8c639dd2cf83734d482d6c94704..65a35a06896db476af1dcf25d04092271b74709e 100644 (file)
@@ -23,6 +23,7 @@
 #CapabilityBoundingSet=
 #SystemCallArchitectures=
 #TimerSlackNSec=
+#DefaultTimerAccuracySec=1min
 #DefaultStandardOutput=journal
 #DefaultStandardError=inherit
 #DefaultTimeoutStartSec=90s
index 62baf5785d3eef2ea786ad822b0f7f47603fa87b..6c853044a17fb5c733fc71b2394cc794520c4aed 100644 (file)
@@ -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) {
index f19ac75286e09c1e6a8381cb1f638dc1b8115bfb..8c7ecde727a622cca2a026702355978181c86d2a 100644 (file)
@@ -14,6 +14,7 @@
 #LogLocation=no
 #SystemCallArchitectures=
 #TimerSlackNSec=
+#DefaultTimerAccuracySec=1min
 #DefaultStandardOutput=inherit
 #DefaultStandardError=inherit
 #DefaultTimeoutStartSec=90s