summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-05-31 04:36:08 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-31 04:36:08 +0200
commitaa0f64ac851ebf27342d66947b5170bfeb9f49ae (patch)
treec57b895246b50ad6c2d155de503a43f2b859aa86
parentd88a251b125f6e9178b9ca9ea47ab7da3234cb58 (diff)
main: allow setting of timer slack for PID 1
-rw-r--r--man/systemd.conf.xml24
-rw-r--r--src/core/main.c6
-rw-r--r--src/core/system.conf1
3 files changed, 31 insertions, 0 deletions
diff --git a/man/systemd.conf.xml b/man/systemd.conf.xml
index 2659f9ab7b..92942f1a93 100644
--- a/man/systemd.conf.xml
+++ b/man/systemd.conf.xml
@@ -216,6 +216,30 @@
</varlistentry>
<varlistentry>
+ <term><varname>TimerSlackNSec=</varname></term>
+
+ <listitem><para>Sets the timer slack
+ in nanoseconds for PID 1 which is then
+ inherited to all executed processes,
+ unless overriden individually, for
+ example with the
+ <varname>TimerSlackNSec=</varname>
+ setting in service units (for details
+ see
+ <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>). The
+ timer slack controls the accuracy of
+ wake-ups triggered by timers. See
+ <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
+ for more information. Note that in
+ contrast to most other time span
+ definitions this parameter takes an
+ integer value in nano-seconds if no
+ unit is specified. The usual time
+ units are understood
+ too.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>DefaultLimitCPU=</varname></term>
<term><varname>DefaultLimitFSIZE=</varname></term>
<term><varname>DefaultLimitDATA=</varname></term>
diff --git a/src/core/main.c b/src/core/main.c
index 4c3ee7d5a2..5cd012e957 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -90,6 +90,7 @@ static usec_t arg_runtime_watchdog = 0;
static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
static struct rlimit *arg_default_rlimit[RLIMIT_NLIMITS] = {};
static uint64_t arg_capability_bounding_set_drop = 0;
+static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
static FILE* serialization = NULL;
@@ -681,6 +682,7 @@ static int parse_config_file(void) {
{ "Manager", "RuntimeWatchdogSec", config_parse_usec, 0, &arg_runtime_watchdog },
{ "Manager", "ShutdownWatchdogSec", config_parse_usec, 0, &arg_shutdown_watchdog },
{ "Manager", "CapabilityBoundingSet", config_parse_bounding_set, 0, &arg_capability_bounding_set_drop },
+ { "Manager", "TimerSlackNSec", config_parse_nsec, 0, &arg_timer_slack_nsec },
{ "Manager", "DefaultLimitCPU", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_CPU]},
{ "Manager", "DefaultLimitFSIZE", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_FSIZE]},
{ "Manager", "DefaultLimitDATA", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_DATA]},
@@ -1487,6 +1489,10 @@ int main(int argc, char *argv[]) {
if (arg_running_as == MANAGER_SYSTEM && arg_runtime_watchdog > 0)
watchdog_set_timeout(&arg_runtime_watchdog);
+ if (arg_timer_slack_nsec != (nsec_t) -1)
+ if (prctl(PR_SET_TIMERSLACK, arg_timer_slack_nsec) < 0)
+ log_error("Failed to adjust timer slack: %m");
+
if (arg_capability_bounding_set_drop) {
r = capability_bounding_set_drop(arg_capability_bounding_set_drop, true);
if (r < 0) {
diff --git a/src/core/system.conf b/src/core/system.conf
index 7b9171b803..c6ba95c212 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -25,6 +25,7 @@
#RuntimeWatchdogSec=0
#ShutdownWatchdogSec=10min
#CapabilityBoundingSet=
+#TimerSlackNSec=
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=