<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/futex/futex.h, branch linux-6.15.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-01-24T08:37:30Z</updated>
<entry>
<title>futex: Pass in task to futex_queue()</title>
<updated>2025-01-24T08:37:30Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2025-01-15T16:05:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5e0e02f0d7e52cfc8b1adfc778dd02181d8b47b4'/>
<id>urn:sha1:5e0e02f0d7e52cfc8b1adfc778dd02181d8b47b4</id>
<content type='text'>
futex_queue() -&gt; __futex_queue() uses 'current' as the task to store in
the struct futex_q-&gt;task field. This is fine for synchronous usage of
the futex infrastructure, but it's not always correct when used by
io_uring where the task doing the initial futex_queue() might not be
available later on. This doesn't lead to any issues currently, as the
io_uring side doesn't support PI futexes, but it does leave a
potentially dangling pointer which is never a good idea.

Have futex_queue() take a task_struct argument, and have the regular
callers pass in 'current' for that. Meanwhile io_uring can just pass in
NULL, as the task should never be used off that path. In theory
req-&gt;tctx-&gt;task could be used here, but there's no point populating it
with a task field that will never be used anyway.

Reported-by: Jann Horn &lt;jannh@google.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/all/22484a23-542c-4003-b721-400688a0d055@kernel.dk


</content>
</entry>
<entry>
<title>futex: fix user access on powerpc</title>
<updated>2024-12-09T18:00:25Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2024-12-09T18:00:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=32913f348229c9f72dda45fc2c08c6d9dfcd3d6d'/>
<id>urn:sha1:32913f348229c9f72dda45fc2c08c6d9dfcd3d6d</id>
<content type='text'>
The powerpc user access code is special, and unlike other architectures
distinguishes between user access for reading and writing.

And commit 43a43faf5376 ("futex: improve user space accesses") messed
that up.  It went undetected elsewhere, but caused ppc32 to fail early
during boot, because the user access had been started with
user_read_access_begin(), but then finished off with just a plain
"user_access_end()".

Note that the address-masking user access helpers don't even have that
read-vs-write distinction, so if powerpc ever wants to do address
masking tricks, we'll have to do some extra work for it.

[ Make sure to also do it for the EFAULT case, as pointed out by
  Christophe Leroy ]

Reported-by: Andreas Schwab &lt;schwab@linux-m68k.org&gt;
Cc: Christophe Leroy &lt;christophe.leroy@csgroup.eu&gt;
Link: https://lore.kernel.org/all/87bjxl6b0i.fsf@igel.home/
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>futex: improve user space accesses</title>
<updated>2024-11-25T20:11:55Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2024-11-22T19:18:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=43a43faf5376114161aa684834d24e06da596287'/>
<id>urn:sha1:43a43faf5376114161aa684834d24e06da596287</id>
<content type='text'>
Josh Poimboeuf reports that he got a "will-it-scale.per_process_ops 1.9%
improvement" report for his patch that changed __get_user() to use
pointer masking instead of the explicit speculation barrier.  However,
that patch doesn't actually work in the general case, because some (very
bad) architecture-specific code actually depends on __get_user() also
working on kernel addresses.

A profile showed that the offending __get_user() was the futex code,
which really should be fixed up to not use that horrid legacy case.
Rewrite futex_get_value_locked() to use the modern user acccess helpers,
and inline it so that the compiler not only avoids the function call for
a few instructions, but can do CSE on the address masking.

It also turns out the x86 futex functions have unnecessary barriers in
other places, so let's fix those up too.

Link: https://lore.kernel.org/all/20241115230653.hfvzyf3aqqntgp63@jpoimboe/
Reported-by: Josh Poimboeuf &lt;jpoimboe@kernel.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>futex: make the vectored futex operations available</title>
<updated>2023-09-29T08:37:07Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-06-13T14:34:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e9a56c9325ef28d5481712e85dd5d3f8b2a68e88'/>
<id>urn:sha1:e9a56c9325ef28d5481712e85dd5d3f8b2a68e88</id>
<content type='text'>
Rename unqueue_multiple() as futex_unqueue_multiple(), and make both
that and futex_wait_multiple_setup() available for external users. This
is in preparation for wiring up vectored waits in io_uring.

Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>futex: make futex_parse_waitv() available as a helper</title>
<updated>2023-09-29T08:37:05Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-06-13T14:31:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5177c0cb306a8628bafbf1e6b7aa7e1b7436b8dc'/>
<id>urn:sha1:5177c0cb306a8628bafbf1e6b7aa7e1b7436b8dc</id>
<content type='text'>
To make it more generically useful, augment it with allowing the caller
to pass in the wake handler and wake data. Convert the futex_waitv()
syscall, passing in the default handlers.

Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>futex: add wake_data to struct futex_q</title>
<updated>2023-09-29T08:37:01Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-06-13T21:44:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8af1692616d993c93a080865a7f19506733aa462'/>
<id>urn:sha1:8af1692616d993c93a080865a7f19506733aa462</id>
<content type='text'>
With handling multiple futex_q for waitv, we cannot easily go from the
futex_q to data related to that request or queue. Add a wake_data
argument that belongs to the wake handler assigned.

Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>futex: abstract out a __futex_wake_mark() helper</title>
<updated>2023-09-29T08:36:54Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-07-12T15:14:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e52c43403c9b839a30a9cfc4b75109581389d764'/>
<id>urn:sha1:e52c43403c9b839a30a9cfc4b75109581389d764</id>
<content type='text'>
Move the unqueue and lock_ptr clear into a helper that futex_wake_mark()
calls. Add it to the public functions as well, in preparation for using
it outside the core futex code.

Suggested-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>futex: factor out the futex wake handling</title>
<updated>2023-09-29T08:36:50Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-06-08T17:56:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=12a4be50aff30ee8f2c6a64020c82a4e997e8d6c'/>
<id>urn:sha1:12a4be50aff30ee8f2c6a64020c82a4e997e8d6c</id>
<content type='text'>
In preparation for having another waker that isn't futex_wake_mark(),
add a wake handler in futex_q. No extra data is associated with the
handler outside of struct futex_q itself. futex_wake_mark() is defined as
the standard wakeup helper, now set through futex_q_init like other
defaults.

Normal sync futex waiting relies on wake_q holding tasks that should
be woken up. This is what futex_wake_mark() does, it'll unqueue the
futex and add the associated task to the wake queue. For async usage of
futex waiting, rather than having tasks sleeping on the futex, we'll
need to deal with a futex wake differently. For the planned io_uring
case, that means posting a completion event for the task in question.
Having a definable wake handler can help support that use case.

Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>futex: move FUTEX2_VALID_MASK to futex.h</title>
<updated>2023-09-29T08:36:16Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2023-07-21T14:41:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3b0781595431acafe3db6596e12deb46975d91dd'/>
<id>urn:sha1:3b0781595431acafe3db6596e12deb46975d91dd</id>
<content type='text'>
We need this for validating the futex2 flags outside of the normal
futex syscalls.

Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>futex: Add flags2 argument to futex_requeue()</title>
<updated>2023-09-21T17:22:09Z</updated>
<author>
<name>peterz@infradead.org</name>
</author>
<published>2023-09-21T10:45:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=27b88f3519e72d71c8cead6b835a26c171109c9b'/>
<id>urn:sha1:27b88f3519e72d71c8cead6b835a26c171109c9b</id>
<content type='text'>
In order to support mixed size requeue, add a second flags argument to
the internal futex_requeue() function.

No functional change intended.

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: https://lore.kernel.org/r/20230921105248.396780136@noisy.programming.kicks-ass.net
</content>
</entry>
</feed>
