[Devel] [PATCH RHEL7 COMMIT] timers should not get negative argument

Vladimir Davydov vdavydov at virtuozzo.com
Mon Jun 20 09:58:56 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.16
------>
commit 3788c76811b2b04318c3f4b240f1e83245ad15e5
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Mon Jun 20 20:58:56 2016 +0400

    timers should not get negative argument
    
    This patch fixes 25-sec delay on login into systemd based containers.
    
    Userspace application can set timer for past
    and expect that the timer will be expired immediately.
    
    This can do not work as expected inside migrated containers.
    Translated argument provided to timer can become negative,
    and according timer will sleep a very long time.
    
    https://jira.sw.ru/browse/PSBM-48475
    
    CC: Vladimir Davydov <vdavydov at virtuozzo.com>
    CC: Konstantin Khorenko <khorenko at virtuozzo.com>
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
    Acked-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 kernel/posix-timers.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index b98cfe429d9b..8ebf01827ee6 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -133,6 +133,8 @@ static struct k_clock posix_clocks[MAX_CLOCKS];
 	 (which_clock) == CLOCK_MONOTONIC_COARSE)
 
 #ifdef CONFIG_VE
+static struct timespec zero_time;
+
 void monotonic_abs_to_ve(clockid_t which_clock, struct timespec *tp)
 {
 	struct ve_struct *ve = get_exec_env();
@@ -151,6 +153,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);
+	if (timespec_compare(tp, &zero_time) <= 0) {
+		tp->tv_sec =  0;
+		tp->tv_nsec = 1;
+	}
 }
 #endif
 


More information about the Devel mailing list