From: Jens Axboe <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], [email protected], Jens Axboe <[email protected]>
Subject: [PATCH 01/10] futex: Clarify FUTEX2 flags
Date: Thu, 20 Jul 2023 16:18:49 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
From: Peter Zijlstra <[email protected]>
sys_futex_waitv() is part of the futex2 series (the first and only so
far) of syscalls and has a flags field per futex (as opposed to flags
being encoded in the futex op).
This new flags field has a new namespace, which unfortunately isn't
super explicit. Notably it currently takes FUTEX_32 and
FUTEX_PRIVATE_FLAG.
Introduce the FUTEX2 namespace to clarify this
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
include/uapi/linux/futex.h | 16 +++++++++++++---
kernel/futex/syscalls.c | 7 +++----
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h
index 71a5df8d2689..0c5abb6aa8f8 100644
--- a/include/uapi/linux/futex.h
+++ b/include/uapi/linux/futex.h
@@ -44,10 +44,20 @@
FUTEX_PRIVATE_FLAG)
/*
- * Flags to specify the bit length of the futex word for futex2 syscalls.
- * Currently, only 32 is supported.
+ * Flags for futex2 syscalls.
*/
-#define FUTEX_32 2
+ /* 0x00 */
+ /* 0x01 */
+#define FUTEX2_32 0x02
+ /* 0x04 */
+ /* 0x08 */
+ /* 0x10 */
+ /* 0x20 */
+ /* 0x40 */
+#define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG
+
+/* do not use */
+#define FUTEX_32 FUTEX2_32 /* historical accident :-( */
/*
* Max numbers of elements in a futex_waitv array
diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c
index a8074079b09e..42b6c2fac7db 100644
--- a/kernel/futex/syscalls.c
+++ b/kernel/futex/syscalls.c
@@ -183,8 +183,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3);
}
-/* Mask of available flags for each futex in futex_waitv list */
-#define FUTEXV_WAITER_MASK (FUTEX_32 | FUTEX_PRIVATE_FLAG)
+#define FUTEX2_MASK (FUTEX2_32 | FUTEX2_PRIVATE)
/**
* futex_parse_waitv - Parse a waitv array from userspace
@@ -205,10 +204,10 @@ static int futex_parse_waitv(struct futex_vector *futexv,
if (copy_from_user(&aux, &uwaitv[i], sizeof(aux)))
return -EFAULT;
- if ((aux.flags & ~FUTEXV_WAITER_MASK) || aux.__reserved)
+ if ((aux.flags & ~FUTEX2_MASK) || aux.__reserved)
return -EINVAL;
- if (!(aux.flags & FUTEX_32))
+ if (!(aux.flags & FUTEX2_32))
return -EINVAL;
futexv[i].w.flags = aux.flags;
--
2.40.1
next prev parent reply other threads:[~2023-07-20 22:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 22:18 [PATCHSET v3 0/10] Add io_uring futex/futexv support Jens Axboe
2023-07-20 22:18 ` Jens Axboe [this message]
2023-07-20 22:18 ` [PATCH 02/10] futex: Extend the FUTEX2 flags Jens Axboe
2023-07-20 22:18 ` [PATCH 03/10] futex: Flag conversion Jens Axboe
2023-07-20 22:18 ` [PATCH 04/10] futex: factor out the futex wake handling Jens Axboe
2023-07-20 22:18 ` [PATCH 05/10] futex: abstract out a __futex_wake_mark() helper Jens Axboe
2023-07-20 22:18 ` [PATCH 06/10] io_uring: add support for futex wake and wait Jens Axboe
2023-07-21 11:30 ` Peter Zijlstra
2023-07-21 11:37 ` Peter Zijlstra
2023-07-21 14:43 ` Jens Axboe
2023-07-21 15:29 ` Jens Axboe
2023-07-25 13:00 ` Peter Zijlstra
2023-07-25 13:48 ` Jens Axboe
2023-07-25 13:57 ` Jens Axboe
2023-07-25 15:19 ` Peter Zijlstra
2023-07-25 20:42 ` Jens Axboe
2023-07-25 21:24 ` Jens Axboe
2023-07-25 14:06 ` Peter Zijlstra
2023-07-20 22:18 ` [PATCH 07/10] futex: add wake_data to struct futex_q Jens Axboe
2023-07-20 22:18 ` [PATCH 08/10] futex: make futex_parse_waitv() available as a helper Jens Axboe
2023-07-20 22:18 ` [PATCH 09/10] futex: make the vectored futex operations available Jens Axboe
2023-07-20 22:18 ` [PATCH 10/10] io_uring: add support for vectored futex waits Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox