From: Suleiman Souhlal <suleiman@google.com>
To: linux-kernel@vger.kernel.org
Cc: "Suleiman Souhlal" <suleiman@google.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"K Prateek Nayak" <kprateek.nayak@amd.com>,
"zhidao su" <soolaugust@gmail.com>,
"John Stultz" <jstultz@google.com>,
"Qais Yousef" <qyousef@google.com>,
ssouhlal@FreeBSD.org
Subject: [RFC PATCH 07/12] futex: Make FUTEX_*_PING use Proxy Execution.
Date: Thu, 17 Sep 2026 04:33:31 +0000 [thread overview]
Message-ID: <20260917043339.2093426-8-suleiman@google.com> (raw)
In-Reply-To: <20260917043339.2093426-1-suleiman@google.com>
Set the locker side proxy execution bits, so that a task blocked on
a PING futex can act as a donor.
Signed-off-by: Suleiman Souhlal <suleiman@google.com>
---
include/linux/futex.h | 11 +++++++++++
include/linux/sched.h | 12 ++++++++++++
kernel/futex/ping.c | 7 +++++++
kernel/sched/core.c | 7 +++++++
4 files changed, 37 insertions(+)
diff --git a/include/linux/futex.h b/include/linux/futex.h
index b1b422b480fb..84eca792e44a 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -170,4 +170,15 @@ static inline struct task_struct *ping_mutex_owner(struct ping_mutex *ping_mutex
return READ_ONCE(ping_mutex->owner);
}
+static inline void ping_mutex_lock_wait_lock(struct ping_mutex *ping_mutex)
+{
+ lockdep_assert_irqs_disabled();
+ raw_spin_lock(&ping_mutex->wait_lock);
+}
+
+static inline void ping_mutex_unlock_wait_lock(struct ping_mutex *ping_mutex)
+{
+ raw_spin_unlock(&ping_mutex->wait_lock);
+}
+
#endif /* _LINUX_FUTEX_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index a7de5c496e3c..200f41c38333 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -835,6 +835,7 @@ struct task_ipi_mask { };
enum blocked_on_type {
BO_T_NONE,
BO_T_MUTEX,
+ BO_T_PING_FUTEX,
};
struct blocked_on_lock {
@@ -2257,6 +2258,13 @@ static inline void __set_task_blocked_on(struct task_struct *p, void *m,
p->blocked_on.type = type;
}
+static inline void set_task_blocked_on(struct task_struct *p, void *m,
+ enum blocked_on_type type)
+{
+ guard(raw_spinlock_irqsave)(&p->blocked_lock);
+ __set_task_blocked_on(p, m, type);
+}
+
static inline void __clear_task_blocked_on(struct task_struct *p, void *m)
{
/* Currently we serialize blocked_on under the task::blocked_lock */
@@ -2278,6 +2286,10 @@ static inline void clear_task_blocked_on(struct task_struct *p, void *m)
}
#else
+static inline void set_task_blocked_on(struct task_struct *p, void *m,
+ enum blocked_on_type type)
+{
+}
static inline void __clear_task_blocked_on(struct task_struct *p, void *m)
{
}
diff --git a/kernel/futex/ping.c b/kernel/futex/ping.c
index ebcd3c4a7793..689f149f7150 100644
--- a/kernel/futex/ping.c
+++ b/kernel/futex/ping.c
@@ -370,6 +370,9 @@ int futex_lock_ping(u32 __user *uaddr, unsigned int flags, ktime_t *time,
queued = false;
while (1) {
+ set_task_blocked_on(current, &q.ping_state->ping_mutex,
+ BO_T_PING_FUTEX);
+
set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE);
if (!queued) {
futex_queue(&q, hb, current);
@@ -382,6 +385,9 @@ int futex_lock_ping(u32 __user *uaddr, unsigned int flags, ktime_t *time,
futex_do_wait(&q, to);
+ clear_task_blocked_on(current,
+ &q.ping_state->ping_mutex);
+
futex_q_lockptr_lock(&q);
if (to && !to->task) {
ret = -ETIMEDOUT;
@@ -511,6 +517,7 @@ int futex_unlock_ping(u32 __user *uaddr, unsigned int flags)
/* Leave it queued, it gets unqueued on the lock side */
get_task_struct(top_waiter->task);
wake_q_add_safe(&wake_q, top_waiter->task);
+ clear_task_blocked_on(top_waiter->task, &ping_state->ping_mutex);
spin_unlock(&hb->lock);
/*
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2e8fe4b9bb88..1d35b1d90ea2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -68,6 +68,7 @@
#include <linux/wait_api.h>
#include <linux/workqueue_api.h>
#include <linux/livepatch_sched.h>
+#include <linux/futex.h>
#ifdef CONFIG_PREEMPT_DYNAMIC
# ifdef CONFIG_GENERIC_IRQ_ENTRY
@@ -158,6 +159,8 @@ static inline struct task_struct *__blocked_on_owner(struct blocked_on_lock *bo)
return NULL;
case BO_T_MUTEX:
return __mutex_owner(bo->lock);
+ case BO_T_PING_FUTEX:
+ return ping_mutex_owner(bo->lock);
default:
WARN_ON_ONCE(1);
return NULL;
@@ -6907,6 +6910,8 @@ lock_blocked_on_lock(struct blocked_on_lock *bo)
{
if (bo->type == BO_T_MUTEX)
raw_spin_lock(&((struct mutex *)bo->lock)->wait_lock);
+ else if (bo->type == BO_T_PING_FUTEX)
+ ping_mutex_lock_wait_lock(bo->lock);
else
WARN_ON_ONCE(1);
}
@@ -6916,6 +6921,8 @@ unlock_blocked_on_lock(struct blocked_on_lock *bo)
{
if (bo->type == BO_T_MUTEX)
raw_spin_unlock(&((struct mutex *)bo->lock)->wait_lock);
+ else if (bo->type == BO_T_PING_FUTEX)
+ ping_mutex_unlock_wait_lock(bo->lock);
else
WARN_ON_ONCE(1);
}
--
2.55.0.1082.g2b9226bbc0-goog
next prev parent reply other threads:[~2026-09-17 4:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 4:33 [RFC PATCH 00/12] FUTEX_PING: A stealable futex using Proxy Execution Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 01/12] sched: Abstract task_struct->blocked_on by locking primitive Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 02/12] futex: Switch PI futex to use p->pi_futex_lock instead of p->pi_lock Suleiman Souhlal
2026-09-17 15:38 ` Peter Zijlstra
2026-09-18 7:11 ` Suleiman Souhlal
2026-09-18 10:07 ` K Prateek Nayak
2026-10-16 5:59 ` Suleiman Souhlal
2026-10-16 8:15 ` K Prateek Nayak
2026-10-19 6:16 ` Suleiman Souhlal
2026-09-18 12:06 ` Peter Zijlstra
2026-09-17 4:33 ` [RFC PATCH 03/12] futex: Add "ping" parameter to pi_state management functions and export them Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 04/12] futex: Introduce stealable PI futex, FUTEX_*_PING Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 05/12] futex: Implement exit_ping_state_list() Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 06/12] futex: Address aborting from futex_lock_ping() while owning ping_state Suleiman Souhlal
2026-09-17 4:33 ` Suleiman Souhlal [this message]
2026-09-17 13:18 ` [RFC PATCH 07/12] futex: Make FUTEX_*_PING use Proxy Execution Jihan LIN
2026-09-17 14:39 ` K Prateek Nayak
2026-09-17 15:36 ` Peter Zijlstra
2026-09-21 4:51 ` K Prateek Nayak
2026-09-23 14:04 ` Jihan LIN
2026-09-17 4:33 ` [RFC PATCH 08/12] futex: Implement PING futex handoff Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 09/12] futex: Wake up donor in PING futex unlock Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 10/12] futex: Optimistic spinning for PING futexes Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 11/12] futex: Allow userspace stealing " Suleiman Souhlal
2026-09-17 4:33 ` [RFC PATCH 12/12] tools/testing/futex: Add ping_bench, a tool for benchmarking futexes Suleiman Souhlal
2026-09-17 8:58 ` [RFC PATCH 00/12] FUTEX_PING: A stealable futex using Proxy Execution Peter Zijlstra
2026-09-17 17:53 ` John Stultz
2026-09-17 18:51 ` Steven Rostedt
2026-09-18 6:30 ` Suleiman Souhlal
2026-09-18 8:25 ` Peter Zijlstra
2026-09-18 6:07 ` Suleiman Souhlal
2026-09-18 8:07 ` Peter Zijlstra
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=20260917043339.2093426-8-suleiman@google.com \
--to=suleiman@google.com \
--cc=andrealmeid@igalia.com \
--cc=bsegall@google.com \
--cc=dave@stgolabs.net \
--cc=dietmar.eggemann@arm.com \
--cc=dvhart@infradead.org \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=qyousef@google.com \
--cc=rostedt@goodmis.org \
--cc=soolaugust@gmail.com \
--cc=ssouhlal@FreeBSD.org \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.