Merged
Conversation
Three new Stellux syscalls (SYS_FUTEX_WAIT=1030, SYS_FUTEX_WAKE=1031, SYS_FUTEX_WAKE_ALL=1032) providing the kernel-side foundation for userspace synchronization primitives (mutexes, condvars, barriers). Implementation uses a fixed 256-bucket hash table keyed by (mm_context, uaddr). Waiters are stack-allocated in the syscall handler. Wake batching follows the existing wait_queue.cpp pattern. Timeout support via timer::schedule_sleep, thread kill handled through existing force_wake_for_kill path. Co-authored-by: Albert Slepak <FlareCoding@users.noreply.github.com>
Tests cover: EAGAIN on mismatch, wake with no waiters, basic wait/wake, wake count limiting, timeout, killed thread unblock, wake_all, and address independence. Also fix futex_wait to handle kernel tasks (null mm_ctx) by reading the futex word directly instead of going through uaccess validation. Co-authored-by: Albert Slepak <FlareCoding@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: Albert Slepak <FlareCoding@users.noreply.github.com>
The timeout test was calling futex_wait directly from the boot/idle task, which cannot block. Moved the wait into a spawned kernel task. Also moved timer::schedule_sleep before the bucket lock release to close a preemption window between TASK_STATE_BLOCKED and timer arm. Co-authored-by: Albert Slepak <FlareCoding@users.noreply.github.com>
1. Move uaccess validation before the bucket spinlock. copy_from_user acquires mm_ctx->lock (sleeping mutex) which must not be held under a spinlock. The value is re-read directly under the lock after the page has been faulted in. 2. Add timer::cancel_sleep after yield to prevent a stale timer from spuriously waking the task during a later unrelated blocking op. Co-authored-by: Albert Slepak <FlareCoding@users.noreply.github.com>
Avoids signed wrap when count > INT32_MAX (e.g. UINT32_MAX) which would make the comparison trivially true after waking just one task. Co-authored-by: Albert Slepak <FlareCoding@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
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.

This pull request contains changes generated by a Cursor Cloud Agent