[Devel] [PATCH rh8] ve/futex/timeout: adjust futex timeout to absolule
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Oct 14 13:20:00 MSK 2020
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>
---
kernel/futex.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/futex.c b/kernel/futex.c
index 5282b74fc31b..9947cb4db384 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -68,6 +68,7 @@
#include <linux/bootmem.h>
#include <linux/fault-inject.h>
#include <linux/refcount.h>
+#include <linux/ve.h>
#include <asm/futex.h>
@@ -3618,6 +3619,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;
@@ -3627,6 +3629,12 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
if (cmd != FUTEX_WAIT && cmd != FUTEX_WAIT_BITSET && \
cmd != FUTEX_WAIT_REQUEUE_PI)
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.28.0
More information about the Devel
mailing list