Skip to content

refactor(rcu): make raw callback admission intrusive - #2217

Merged
fslongjin merged 2 commits into
DragonOS-Community:masterfrom
fslongjin:codex/refactor-rcu-intrusive-call-rcu
Aug 29, 2026
Merged

refactor(rcu): make raw callback admission intrusive#2217
fslongjin merged 2 commits into
DragonOS-Community:masterfrom
fslongjin:codex/refactor-rcu-intrusive-call-rcu

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Summary

  • replace growable pending/ready callback queues with one global intrusive FIFO backed by RcuHead
  • make raw callback publication bounded and allocation-free under the RCU IRQ-saving lock
  • preserve FIFO, grace-period, exactly-once, callback reuse, and rcu_barrier() sequencing
  • keep allocating closure helpers separate and document their task-context restriction
  • harden worker wake/lifecycle handling without introducing per-CPU or segmented callback queues

Safety and ordering

  • callback nodes remain address-stable from admission until invocation starts
  • dequeue copies callback metadata and detaches the head before clearing its queued state
  • callbacks may destroy or requeue their embedded head without post-callback dereferences
  • a unique drainer and continuous callback sequence tracking preserve global completion order

Validation

  • make fmt
  • make kernel
  • x86_64 two-CPU QEMU boot
  • /sys/kernel/debug/rcu/selftest: status=ok
  • rcu_selftest_test: all tests passed, including repeated stability runs

Closes #2212

@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-29T07:45:23.810966Z 9520f5b 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d197d1c04f

ℹ️ 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".

Comment thread kernel/src/rcu/mod.rs Outdated
Comment on lines +723 to +726
if KernelThreadMechanism::create_and_run(closure, "rcu_gp".to_string()).is_none() {
RCU_STATE.worker_started.store(false, Ordering::Release);
{
let _inner = RCU_STATE.inner.lock_irqsave();
RCU_STATE.worker_starting.store(false, Ordering::Release);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 为工作线程创建失败保留回调推进路径

create_and_run 因内存压力或进程创建失败返回 None 时,启动流程在 initial_kthread.rs:72 只调用一次 start_worker(),而此分支仅清除 worker_starting 后继续启动;本提交又移除了 quiescent-state、idle/IRQ 等路径在无工作线程时的内联处理,且 progress_and_drain_inline_if_no_worker() 只由 rcu_barrier() 调用。因此后续普通 rcu_defer_drop() 回调即使已度过宽限期也不会执行,除非其他代码偶然调用 rcu_barrier(),持续更新的 RCU 槽会无界保留旧对象并进一步加剧内存压力。这里需要可靠重试、初始化失败,或可从任务上下文触发的后备回调协调器。

Useful? React with 👍 / 👎.

@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 92aeb912bd

ℹ️ 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".

Replace the growable pending and ready callback queues with one global intrusive FIFO backed by RcuHead. Raw callback publication now performs bounded pointer and sequence updates under the IRQ-saving RCU lock without reserving container capacity.

Detach callback metadata before invocation so embedded heads can be destroyed or requeued safely. Preserve FIFO, grace-period, exactly-once, and barrier sequencing through the existing callback tracker, while keeping allocating closure helpers explicitly separate from the raw path.

Tighten worker progress and lifecycle handling, avoid unnecessary wakeups while a grace period is blocked, and add deterministic coverage for allocation failure, duplicate claims, IRQ-disabled admission, embedded destruction, callback requeue, and sequence wraparound.

Validated with make fmt, make kernel, the QEMU debugfs RCU selftest, and the rcu_selftest dunitest.

Closes DragonOS-Community#2212

Signed-off-by: longjin <longjin@dragonos.org>
Treat the RCU callback worker as required boot infrastructure. Continuing after kthread creation failure leaves intrusive callback heads and deferred closures queued without an asynchronous drainer, so their resources can remain retained indefinitely.

Fail fast before the kernel continues initialization, while preserving the existing disabled, idempotent, successful-start, and shutdown paths. This avoids introducing retry state, fallback executors, or callback execution in unsafe contexts.

Validated with make fmt, make kernel, a QEMU failure-injection boot, normal QEMU boot, two debugfs RCU selftest runs, and the rcu_selftest dunitest.

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin
fslongjin force-pushed the codex/refactor-rcu-intrusive-call-rcu branch from 92aeb91 to 9520f5b Compare August 29, 2026 07:42
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9520f5bf89

ℹ️ 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 f6f0209 into DragonOS-Community:master Aug 29, 2026
14 of 16 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): make the intrusive call_rcu path allocation-free

1 participant