Skip to content

refactor(rcu): extract grace period state machine - #2216

Merged
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/rcu-gp-state-machine
Aug 29, 2026
Merged

refactor(rcu): extract grace period state machine#2216
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/rcu-gp-state-machine

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Summary

  • replace redundant grace-period fields with a deterministic state machine for request coalescing, CPU waiting masks, and wrap-safe sequence transitions
  • track callback generations with wrap-safe tickets and a single drainer owner so barrier completion remains FIFO-correct
  • define the ordinary non-preemptible RCU contract in code and place memory barriers at the GP ordering boundaries
  • add deterministic regression coverage for nested requests, empty masks, consecutive GPs, callback generations, FIFO ordering, drainer ownership, and sequence wraparound

Compatibility

The existing public RCU APIs, worker model, callback queue layout, and debug snapshot format remain unchanged.

Testing

  • make fmt
  • make kernel
  • /opt/tests/dunitest/bin/normal/rcu_selftest_test in a 2-vCPU QEMU guest, run twice (2/2 passed each run)

Closes #2209

Replace the redundant grace-period fields with a small deterministic state machine that owns sequence advancement, request coalescing, waiting CPU snapshots, and wrap-safe completion checks.

Track callback generations with wrap-safe tickets and serialize lock-free callback draining through a single owner so rcu_barrier cannot observe out-of-order completion. Keep the existing worker, queue layout, public APIs, and debug snapshot contract unchanged.

Document the ordinary non-preemptible RCU contract in code, make read guards task-bound, and place full memory barriers only at GP start, real quiescent-state reports, GP completion, and synchronous return boundaries.

Add deterministic coverage for nested requests, empty masks, consecutive grace periods, sequence wraparound, callback ticket wraparound, drainer ownership, and callbacks admitted during an active GP.

Tests:
- make fmt
- make kernel
- /opt/tests/dunitest/bin/normal/rcu_selftest_test (QEMU, twice)

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T06:04:10.437153Z 40cf2bd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 40cf2bddca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fslongjin
fslongjin merged commit d227ec5 into DragonOS-Community:master Aug 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(rcu): define ordinary RCU invariants and extract a testable GP state machine

1 participant