mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: "André Almeida" <andrealmeid@igalia.com>,
	"Darren Hart" <dvhart@infradead.org>,
	"Davidlohr Bueso" <dave@stgolabs.net>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Valentin Schneider" <vschneid@redhat.com>,
	"Waiman Long" <longman@redhat.com>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Subject: [PATCH v9 01/11] futex: fixup futex_wait_setup [fold futex: Move futex_queue() into futex_wait_setup()]
Date: Tue, 25 Feb 2025 18:09:04 +0100	[thread overview]
Message-ID: <20250225170914.289358-2-bigeasy@linutronix.de> (raw)
In-Reply-To: <20250225170914.289358-1-bigeasy@linutronix.de>

we could also make @task a bool signaling it is either NULL or current.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/futex/waitwake.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c
index 7655de59ab3d6..44034dee7a48c 100644
--- a/kernel/futex/waitwake.c
+++ b/kernel/futex/waitwake.c
@@ -571,7 +571,8 @@ int futex_wait_multiple(struct futex_vector *vs, unsigned int count,
  * @val:	the expected value
  * @flags:	futex flags (FLAGS_SHARED, etc.)
  * @q:		the associated futex_q
- * @hb:		storage for hash_bucket pointer to be returned to caller
+ * @key2:	the second futex_key if used for requeue PI
+ * task:	Task queueing this futex
  *
  * Setup the futex_q and locate the hash_bucket.  Get the futex value and
  * compare it with the expected value.  Handle atomic faults internally.
@@ -634,7 +635,7 @@ int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
 
 		if (uval != val) {
 			futex_q_unlock(hb);
-			ret = -EWOULDBLOCK;
+			return -EWOULDBLOCK;
 		}
 
 		if (key2 && futex_match(&q->key, key2)) {
@@ -648,8 +649,9 @@ int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
 		 * futex_queue() calls spin_unlock() upon completion, both serializing
 		 * access to the hash list and forcing another memory barrier.
 		 */
-		set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE);
-		futex_queue(q, hb, current);
+		if (task == current)
+			set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE);
+		futex_queue(q, hb, task);
 	}
 
 	return ret;
-- 
2.47.2


  reply	other threads:[~2025-02-25 17:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 17:09 [PATCH v9 00/11] futex: Add support task local hash maps Sebastian Andrzej Siewior
2025-02-25 17:09 ` Sebastian Andrzej Siewior [this message]
2025-02-26  8:15   ` [PATCH v9 01/11] futex: fixup futex_wait_setup [fold futex: Move futex_queue() into futex_wait_setup()] Thomas Gleixner
2025-02-26  8:40     ` Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 02/11] futex: Create helper function to initialize a hash slot Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 03/11] futex: Add basic infrastructure for local task local hash Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 04/11] futex: Hash only the address for private futexes Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 05/11] futex: Allow automatic allocation of process wide futex hash Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 06/11] futex: Decrease the waiter count before the unlock operation Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 07/11] futex: Introduce futex_q_lockptr_lock() Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 08/11] futex: Acquire a hash reference in futex_wait_multiple_setup() Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 09/11] futex: Allow to re-allocate the private local hash Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 10/11] futex: Resize local futex hash table based on number of threads Sebastian Andrzej Siewior
2025-02-25 17:09 ` [PATCH v9 11/11] futex: Use a hashmask instead of hashsize Sebastian Andrzej Siewior
2025-02-26  8:17   ` Thomas Gleixner
2025-03-03 10:54 ` [PATCH v9 00/11] futex: Add support task local hash maps Peter Zijlstra
2025-03-03 14:17   ` Sebastian Andrzej Siewior
2025-03-03 16:40     ` Sebastian Andrzej Siewior
2025-03-04 14:58       ` Sebastian Andrzej Siewior
2025-03-05  9:02         ` Sebastian Andrzej Siewior
2025-03-10 16:01           ` Peter Zijlstra
2025-03-10 16:27             ` Sebastian Andrzej Siewior
2025-03-11 10:17               ` Peter Zijlstra
2025-03-11 10:33                 ` Sebastian Andrzej Siewior
2025-03-10 15:57         ` Peter Zijlstra
2025-03-11 15:20   ` Sebastian Andrzej Siewior

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 \
    --in-reply-to=20250225170914.289358-2-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=andrealmeid@igalia.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vschneid@redhat.com \
    /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

all inboxes | Powered by JetHome®