[Devel] [PATCH vz7] ve/posix_timers: adjust CLOCK_BOOTTIME for CT

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Thu Dec 2 20:32:19 MSK 2021


CLOCK_BOOTTIME operations must be adjusted similar to CLOCK_MONOTONIC
operations, to work with CT boot time, not host boot time.

https://jira.sw.ru/browse/PSBM-136131
https://bugs.openvz.org/browse/OVZ-7298
Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 kernel/posix-timers.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index f565fe0e6503..127102cf2d0b 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -146,6 +146,10 @@ void monotonic_abs_to_ve(clockid_t which_clock, struct timespec *tp)
 		set_normalized_timespec(tp,
 				tp->tv_sec - ve->start_timespec.tv_sec,
 				tp->tv_nsec - ve->start_timespec.tv_nsec);
+	else if (which_clock == CLOCK_BOOTTIME)
+		set_normalized_timespec(tp,
+				tp->tv_sec - ve->real_start_timespec.tv_sec,
+				tp->tv_nsec - ve->real_start_timespec.tv_nsec);
 }
 
 void monotonic_ve_to_abs(clockid_t which_clock, struct timespec *tp)
@@ -156,6 +160,10 @@ void monotonic_ve_to_abs(clockid_t which_clock, struct timespec *tp)
 		set_normalized_timespec(tp,
 				tp->tv_sec + ve->start_timespec.tv_sec,
 				tp->tv_nsec + ve->start_timespec.tv_nsec);
+	else if (which_clock == CLOCK_BOOTTIME)
+		set_normalized_timespec(tp,
+				tp->tv_sec + ve->real_start_timespec.tv_sec,
+				tp->tv_nsec + ve->real_start_timespec.tv_nsec);
 	if (timespec_compare(tp, &zero_time) <= 0) {
 		tp->tv_sec =  0;
 		tp->tv_nsec = 1;
-- 
2.30.2



More information about the Devel mailing list