[Devel] [PATCH vz9 11/23] ve/futex/timeout: adjust futex timeout to absolule

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Fri Oct 1 18:53:19 MSK 2021


From: Kirill Tkhai <ktkhai at parallels.com>

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) {
-- 
2.30.2



More information about the Devel mailing list