public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: [email protected]
Cc: [email protected], Jens Axboe <[email protected]>
Subject: [PATCH 4/6] futex: add futex wait variant that takes a futex_q directly
Date: Fri,  9 Jun 2023 12:31:23 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

For async trigger of the wait, we need to be able to pass in a futex_q
that is already setup. Add that helper.

Signed-off-by: Jens Axboe <[email protected]>
---
 kernel/futex/futex.h    |  3 +++
 kernel/futex/waitwake.c | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h
index 8c12cef83d38..29bf78a1f475 100644
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -156,6 +156,9 @@ extern void __futex_unqueue(struct futex_q *q);
 extern void __futex_queue(struct futex_q *q, struct futex_hash_bucket *hb);
 extern int futex_unqueue(struct futex_q *q);
 
+extern int futex_queue_wait(struct futex_q *q, u32 __user *uaddr,
+			    unsigned int flags, u32 val);
+
 /**
  * futex_queue() - Enqueue the futex_q on the futex_hash_bucket
  * @q:	The futex_q to enqueue
diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c
index 5151c83e2db8..442dafdfa22a 100644
--- a/kernel/futex/waitwake.c
+++ b/kernel/futex/waitwake.c
@@ -706,3 +706,20 @@ static long futex_wait_restart(struct restart_block *restart)
 				restart->futex.val, tp, restart->futex.bitset);
 }
 
+int futex_queue_wait(struct futex_q *q, u32 __user *uaddr, unsigned int flags,
+		     u32 val)
+{
+	struct futex_hash_bucket *hb;
+	int ret;
+
+	if (!q->bitset)
+		return -EINVAL;
+
+	ret = futex_wait_setup(uaddr, val, flags, q, &hb);
+	if (ret)
+		return ret;
+
+	__futex_queue(q, hb);
+	spin_unlock(&hb->lock);
+	return 0;
+}
-- 
2.39.2


  parent reply	other threads:[~2023-06-09 18:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09 18:31 [PATCHSET RFC 0/6] Add io_uring support for futex wait/wake Jens Axboe
2023-06-09 18:31 ` [PATCH 1/6] futex: abstract out futex_op_to_flags() helper Jens Axboe
2023-06-09 18:31 ` [PATCH 2/6] futex: factor out the futex wake handling Jens Axboe
2023-06-09 18:31 ` [PATCH 3/6] futex: assign default futex_q->wait_data at insertion time Jens Axboe
2023-06-09 18:31 ` Jens Axboe [this message]
2023-06-09 18:31 ` [PATCH 5/6] io_uring: add support for futex wake and wait Jens Axboe
2023-06-12 16:06   ` Gabriel Krisman Bertazi
2023-06-12 20:37     ` Jens Axboe
2023-06-12 23:00       ` Gabriel Krisman Bertazi
2023-06-13  1:09         ` Jens Axboe
2023-06-13  2:55           ` io_uring link semantics (was [PATCH 5/6] io_uring: add support for futex wake and wait) Gabriel Krisman Bertazi
2023-06-23 19:04   ` [PATCH 5/6] io_uring: add support for futex wake and wait Andres Freund
2023-06-23 19:07     ` Jens Axboe
2023-06-23 19:34       ` Andres Freund
2023-06-23 19:46         ` Jens Axboe
2023-06-09 18:31 ` [PATCH 6/6] io_uring/futex: enable use of the allocation caches for futex_q 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] \
    /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