Repository navigation
Conversation
kilian-ai
added a commit
to kilian-ai/linux
that referenced
this pull request
Sep 29, 2026
On !CONFIG_MMU, get_futex_key() keys every futex by its virtual address only, on the grounds that there is a single address space. wasm has no MMU but gives every process its own linear memory with an identical layout, so equal addresses in two processes were the same futex: a FUTEX_WAKE in one process could be consumed by a waiter in another, which re-checks its own word and sleeps again, while the intended waiter never wakes. Two concurrent threaded programs (e.g. two ffmpeg encodes) hung with every thread asleep. Add ARCH_NOMMU_PER_MM_ADDRESS_SPACE for no-MMU architectures whose mms are separate address spaces, select it for wasm, and include the mm in the private futex key there, as on MMU systems. Threads and CLONE_VM children share an mm, so they still share futexes. Same change as f11cdab on wasm-linuxontab-7.1 (tombl#57). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 25, 2026
tombl
force-pushed
the
pr/wasm-futex-key-by-mm
branch
from
October 27, 2026 14:35
2995b64 to
5e70d83
Compare
On !CONFIG_MMU, get_futex_key() keys every futex by its virtual address only, on the grounds that there is a single address space. wasm has no MMU but gives every process its own linear memory with an identical layout, so equal addresses in two processes were the same futex: a FUTEX_WAKE in one process could be consumed by a waiter in another, which re-checks its own word and sleeps again, while the intended waiter never wakes. Two concurrent threaded programs (e.g. two ffmpeg encodes) hung with every thread asleep. Add ARCH_NOMMU_PER_MM_ADDRESS_SPACE for no-MMU architectures whose mms are separate address spaces, select it for wasm, and include the mm in the private futex key there, as on MMU systems. Threads and CLONE_VM children share an mm, so they still share futexes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tombl
force-pushed
the
wasm-copy-clone-shared-mm
branch
from
October 27, 2026 14:38
88d00aa to
805f8ca
Compare
tombl
force-pushed
the
pr/wasm-futex-key-by-mm
branch
from
October 27, 2026 14:38
5e70d83 to
ee14437
Compare
This was referenced Oct 27, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
Position 10 of 14 in the linux release stack. Below: #75 (
wasm-copy-clone-shared-mm). Above: #70.Order, bottom to top:
wasm→ #74 → #62 → #71 → #64 → #65 → #66 → #67 → #68 → #75 → #57 → #70 → #73 → #60 → #72. Squash in this order. distro#263 pins #57's head for everything up to #57. #70, #73, #60 and #72 are pinned by their host halves, distro#238, #254, #181 and #246.Its head lives on kilian-ai's fork, so a GitHub PR can't use it as a base. The same commit is mirrored at tombl/linux
wasm-futex-key-by-mm, which is #70's base. Delete the mirror after #57 lands.On
!CONFIG_MMU,get_futex_key()keys private futexes by virtual address alone (key->private.mm = NULL), because a no-MMU system normally has a single address space. wasm has no MMU, but every process gets its own linear memory, and two instances of the same binary have identical layouts. The kernel therefore treats the same address in two processes as one futex:FUTEX_WAKEin process A can wake a waiter in process B that sits at the same address;In practice, two threaded programs running at the same time hang with every thread in
S(for example two concurrent multithreaded ffmpeg encodes, or two copies of a condvar ping-pong), while each one passes when run alone.Change: a new
ARCH_NOMMU_PER_MM_ADDRESS_SPACE(inarch/Kconfig,depends on !MMU), selected byWASM, makesget_futex_key()include the mm in the private key, as it does on MMU systems. Threads andCLONE_VMchildren share an mm, so they still share futexes. Other no-MMU architectures are unaffected.(
FLAGS_SHAREDis still compiled to 0 on no-MMU, so "shared" futexes are keyed per mm too. As far as I can tell that is correct here, because separate wasm processes don't share memory that a futex could live in.)Deterministic repro: one process waits on a static word and a second instance of the same binary wakes its own copy of that word, where nobody waits:
Run
./futexkey wait & sleep 1; ./futexkey wake. Before this change, the wake reports1and the waiter returns 0, woken by the other process. After it, the wake reports0and the waiter times out withETIMEDOUT.Tested:
futexkey2/2; three concurrent condvar ping-pongs alongside two busy loops, 9/9; two concurrent pthread create/join stress runs, 3/3; two concurrent 4-thread ffmpeg 7.0 encodes, 2/2. All of these hung without the patch.make defconfig && make vmlinux.wasmbuilds; the symbol is=yandkernel/futex/core.obuilds without new warnings. I didn't boot this exact tree under@lowland/kernel.🤖 Generated with Claude Code