chore(sync): migrated kernel atomics to the typed atomic wrappers - #177
Merged
Conversation
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.
Note
Medium Risk
Mechanical but very broad changes in scheduler, signal delivery, and SMP boot synchronization; any mismatched memory order or non-atomic access on a formerly shared field could cause rare races or AP boot hangs.
Overview
Replaces widespread
__atomic_*andvolatileflag usage withsync::atomic<T>andsync::atomic_refacross the kernel (scheduling, signals, SMP, timers, IRQ/MSI dispatch, networking, PTY, reaper, sync primitives, and tests).Type-level changes: hot shared fields are now atomics in structs—e.g.
sched::taskstate,cleanup_stage,run_ticks; signalblocked/pendingand groupshared_pending/exit_signal;smp::cpu_info::state; poll/mutexowner,triggered,error; PTY/console foreground group; MSI handler slots; DHCP RXready/active.Access pattern: standalone counters and flags use
sync::atomicmethods (load_acquire,store_release,fetch_add_relaxed,cmpxchg_strong_acq_rel, etc.). Fields that stay plain scalars for layout/assembly (e.g.task_exec_core::on_cpu,exec.cpu, per-CPU epochs) are updated viasync::atomic_ref<uint32_t>/uint64_t.Fences: IRQ registration and similar handoffs use
sync::atomic_fence_release/acquire; kill/block and signal wake paths use a newsync::atomic_fence_seq_cst. A few failed-CMpxchg paths add an explicit acquire fence when adopting another thread’s winning value (e.g. group exit signal /exit_groupstatus).Test helpers and kernel tests switch from
volatile+ builtins to the same typed atomics for handshakes.Reviewed by Cursor Bugbot for commit 61b9fb8. Bugbot is set up for automated code reviews on this repo. Configure here.