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

Vasily Averin vvs at virtuozzo.com
Thu Dec 30 16:58:55 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.42.2.vz7.184.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.42.2.vz7.184.7
------>
commit 0147918f0ec3763682c024e6787fb3728a8c6def
Author: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Date:   Thu Dec 30 16:58:55 2021 +0300

    ve/posix_timers: adjust CLOCK_BOOTTIME for CT
    
    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 f565fe0..127102c 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;


More information about the Devel mailing list