refactor(ax-task): rebuild scheduler and runtime ownership - #1775
Draft
ZR233 wants to merge 196 commits into
Draft
refactor(ax-task): rebuild scheduler and runtime ownership#1775ZR233 wants to merge 196 commits into
ZR233 wants to merge 196 commits into
Conversation
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
2 times, most recently
from
July 30, 2026 02:13
10ccb6d to
4236924
Compare
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
5 times, most recently
from
July 30, 2026 16:15
e927578 to
295087c
Compare
This was referenced Jul 31, 2026
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
from
July 31, 2026 03:25
56056c6 to
60d6971
Compare
ZR233
commented
Jul 31, 2026
ZR233
commented
Jul 31, 2026
ZR233
commented
Jul 31, 2026
ZR233
commented
Jul 31, 2026
ZR233
commented
Jul 31, 2026
ZR233
commented
Jul 31, 2026
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
2 times, most recently
from
July 31, 2026 06:33
d06e408 to
4dc2b44
Compare
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
from
July 31, 2026 08:25
8998618 to
6282d90
Compare
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
2 times, most recently
from
July 31, 2026 12:08
b3d54af to
111ad4f
Compare
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
2 times, most recently
from
August 3, 2026 02:42
3758658 to
b492d23
Compare
ZR233
force-pushed
the
codex/refactor-ax-task-from-1596
branch
from
August 3, 2026 09:21
2c7c43f to
0fe14b3
Compare
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.
问题
旧任务系统把 OS 资源、调度状态、物理 clockevent 和中断唤醒生命周期耦合在一起。迁移与 Linux v7.1
CONFIG_PREEMPT_RT=y对照审计中确认了以下系统性风险:on_cpu和 switch-tail 由多套状态分别维护,线程可能被重复拥有或过早回收;Firing期间更新容易留下陈旧状态;本 PR 以 #1596 的 OS 无关
ax-task核心为迁移起点,并按 Linux v7.1 scheduler、rtmutex、hrtimer/clockevent、irq_work、task_work、perf 和 exit 生命周期重新审计和重构。完整设计、不变量、红绿测试与历史里程碑记录在book/design/ax-task-linux-v7.1-rt-audit.md。主要改动
ax-task / ax-runtime
components/ax-task,提供TaskSystem、每 CPUCpuLocal、generation-bearingThreadId/ThreadHandle、运行时调度策略、PI、wait、executor 和 task-work;删除旧os/arceos/modules/axtask。ax-runtime::task成为 ArceOS/StarryOS 的任务入口,负责 bootstrap、stack/TLS/context/address-space、IPI、clockevent、switch-tail 和资源回收。SchedulerPlacement状态机表达 detached、queued、running、switching-out、migrating 和 exited-awaiting-tail;只有 switch tail 清除物理on_cpu后才允许迁移完成或回收。CPU_CAPACITY约束。Task deadline / clockevent
ax-task只管理 sleep、park、wait timeout、调度策略和自身 deferred work deadline,不承载 VM/POSIX 任意 timer callback。ThreadId + node identity + arm generation + typed kind;cancel/rearm 物理删除旧条目,不保存 tombstone 或裸 timer-node 指针。ax-runtime::LocalClockEvent是物理 oneshot timer 的唯一 owner,显式实现Offline / Idle / Armed / Firing,统一选择 task deadline 与 periodic source 的最早期限。PI、等待和资源生命周期
IrqWaitCell使用 generation-bearing registration;撤销后等待在途 notifier quiesce,IRQ 不保存裸 wake 指针。StarryOS
ThreadId分离;保留最新dev的ProcessIdentity: Live -> Zombie -> Reaping -> Reaped作为唯一 PID/zombie/reap authority。Ready / Interrupted / TimedOut,signal publication/acknowledgement 使用单调 generation。PerfTarget::{Task, Cpu}、固定 owner-CPU worker、generation-checked sampling registration 和 owner fence。ITIMER_REAL仍由 wall-clock worker 驱动,ITIMER_VIRTUAL/PROF不再按 wall time 轮询。本分支涉及的 IRQ/驱动边界
最新 dev rebase 与本轮修复
当前 HEAD
75db31f35基于最新origin/devf1774c1f6。本轮刷新后无需新增 rebase 提交;dev 的ProcessIdentity: Live -> Zombie -> Reaping -> Reaped、AxVM CPU lifecycle 与 LS2K IRQ 修复均保持不变。现有 stash 和两个 rustc ICE 日志未改动。本轮新增五十八个阶段提交:
fix(ax-runtime): adapt block runtime after dev rebaseIrqNotify/AxTaskRefAPI 迁到IrqWaitCell、固定 service-thread waiter、generation-bearingThreadHandle和 affinity spawn;SpinNoPreempt,不无故屏蔽 IRQ;PiMutex,IRQ 可达的 block runtime 元数据继续使用非睡眠 gate;fs时误执行的问题。fix(ax-task): serialize deferred scheduler tick accountingThreadId和单调observed_nswatermark;SpinNoPreemptwriter gate 排除跨 CPU 双写并实现Retry;第 31 项进一步删除这套过渡设计,恢复 Linux owner-CPU vtime 所有权;Complete。fix(ax-task): yield between scheduler tick retriesRetry的确定性红测在一个 64 项 service batch 中观察到 64 次 callback,证明原实现虽有总预算但会在同一 worker pass 内忙重试;task_work_run()在每个 callback 后执行cond_resched()的 RT 友好边界。fix(ax-task): publish coalesced scheduler tick timestampsobserved_ns:consumer 可能 claim 旧 publication、读到旧时间戳,而 producer 又因看到 pending 而不重新入队;irq_work_claim()即使 work 已 pending 仍执行 atomic RMW 的 publish/claim 配对。perf(ax-runtime): streamline preemption guard accessCpuPin/ExclusiveCpu;TaskRuntime::current_cpu_id收窄为要求既有 migration pin 的 unsafe capability,IRQ-context 检查在该 pin 下直接读取平台 publication bit;NoPreemptdrop 中递归进入通用 IRQ 查询并触发 x86_64 double fault;确定性 host 测试要求嵌套退出不调用 IRQ/reschedule probe,修复采用 Linuxpreempt_count_dec_and_test()一样的 state-first 短路顺序;current_area/current_thread/symbol_offset热点消失,但 DHCP 到 shell 仍为 13.43 秒/13,113 samples,明显慢于 dev 的 4.99 秒/4,606 samples;剩余 owner schedule、remote/policy inbox drain 的插件放大继续追踪,真实性能由第 9 项无插件对照判定。perf(ax-task): skip empty owner inbox drainssched_ttwu_pending()的空 llist 快速返回;没有把该优化扩大为跳过 dispatch commit/Deadline service,因为__schedule()在prev == next时仍维护 rq clock、hrtick 和调度状态;scheduler_wait_preempt仍占 46.27%,因此该提交只关闭空 drain 浪费;该插件窗口不再单独作为真实性能结论,见第 9 项无插件对照。fix(ax-task): bound deadline member scan roundsdeadline_members > batch_limit时旧游标会永久重投 owner work;第一批 backlog 又被 no-switch tail 误报为Quiescent;SchedulerOutcome::OwnerWorkPending覆盖全部有界 owner work;sched/deadline.c的 per-entitydl_timer/inactive_timer,文档已把成员扫描重新列为待关闭架构 finding:本提交只封住有限批次 livelock,后续将 CBS replenishment 与 GRUB zero-lag 改为 generation-checked typed event;test(ax-sync): keep lock audit stable across module splitscache.rs路径而失败;SpinMutex声明恰好出现一次,继续约束 IRQ/任务态锁分类,而不是放宽断言。perf(ax-task): cache the current CPU remote endpointneed_resched查询仍执行一次通用 remote registry lookup(0, 1);修复后为(0, 0);preempt_count/need_resched直接访问,ax-runtime 在 CPU online 前缓存 shutdown-lifetimeCpuRemoteendpoint,当前 CPU 查询通过 current-thread 寄存器访问,远程 producer 仍显式按 CPU 查找;qperfCargo feature、NVMe rootfs 和 virtio-net,但不加载指令插件,当前分支 DHCP 为 3.328285 秒,dev 为 3.321183 秒,差 7.1ms(约 0.21%),不支持材料性的真实 wall-time 回退;缺失 workload marker 的插件结果明确作废。fix(ax-task): replace deadline scans with typed timer eventsbatch_limit = 1时,旧普通 safe point 仍会因成员扫描返回OwnerWorkPending;新实现不再扫描未到期 reservation;sched_dl_entity独立的dl_timer与inactive_timer,每线程嵌入 park、CBS、zero-lag 三类节点,硬 IRQ 只复制值类型事件,safe point 按完整 registration identity 验证;deadline_memberstimer scan 和第二套deferred_scheduler_deadline_ns标量;deadline_members仅保留 GRUB ownership/offline registry 语义;DeadlineRefresh定向投递;合并保留的旧消息按当前 CBS generation 重算,不重放旧状态;ThreadId/class 的不同 node 会发生 registration ABA;token 现在组合 process-lifetime node identity 与 node-local generation,旧 registration 不能取消另一节点;__schedule()在 rq clock/accounting 后清need_resched的顺序,补 RR forced-yield 回归;完整 ax-task、ax-runtime、ax-sync 测试与 feature clippy 通过。fix(ax-task): return typed PI cycle errorsrt_mutex_lock()可把内核死锁视为调用错误,但 PI-futex/proxy registration 的 full chain walk 返回-EDEADLK;ax-task::pi_wait_start()接受显式 waiter/owner,属于可复用 graph/proxy 边界,现在在任何 generation/edge mutation 前返回TaskError::PiCycle;ax-sync::RawMutex的 infallible lock API 仍可把该错误升级为 kernel programming failure,策略不再硬编码进调度核心;红绿测试同时证明失败后原有 donation edge 仍可正常取消;fix(starry-task): use PI locks for task registriesSpinRwLock;这些临界区会执行BTreeMap/WeakMap插入、删除、遍历和 weak handle upgrade;tasklist_lock的rwlock_t会替换为rwbase_rt/rtmutex-backed wait path;四个 Starry 注册表改用PiMutex,竞争时睡眠并提供优先级继承;ProcessIdentity的短小、无分配生命周期状态仍使用SpinNoIrq,锁序明确为 registry → identity state,避免机械替换 IRQ/原子状态锁;fix(starry-task): close clone activation windowcopy_process()的“最后可失败准备 → tasklist 可见性提交 → 不可失败wake_up_new_task()”,ax-runtime 将启动拆成可失败的PreparedThread::stage()与不可失败的StagedThread::activate();Aborted并让线程在消费 Starry/user entry 前退出、进入正常 switch-tail/reap;ProcessIdentity: Live -> Zombie -> Reaping -> Reaped仍是唯一 identity authority;fix(starry-perf): separate control and IRQ output locksPerfEventOps::enable执行 scheduler yield,旧SpinNoPreempt<Box<dyn PerfEventOps>>使其稳定返回 unsafe-context,套件为 387 pass / 1 fail;PiMutex,不再在禁抢占 raw gate 内分配页、构建 VM 或等待 PMU worker;BpfPerfOutputraw endpoint,IRQ/trace producer 只进入有界 ring write 与IrqNotifypublication;页分配、清零和Arc创建均在 raw gate 外;fix(starry-trace): publish callbacks outside raw locksSpinNoPreempt<ExtTracePoint>把任意 trace/perf/BPF callback 包在禁抢占 raw gate 内,套件稳定为 388 pass / 1 fail;kernel/tracepoint.c:先发布完整 probe generation 再打开 fast-path gate,最终移除先关 gate,旧 probe array 通过 SRCU/RCU grace period 延迟释放;ktracepoint将 callback list mutation 改为无全局副作用的值操作,以 Acquire/ReleaseAtomicBool作为 runtime gate,不再在 SMP 运行期间为 tracepoint patch executable text;dev 的static-keys与 dynamic-debug 初始化原样保留;PiMutex构造 replacement,raw gate 只负责Arcsnapshot acquire/swap;两 epoch reader lease 覆盖 callback,最后读者仅发布 IRQ-safe sticky notify,task worker 负责最终回收;fix(ax-task): service local wakes at scheduler safe pointsperf(ax-runtime): fold reschedule state into preemption guards__preempt_count,把普通 guard depth 与反向need_reschedbit 合并进 current-thread fast-path word;无调度请求的最终 guard 通过一次 CAS 直接退出,不再关闭 IRQ、解析 CPU-local handle;lock前缀的 RMW,其他架构使用 portable atomic fallback;红绿测试覆盖嵌套、无 resched fast path、pending baton 和单 generation 消费;fix(axbuild): test new ax-task without legacy featuresax-task标准测试清单,但删除旧 axtask 的host-test/multitask/preempt/lockdepprofile;新核心使用默认cargo test -p ax-task;fix(ax-runtime): model pre-bootstrap host guards safelyhost-test下允许 bootstrap 前的 preemption guard 安全 no-op,生产构建继续严格拒绝缺失 current-thread;axvm/host-test经ax-std/host-test补齐 runtime 配置,原精确 SIGSEGV 用例和后续 IRQ sender 触发点均转绿,axvm 143 项 host-test 全部通过。fix(ax-task): make owner migration transactionalQueued -> Migrating转换提交;test(ax-runtime): declare host guard lock dependencyhost-test单独 profile 现在显式声明ax-kspin/host-testdev dependency,保持 bootstrap 前SpinNoIrq回归在与 CI 相同的 feature 闭包内可编译;ax_kspin,修复后cargo test -p ax-runtime --features host-test21/21、ax-runtime 26/26 feature clippy 通过。fix(ax-task): preserve EEVDF ordering across wrapu64::MAX红测先稳定复现两个 virtual deadline 被saturating_add压成同一值、随后按入队顺序选错任务;vruntime_cmp、entity_before、zero_vruntime、sum_w_vruntime与avg_vruntime,owner fair rq 改为有符号环形比较和相对加权和;负值平均保持左偏,running entity 与 queued entities 参与同一 rebase;fix(ax-task): replenish CBS at the next releasedl_next_period()、start_dl_timer()与replenish_dl_entity(),普通 depletion 和 yield 都在 next release 触发;overrun debt 只推进到正预算,若所得 deadline 已落后于 now,则启动恰好一个 fresh job;fix(ax-task): enforce constrained deadline wake rulesD<P线程在 absolute deadline 之后、next release 之前 wake 时,旧实现会提前发放新预算;revised-wakeup density 又错误使用 period 而不是 relative deadline;dl_entity_overflow()、update_dl_revised_wakeup()与dl_check_constrained_dl():deadline 前超密度只削减 residual runtime,deadline 后保持 blocked 并把 clockevent 设为 next release;TaskSystem唯一 owner,RunQueue只接收已激活实体;PI-boosted 锁持有者覆盖 throttle,避免非 Deadline base thread 因不存在 replenishment carrier 而永久阻塞;fix(axvm): route timer cancellation to owner workerSpinNoIrqwheel;保留 CPU-affine task worker 和有界 wake 边界;fix(starry-process): release address space before zombie wakewaitpid观察后,父进程munmap最后一处 shared-writable memfd VMA,F_ADD_SEALS(F_SEAL_WRITE)仍错误返回EBUSY;do_exit()的exit_mm()先于exit_notify(),Starry 现在先完成 SysV SHM 与地址空间资源回收,再发布稳定 zombie identity 和 wait/pidfd 通知;qemu/system/syscall-test-modern-fd-family从 244/245 红灯转为 245/245,正式 grouped 成功标志通过;starry-kernel24/24 feature/target clippy、fmt 和 diff check 通过。fix(starry-ptrace): deliver kill before releasing event stopperf(ax-task): reduce placement and guard overheadyield_current在 scheduler baton 内又进入 8 次完整 IRQ guard;scheduler 内部纯任务态 registry、runqueue、wait 与 kernel-thread 元数据改为 preemption-only ticket lock,IRQ publication 继续保留 IRQ-safe gate;queued + running + in-flight migrationworkload 选取,避免所有新线程集中到创建 CPU;完整 ax-task(218 unit、全部 integration/doc、20 loom)及 ax-task/ax-runtime/ax-sync/ax-net clippy 通过。perf(ax-runtime): lazily defer later clockevent rearmProgram(400);HRTIMER_MODE_LAZY_REARM:新期限更早时立即重编程,向未来移动时保留已武装的更早中断并在 firing transaction 中汇总最新逻辑期限;59 项 ax-runtime host 行为测试与 26 组 feature clippy 通过;do_sched_yield()收窄 deadline service、balance 与 clockevent publication。perf(ax-runtime): make preemption state CPU-localneed_resched位从 task-ownedCurrentThreadHeader移入固定CpuRuntimeAnchor,上下文切换不再搬运或重置 CPU guard 状态;FinalPending本身即为调度请求观察,IRQ 关闭后原子转换为 scheduler baton,不再二次查询CpuRemote/registry;task-yield与 x86_64task-irq。perf(starry-task): make CPU vtime owner-writtenvtime_user_enter/exit、vtime_task_switch_generic和task_cputime,删除 Starry 跨 CPUSpinNoPreemptwriter gate;只有运行线程的 owner CPU 在短NoPreempt区间写 task vtime,远端 scheduler-tick worker 通过奇偶 sequence 只读采样;Retry;ScheduleDecision把 applied base policy 直接交给 switch-in,删除旁路realtime_policy原子并关闭 inactive-to-running 竞态;perf(ax-task): make wake and deadline service scheduler-drivenWAKE/REQUEUE/WAKE_OP只完成 wake publication,不再强制让 syscall 调用者yield_now();调度器的 stickyneed_resched与 guard/IRQ exit 负责必要抢占,对齐 Linux v7.1wake_q的 producer/consumer 边界;TaskSystem入口保留 direct-core deadline service,facade 使用 typedAlreadyServiced入口避免同一 safe point 二次扫描;timer batch 满载时先排空已提升事件,再进行一次到期 promotion,保证无需偶然下一次 IRQ 也能推进;origin/dev31f341abc时保留 fix(cpu-local): guard uninstalled host CPU areas #1798 更完整的 host CPU-area guard,并保留本分支 pre-bootstrap guard 修复;CPU-local host 测试、ax-task 222 个 unit、全部 integration/doc、20 个 loom、相关 clippy 与 x86_64 Starry 391 项 axtest 通过。perf(ax-task): unify scheduler work and IPI ownershipSchedulerIpiDoorbell成为唯一物理投递 owner,并在 IPI entry 先消费再执行共享 callback;perf(ax-task): separate forced yield from scheduler workdo_sched_yield()与 fair/deadline class yield,forced yield 只提交当前 dispatch、消费本次选择覆盖的 preemption request、执行 class transition 并选取 successor,不再顺带 drain owner inbox 或运行 deadline/deferred work;CpuLocal缓存最后一次发布的逻辑 task-deadline 状态,普通 switch tail 仅在 deadline 或 deferred-work 位变化时增加 generation 并调用 runtime;物理 clockevent commit 由 runtime 唯一、不可失败的所有权边界完成;fix(ax-task): derive scheduler deadlines from owner stateCpuRemote::scheduler_deadline_ns原子镜像;clockevent 直接从 owner 的 current dispatch、runqueue cached minimum、RT bandwidth 和 fair-balance 状态选择,任何 dequeue、policy、PI 或 migration 变化都不再等待额外 refresh;test(ax-runtime): compile preempt helpers in host testshost-testprofile 单独编译时,回归测试仍调用只在multitaskfeature 下编译的enter_preempt/exit_preempt,因此在运行前报两个 E0425;cfg(test)下编译,不以 feature gate 跳过回归;原 CI 命令cargo test -p ax-runtime --features host-test由编译失败转为 24/24,通过 26/26 feature clippy。refactor(ax-task): isolate forced scheduler transitionsTaskSystem::{commit_park, block_current, exit_current}改为显式接收 owner timestamp,删除隐藏的第二状态转换时钟;exit 仍保留 selection 完成后的独立 clockevent 重采样,避免编程过期 one-shot;fix(ax-task): make deadline cancellation transactionalTaskDeadlineCancelTxn:deadline generation 更新失败时恢复同一 token、同一 heap entry 与 class capacity,不再返回半取消状态;TaskRuntime::publish_task_deadline改为类型上不可失败,物理 clockevent 的 local state 与硬件 commit 由 ax-runtime 在同一 IRQ-excluded transaction 中独占,删除测试专用的伪 recoverable failure;fix(ax-task): reject task control from hard irqvalidate_task_context()authority;UnsafeContext且策略不变;try_thread_state()及生产态 try-lock escape hatch;ax-task 229 个 unit、20 个 loom、ax-runtime 62/62 和两包 clippy 通过。fix(ax-task): split CPU placement from wake reachabilitycpu_active/cpu_online分层,将 CPU lifecycle 重构为Online / Inactive / Draining / Offline:Inactive 关闭新 placement,但保留旧 generation-bearing wake route 的可达性;target_cpu不再被误判为物理 CPU ownership;CPU-down 只拒绝 queued/running/on-CPU/migrating、Deadline bandwidth 和 sleep timer 等真实 owner,并把 dormant wake route 事务式重定向到允许的 active CPU;CpuNotQuiescent(1),修复后 CPU 1 成功 offline、wake 路由迁至 CPU 0 并通过真实 inbox drain 进入 Ready;publisher 测试证明在途旧 wake 阻止最终 draining;fix(ax-task): make wake routing carrier-ownedUnavailable并清除 sticky wake,修复后通过 CPU 0 carrier 投递并进入 Ready;target_cpu只保留 placement hint 语义;CpuWakeCarrier从 inbox publication 到 doorbell 全程持有 lifecycle publisher lease,preferred endpoint 已关闭时在不可变 CPU capacity 内选择任一 scheduler-ready carrier;cpu_local_for_wake()与可绕过 lease 的 remote wake API;test(ax-task): isolate stale wake route regressionrefactor(ax-task): isolate remote scheduler ownershiprq->ttwu_pending/idle polling、balancing 与 task placement 分层,将 1,089 行CpuRemote平铺实现拆为 lifecycle publication、scheduler doorbell、owner snapshot、load summary、idle-pull 和 delivery 六个私有状态对象;根模块收敛为 46 行稳定组合入口;Migrationinbox 类名与publish_policy_update/publish_migration双入口,统一为OwnerControl和publish_owner_control;只有真实 runqueue ownership transfer 继续使用Migrationmessage operation;refactor(ax-task): isolate owner runqueue statestruct rq的 current/idle、CFS/RT/DL class、ttwu_pending与 timing state 所有权,把平铺的CpuLocal拆为OwnerDispatchState、DeadlineClassState、LocalTaskDeadlineState和OwnerDrainScratch四个 owner-only 域;fields_mut()逃逸;balance、wake/control drain、Deadline admission、clockevent 与 switch-tail 只能取得所需状态域或调用命名的跨域事务;migration_buffer更名为真实语义的owner_control_buffer,并保留 scheduler/IRQ 热路径的零额外引用计数:runtime accounting、clockevent selection、deadline expiry 与 fair balance 直接投影 owner-local 字段;refactor(ax-task): separate per-thread scheduler statetask_struct内 sched entity、physical placement、PI 与 memory ownership 的分域方式,把 34 个平铺的ThreadSchedState字段收敛为 lifecycle、policy、placement、Deadline、PI、runtime 六个所有权域;base_policy、active_base_policy、policy三者含义依赖上下文的旧字段,显式命名为 requested、owner-applied、PI-effective policy/entity 及各自 generation;线程创建统一通过一个构造事务初始化所有域;SchedulerPlacement变为该域私有的唯一物理状态机,没有增加 queued/running/on_cpu 镜像缓存;fix(ax-task): avoid registry scans for exited workexit_notify()的显式 dead-list 与release_task()锁外 teardown,把 exit callback/reap 从“扫描全部 registry slot”改为 generation-bearingExitedThreadWorkcandidate;refactor(ax-task): type deferred callback claimsThreadRecord的 exit pending/claimed 与 Deadline claimed 三个并行 bool 收敛为ThreadCallbackState;Absent -> Pending -> Claimed -> Absent;无 callback 保持Absent;Deadline claim 必须恰好 finish 一次;fix(ax-task): publish deadline callbacks without registry scanstask_work/irq_work的显式 work identity,删除每派发一个 Deadline overrun callback 就扫描全部 registry slot 的旧 cursor;ThreadCore嵌入独立 task-work node,producer 只转移一个 retained core reference 并 lock-free publish,事件数在 per-thread state 中 coalesce;fix(cpu-local): select preemption ownership by architectureWaitQueue::wait_once_inner()退出时触发unbalanced CPU-local preemption guard exit;根因是把 x86 的 per-CPU__preempt_count存储方式机械推广到所有架构,使任务迁移后继承前一任务的普通 guard depth;Ok(0x1)改为 typed mismatch;cpu-local 全部 unit/integration/doc tests、3/3 clippy、ax-runtime 26/26 clippy 和 AArch64 Starrytest-sched-family37/37 通过。docs(ax-task): document RT ownership model in ChineseUnpublished -> Published -> Draining -> Dead:IRQ 只访问有界私有状态,经固定队列/IrqWaitCell发布,外部锁与完整 OS 对象只在线程上下文持有;IrqWaitCell在无法证明 notifier quiescent 时会安全泄漏 storage,后续需先补确定性 revoke/drop 红测,再实现显式 draining/grace/reclaim 状态机。fix(ax-task): separate IRQ registration drain lifetimeunregister的 generation load 与 pointer CAS 之间暂停:IRQ 完成旧 generation,同一 node 地址重新发布新 generation;恢复旧 detach 后会删除新 waiter,并在取消旧 generation 时 panic;Detached同时表示“IRQ reader 已结束”和“允许同地址复用”,而旧 Loom 只建模 registration 原子,没有把 cell pointer ABA 纳入状态空间;Detached -> Attached -> Notifying -> Draining -> Detached。IRQ direct wake 完成只进入Draining,任务侧 move-onlyIrqWaitToken::detach()转换为IrqWaitDrain,只有try_finish()完成 grace 后才开放复用;quiesce_irq_wait不再接受可传错的 cell 参数;硬 IRQ 保持有界 CAS、零等待、零分配/析构,所有真实调用点均在无外部锁的任务上下文完成 quiesce;disable_irq_nosync、synchronize_hardirq、irq_work_sync的“先关 admission,再等在途 reader,最后释放”边界;显式遗忘 token 仍以泄漏而非 UAF 失效;fix(axbuild): preserve qperf kernel build contractsCARGO_ENCODED_RUSTFLAGS遮蔽 target inline linker script,以及--qemu-arg -cpu被 argparse 误当选项的回归;append_encoded_rustflags合并 debuginfo/frame-pointer 标志,并以--qemu-arg=<value>传递连字号开头的 QEMU 参数;cargo xtask clippy --package axbuild通过;frame-pointer 模式进一步暴露 qperf plugin 在 guest 早期启动栈上 unwind 导致 host QEMU SIGSEGV,这是归因边界而非 guest scheduler panic。test(starry): add Linux RT futex wake benchmark-cpu max、2 CPU、512 MiB、CPU0/CPU1 affinity、200 次预热与 7 组 2000 次交接;apps/.ignore,避免扩大通用 app CI;中文审计文档记录环境、数据和当前归因;FUTEX_WAIT创建LocalExecutor、WaitQueue、Arc<WaiterState>和 wakeVec<Waker>,下一阶段以线程自有等待节点和解锁后批量唤醒替换该架构。refactor(starry-futex): park directly on scheduler threadsPreparedCurrentPark,让 OS waiter 在自己的队列锁内完成条件检查与 publication,同时由 ax-task 独占 park generation、task deadline 和上下文切换事务;Starry futex 不再为每次 wait 创建临时LocalExecutor、WaitQueue、coroutine 和 waker;WaiterState;re-park 准备失败时旧实现遗留已入队 waiter,新增错误注入回归在修复前为 392/393、修复后为 393/393;ThreadWakeHandle,释放锁后才进入 scheduler wake;signal、timeout 与 notify 通过同一 park generation 决定唯一结果;Arc<WaiterState>、wakeVec和按 key 动态 entry,不把该阶段误报为性能达标。refactor(starry-futex): embed generation wait state in threadsArc<WaiterState>收敛为稳定Thread内嵌的 generation 状态机;队列保存UserTaskRef + generation,由同一状态源裁决 wake、signal、timeout、cancel 和 requeue,旧 generation 不能命中新一轮等待;HashMap/FutexEntry/Vec。fix(starry-timer): isolate alarm worker wake transportevent-listenerfallback spinlock,调用链来自 Starryalarm_task,其余 CPU已进入 idle;WaitQueue + AtomicU64 epoch:producer 在 alarm heap 锁外 publish epoch 并唤醒,worker 先观察 generation、再做 heap snapshot,通过带谓词的 timed wait 关闭 snapshot-vs-publish 丢唤醒窗口;cargo xtask clippy --package starry-kernel25/25 通过;完整 x86_64 system 已越过原全局停滞并完成 398 个 common case;随后停在 USB audio,作为相同event-listener驱动外围边界单独登记 bug(starry-usb): replace no_std event-listener wake transport #1838,本 PR 不越界修改;ext4 inode unique(110s vs 57s,+53s);dev 只用于选择优化顺序,根因、调用链和目标架构继续以 Linux v7.1 PREEMPT_RT 为准。refactor(axbuild): make grouped case execution explicitq35;GuestInit / ShellCommand / External,Starry、Axvisor 与 qperf 各自只有一条入口;删除旧 profile autorun 字段和脚本,不保留双启动兼容;External只注入目标二进制,性能窗口前不再启动正式 runner;perf(ax-task): measure remote wake deliverytest-ext4-inode-unique的 30.6237922 秒窗口中,48,657 个 remote wake 全部 drain,41,648 次 activation 与 owner enqueue 一一相等,38,251 次 IPI send/consume 一一相等,排除永久 lost wake;TTWU_QUEUE=false,下一阶段直接改为 target raw-rq-lock activate,仅实际抢占时发 reschedule IPI;refactor(ax-task): activate wakeups under target runqueue locktry_to_wake_up() -> ttwu_do_activate()路径:waker 在 thread scheduler-state 锁下确定目标,再在目标 CPU 的 IRQ-safe runqueue 锁内完成生命周期激活、物理入队、当前任务抢占判断与 load-summary 发布;RemoteWakeinbox、线程内嵌 wake node、owner drain batch、旧指标名及对应兼容入口;不引入非 RTTTWU_QUEUEwake-list feature fallback,也不保留历史 API 别名;direct_wake_attempts / activations / enqueues / preemptions,旧 remote-wake 数字只作为已删除架构的历史基线;cargo test -p ax-task --features qperf-metrics全部通过;cargo xtask clippy --package ax-task2/2、ax-runtime27/27、starry-kernel26/26 通过;fmt 与 diff check 通过。该边界对应 Linux 的 task-work/irq-work 所有权逻辑,但不照搬对象布局:固定 task-work consumer 只读取 generation-bearing target vtime 快照并发布 high-water delta,不再成为 target task writer;真正的 task vtime 写入始终由执行 owner 和 scheduler baton 串行化。
确定性红绿证据
384 pass / 1 fail。随后 read-only tick 红测又证明 writer gate 仍保留了错误所有权;inactive policy 回归进一步稳定观察到非 owner hook 被调用一次。2026-08-03 EEVDF 最新进展
PLACE_DEADLINE_INITIAL与sysctl_sched_base_slice,Fair 默认基础 request 从 1 ms 调整为 700 us;初始实体只获得半 request,sleep 后和后续 request 使用完整 slice。cargo test -p ax-task(257 个 unit、全部 integration/doc、21 个 Loom 模型)、cargo xtask clippy --package ax-task、fmt 与 diff check 通过。test-ext4-inode-unique在 guest 约 45 秒完成 786/2048,投影仍约 118 秒,明显慢于用于选题的 dev 57 秒,因此按约定主动终止;总墙钟 92.98 秒包含约 23 秒重编译及启动,不声明该 QEMU case 通过。TTWU_QUEUE=false模型,验证“直接锁目标 runqueue 激活、仅需要抢占时发送 reschedule IPI”,不恢复旧 wakeup granularity 或其他兼容路径。当前验证
run_host在 NVMe block endpoint 注册后、测试套件开始前超时 120 秒,其余后续 job 被 fail-fast 取消;该启动期 deferred worker/timer/IRQ 链路将在本 head 上继续复现,cancelled job 不作为通过或失败证据。task-yield:x86_64、AArch64、RISC-V、LoongArch64 全部通过;x86_64task-irq通过。qemu/system/syscall-test-modern-fd-family:245/245,正式STARRY_GROUPED_TESTS_PASSED;覆盖 fork/exit/wait 后 memfd shared-writable VMA 计数已在 parent 可见前释放。cargo test -p cpu-local --features host-test:全部 unit/integration/doc tests 通过;旧 thread-owned preempt 集成测试已由 fixed-anchor 状态机与 runtime 行为测试取代。qemu/block-io-bench:1/1,正式STARRY_GROUPED_TESTS_PASSED;write 288588us、read 17853us。cargo test -p ax-task --lib:243/243。cargo test -p ax-runtime --no-default-features --features host-test,multitask:62/62。cargo test -p ax-runtime --features host-test:24/24。cargo test -p ax-runtime --features host-test,multitask,fs --lib:52/52。cargo xtask clippy --package ax-task:1/1。cargo xtask clippy --package ax-runtime:26/26 feature 组合。cargo xtask clippy --package axbuild:通过。cargo test -p cpu-local --features host-test:全部 unit/integration/doc tests 通过。cargo test -p axvm --features host-test --lib:143/143。cargo xtask clippy --package cpu-local:3/3;axbuild:1/1;axvm:6/6。cargo test -p ax-sync --features multitask --lib -- --test-threads=1:27/27;默认并行测试的全局 preemption fixture 隔离问题已登记 test(ax-sync): isolate preemption state between parallel unit tests #1812,本轮不越界修改。cargo test -p ax-net:72 个 unit test 通过。cargo xtask clippy --package ax-sync:3/3 feature 组合。cargo xtask clippy --package ax-net:3/3 feature 组合。cargo test -p ktracepoint --lib:1/1;带 linker section 的 host example 实际运行并输出 cooked/raw callback。cargo xtask clippy --package ktracepoint:1/1。cargo xtask clippy --package starry-kernel:25/25 feature/target 组合。cargo xtask ktest qemu --package starry-kernel --arch x86_64:394/394,AXTEST_SUITE_OK。cargo xtask sync-lint:187/187 workspace packages。cargo fmt --all --check、git diff --check:通过。较早里程碑已完成四架构 ArceOS/Starry QEMU、scheduler placement、deadline/IPI/idle、PI/park/IRQ waiter、perf/PID/zombie、UART/vsock/USB 定向回归。本轮 owner-only vtime、futex wake 与 deadline safe-point 已重复运行 x86_64 全部 391 项 axtest;四架构 full-system 留到下一个核心里程碑统一运行。
兼容性与后续
TaskInner/AxTaskRef/AxTaskExt生命周期模型。Closes #1833