File hwclock-raiseprio.diff of Package util-linux
From: Kurt Garloff <garloff@suse.de>
Subject: Run hwclock with higher CPU priority
References: bnc441106
We have polling and busy waiting loops; decrease the chance of being
preempted in a bad moment by using a higher CPU priority.
(No error handling is intentional -- if it fails it fails.)
[Patch 1/4]
Index: util-linux-ng-2.14.1/hwclock/hwclock.c
===================================================================
--- util-linux-ng-2.14.1.orig/hwclock/hwclock.c
+++ util-linux-ng-2.14.1/hwclock/hwclock.c
@@ -80,8 +80,9 @@
#include <sys/stat.h>
#include <stdarg.h>
#include <getopt.h>
#include <sysexits.h>
+#include <sys/resource.h>
#include "clock.h"
#include "nls.h"
@@ -1253,8 +1254,15 @@ usage( const char *fmt, ... ) {
hwclock_exit(fmt ? EX_USAGE : 0);
}
+/* Raise priority to nice -15 level to increase accuracy */
+static void
+raise_priority()
+{
+ setpriority(PRIO_PROCESS, 0, PRIO_MIN*7/8+PRIO_MAX/8);
+}
+
static const struct option longopts[] = {
{ "adjust", 0, 0, 'a' },
{ "help", 0, 0, 'h' },
{ "show", 0, 0, 'r' },
@@ -1542,8 +1550,9 @@ main(int argc, char **argv) {
"of our search for an access method.\n"));
hwclock_exit(1);
}
+ raise_priority();
rc = manipulate_clock(show, adjust, noadjfile, set, set_time,
hctosys, systohc, startup_time, utc,
local_opt, testing);
hwclock_exit(rc);