[CRIU] [RFC 06/20] kernel: Take into account timens clock offsets in clock_nanosleep

Dmitry Safonov dima at arista.com
Wed Sep 19 23:50:23 MSK 2018


From: Andrei Vagin <avagin at gmail.com>

Wire up clock_nanosleep to timens offsets.

Signed-off-by: Andrei Vagin <avagin at openvz.org>
Signed-off-by: Dmitry Safonov <dima at arista.com>
---
 kernel/time/hrtimer.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index e1a549c9e399..4fe80c1325b2 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -51,6 +51,7 @@
 #include <linux/timer.h>
 #include <linux/freezer.h>
 #include <linux/compat.h>
+#include <linux/time_namespace.h>
 
 #include <linux/uaccess.h>
 
@@ -1730,9 +1731,16 @@ long hrtimer_nanosleep(const struct timespec64 *rqtp,
 {
 	struct restart_block *restart;
 	struct hrtimer_sleeper t;
+	struct timespec64 tp;
 	int ret = 0;
 	u64 slack;
 
+	if (!(mode & HRTIMER_MODE_REL)) {
+		tp = *rqtp;
+		rqtp = &tp;
+		timens_clock_to_host(clockid, &tp);
+	}
+
 	slack = current->timer_slack_ns;
 	if (dl_task(current) || rt_task(current))
 		slack = 0;
-- 
2.13.6



More information about the CRIU mailing list