[RHEL8,COMMIT] ve/futex/timeout: adjust futex timeout to absolule

Submitted by Konstantin Khorenko on Oct. 14, 2020, 12:52 p.m.

Details

Message ID 202010141252.09ECqlt71529038@finist-co8.sw.ru
State New
Series "ve/futex/timeout: adjust futex timeout to absolule"
Headers show

Commit Message

Konstantin Khorenko Oct. 14, 2020, 12:52 p.m.
The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.12
------>
commit 1bc875e8a7d673ed9c10e48cd4f0fd6956dc5769
Author: Kirill Tkhai <ktkhai@parallels.com>
Date:   Wed Aug 6 15:37:15 2014 +0400

    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@openvz.org>
    Signed-off-by: Kirill Tkhai <ktkhai@parallels.com>
    
    (cherry picked from vz7 commit 14a4db52ee8c862eb7a9dec740b15c646e0b59aa)
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 kernel/futex.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch hide | download patch | download mbox

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