[Devel] [PATCH RHEL COMMIT] ve/futex/timeout: adjust futex timeout to absolule

Konstantin Khorenko khorenko at virtuozzo.com
Fri Oct 1 19:38:41 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 8502314d69fef6b8da2d790c0894cf01e66cb865
Author: Kirill Tkhai <ktkhai at parallels.com>
Date:   Fri Oct 1 19:38:41 2021 +0300

    ve/futex/timeout: adjust futex timeout to absolule
    
    This converts ve-absolute-monotonic time to global-absolute-monotonic time.
    
    https://jira.sw.ru/browse/PSBM-14471
    
    diff-futex-reference-ct-monotonic-clock-from-ct-start
    
    Signed-off-by: Konstantin Khlebnikov <khlebnikov at openvz.org>
    
    Signed-off-by: Kirill Tkhai <ktkhai at parallels.com>
    
    (cherry picked from vz7 commit 14a4db52ee8c862eb7a9dec740b15c646e0b59aa)
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    
    (cherry-picked from vz8 commit 9b7182b8c953 ("ve/futex/timeout: adjust
    futex timeout to absolule"))
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 kernel/futex.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/futex.c b/kernel/futex.c
index 2ecb07575055..1c2e9aa57bbe 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -39,6 +39,7 @@
 #include <linux/memblock.h>
 #include <linux/fault-inject.h>
 #include <linux/time_namespace.h>
+#include <linux/ve.h>
 
 #include <asm/futex.h>
 
@@ -3700,6 +3701,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
 {
 	int cmd = op & FUTEX_CMD_MASK;
 	unsigned int flags = 0;
+	ktime_t abs_time;
 
 	if (!(op & FUTEX_PRIVATE_FLAG))
 		flags |= FLAGS_SHARED;
@@ -3709,6 +3711,12 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
 		if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI &&
 		    cmd != FUTEX_LOCK_PI2)
 			return -ENOSYS;
+	} else if (timeout) {
+		if (cmd == FUTEX_WAIT_BITSET || cmd == FUTEX_WAIT_REQUEUE_PI) {
+			abs_time = ktime_add(*timeout, ns_to_ktime(
+					     get_exec_env()->start_time));
+			timeout = &abs_time;
+		}
 	}
 
 	switch (cmd) {


More information about the Devel mailing list