From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: "André Almeida" <andrealmeid@igalia.com>
Cc: linux-kernel@vger.kernel.org, Carlos O'Donell <carlos@redhat.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Florian Weimer <fweimer@redhat.com>,
Rich Felker <dalias@aerifal.cx>,
Torvald Riegel <triegel@redhat.com>,
Darren Hart <dvhart@infradead.org>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Arnd Bergmann <arnd@arndb.de>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>
Subject: Re: [RFC PATCH] futex: Introduce __vdso_robust_futex_unlock
Date: Thu, 12 Mar 2026 10:04:59 -0400 [thread overview]
Message-ID: <c2eec0c1-1509-4c32-92c0-2f256543a83e@efficios.com> (raw)
In-Reply-To: <2993f778-c4f4-4aa8-8e42-1dca4d5e29e1@igalia.com>
On 2026-03-12 09:46, André Almeida wrote:
> Hi Mathieu,
>
> Thanks for your patch!
>
> Em 11/03/2026 15:54, Mathieu Desnoyers escreveu:
>> This vDSO unlocks the robust futex by exchanging the content of
>> *uaddr with 0 with a store-release semantic. If the futex has
>> waiters, it sets bit 1 of *op_pending_addr, else it clears
>> *op_pending_addr. Those operations are within a code region
>> known by the kernel, making them safe with respect to asynchronous
>> program termination either from thread context or from a nested
>> signal handler.
>>
>> Expected use of this vDSO:
>>
>> if ((__vdso_robust_futex_unlock((u32 *) &mutex->__data.__lock, &pd-
>> >robust_head.list_op_pending)
>> & FUTEX_WAITERS) != 0)
>> futex_wake((u32 *) &mutex->__data.__lock, 1, private);
>> WRITE_ONCE(pd->robust_head.list_op_pending, 0);
>>
>
> [...]
>
>> +
>> +u32 __vdso_robust_futex_unlock(u32 *uaddr, uintptr_t *op_pending_addr)
>> +{
>
> The interface that I would propose here would be a bit more "generic" or
> "flexible":
>
> __vdso_robust_futex_unlock(void *uaddr, int uval, struct
> robust_list_head *head, unsigned int flags)
I agree on adding explicit "uval" and pointer to robust list head,
I'm not convinced that the rest is an improvement.
This would require the caller to deal with errors, making it
more complex than a simple replacement for atomic xchg/cmpxchg.
"flags" could be unsupported, so the handler would have to deal with
-EINVAL.
The "size" could be unsupported (e.g. 64-bit on a 32-bit arch), which
would also require the caller to deal with -EINVAL.
> First because we have FUTEX2_SIZE's, so uaddr could have different size
> here.
Even in your proposal, "int uval" would be limited to 32-bit and would
not cover the 64-bit size case. Making this input parameter a void
pointer would remove type validation and adds complexity.
> And we need `flags` to determine the size. Also `flags` is a great
> way to expand this funciton in the future without the need to create
> __vdso_robust_futex_unlock2().
But adding flags leaves additional error handling burden for the caller.
I'm not sure it's a win.
> I would also have `uval` instead of `val = 0`, because even though the
> most common semanthics for futex is that (LOCK_FREE == 0), futex has no
> predetermined semanthics of what each value means, and the userspace is
> free to choose what value they want to choose for a free lock.
Agreed on adding a u32 val parameter.
We can specialise the vdso for the size, e.g.:
extern u32 __vdso_robust_futex_unlock_u32(u32 *uaddr, u32 val, struct robust_list_head *robust_list_head);
and eventually add vdsos for u8, u16, u64.
Thoughts ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2026-03-12 14:05 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 18:54 Mathieu Desnoyers
2026-03-11 20:11 ` Mathieu Desnoyers
2026-03-12 8:49 ` Florian Weimer
2026-03-12 13:13 ` Mathieu Desnoyers
2026-03-12 14:12 ` Florian Weimer
2026-03-12 14:14 ` André Almeida
2026-03-12 16:09 ` Mathieu Desnoyers
2026-03-12 13:46 ` André Almeida
2026-03-12 14:04 ` Mathieu Desnoyers [this message]
2026-03-12 18:40 ` Mathieu Desnoyers
2026-03-12 18:58 ` André Almeida
2026-03-12 19:10 ` Thomas Gleixner
2026-03-12 19:16 ` Mathieu Desnoyers
2026-03-13 8:20 ` Florian Weimer
2026-03-12 20:19 ` Thomas Gleixner
2026-03-12 21:28 ` Mathieu Desnoyers
2026-03-12 22:23 ` Thomas Gleixner
2026-03-12 22:52 ` Mathieu Desnoyers
2026-03-13 12:12 ` Sebastian Andrzej Siewior
2026-03-13 12:17 ` Mathieu Desnoyers
2026-03-13 13:29 ` Sebastian Andrzej Siewior
2026-03-13 13:35 ` Mathieu Desnoyers
2026-03-16 17:12 ` Thomas Gleixner
2026-03-16 19:36 ` Mathieu Desnoyers
2026-03-16 20:27 ` Thomas Gleixner
2026-03-16 21:01 ` Mathieu Desnoyers
2026-03-16 22:19 ` Thomas Gleixner
2026-03-16 22:30 ` Mathieu Desnoyers
2026-03-16 23:29 ` Thomas Gleixner
2026-03-20 18:13 ` Mathieu Desnoyers
2026-03-24 21:35 ` Thomas Gleixner
2026-03-25 14:12 ` Mathieu Desnoyers
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=c2eec0c1-1509-4c32-92c0-2f256543a83e@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=Liam.Howlett@oracle.com \
--cc=andrealmeid@igalia.com \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=carlos@redhat.com \
--cc=dalias@aerifal.cx \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=fweimer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=triegel@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®