perf(ci): parallelize jobs, prebuilt Docker image, caching and shallow clone#197
perf(ci): parallelize jobs, prebuilt Docker image, caching and shallow clone#197MRNIU merged 3921 commits intoSimple-XX:mainfrom
Conversation
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
…asks priority_queue Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Replace custom Singleton<T> with etl::singleton<T> using per-type named aliases (e.g. BasicInfoSingleton, TaskManagerSingleton) defined centrally in kernel.h. Delete singleton.hpp. Update all call sites from Singleton<T>::GetInstance() to TypeSingleton::instance() and assignment-construction to TypeSingleton::create(). Update all documentation references. Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
…e interrupt controllers Interrupt members Move arch-specific singleton type aliases from shared kernel.h into per-arch directories, and convert interrupt controller singletons (PlicSingleton, ApicSingleton) into private members of each arch's Interrupt class, following the existing aarch64 pattern where Gic is already an Interrupt member. - Move Pl011Singleton to src/arch/aarch64/include/pl011_singleton.h - Move SerialSingleton to file-local scope in x86_64/early_console.cpp - Move Ns16550aSingleton to file-local scope in riscv64/interrupt_main.cpp - Add Plic plic_ member to riscv64 Interrupt with InitPlic() deferred init - Add Apic apic_ member to x86_64 Interrupt with InitApic() deferred init - Move APIC creation from ArchInit() to InterruptInit() (boot order fix) - Remove arch-specific #includes and #ifdefs from kernel.h Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Since Interrupt is used as etl::singleton (only one instance), static class members are semantically equivalent to non-static members. Remove static to eliminate the need for out-of-class definitions in .cpp files. - aarch64: interrupt_handlers -> interrupt_handlers_ (non-static member) - riscv64: interrupt_handlers_, exception_handlers_ (drop static + defs) - x86_64: interrupt_handlers_, idts_ (drop static + defs, keep alignas) The alignas(4096) on x86_64 members propagates correctly through etl::singleton via uninitialized_buffer_of<T> which uses alignas(etl::alignment_of<T>::value) on its storage. Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
…irectories Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
- C1: Add ReapTask(current) for orphan tasks in Exit() to prevent TCB leak - C2: Start FSM after default-constructing TCB in Clone() to avoid null deref - I2: Use STATE_ID constant in StateExited::on_event(MsgReap) - I3: Move GetStatus() implementation from header to .cpp file - I4: Enqueue idle task in kReady state, then transition to kRunning - M2: Restore dropped @todo SIGCHLD comment in exit.cpp - M5: Add [[nodiscard]] attribute to GetStatus() Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
…_router Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
U-Boot's image.h requires openssl/evp.h for FIT image signing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
…uild OP-TEE's build system requires aarch64-linux-gnu-cpp which was not symlinked via update-alternatives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Add kSyscallSchedGetaffinity and kSyscallSchedSetaffinity constants for all architectures. Add dispatcher cases for sys_kill, sys_sigaction, sys_sigprocmask, sys_sched_getaffinity, and sys_sched_setaffinity. Implement sys_kill, sys_sigaction, and sys_sigprocmask function bodies that delegate to TaskManager signal methods. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
- signal_test: SIGTERM/SIGKILL default, SIG_IGN, sigprocmask, error paths - affinity_test: get/set affinity syscalls, cross-task, error paths - tick_test: tick increment, sleep timing, runtime tracking - zombie_reap_test: zombie reaping, orphan reparenting, multi-child Wait - stress_test: 20 concurrent tasks, wait non-child, rapid create-exit Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
…w clone - Split single serial job into parallel build-riscv64 + build-aarch64 jobs - Add dev-image.yml workflow to build/push dev container to GHCR - Replace devcontainers/ci per-step with container: for shared container - Use shallow clone (fetch-depth: 1) and shallow submodules (--depth 1) - Add CMake build cache via actions/cache - Reduce system test runs to 3 for PRs (10 for push/release) - Add concurrency group to cancel superseded runs - Upgrade codecov-action v3->v4, actions-gh-pages v3->v4 Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
There was a problem hiding this comment.
Pull request overview
该 PR 以“CI 性能优化”为名重写了 GitHub Actions 工作流与 devcontainer 镜像构建流程,但同时还引入了大量内核/测试/架构层面的功能变更(信号机制、Wait/Block/Wakeup 并发语义调整、新增系统测试、以及 x86_64 支持移除)。
Changes:
- 重写 CI:并行 riscv64/aarch64 job、预构建 devcontainer 镜像、浅克隆、CMake 构建缓存、减少 PR system test 次数、并发取消与依赖 action 升级
- 内核任务系统改动:新增信号子系统、调整 Wait/Exit/Mutex/Block/Wakeup 的锁顺序与跨核唤醒逻辑、bmalloc 加锁
- 测试与平台调整:新增多项系统测试、系统测试入口/命名调整、并移除 x86_64 相关构建/文档/代码
Reviewed changes
Copilot reviewed 110 out of 111 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/workflow.yml | CI 并行化、容器化、缓存、浅克隆、发布改为 artifact 传递 |
| .github/workflows/dev-image.yml | 新增 dev 镜像构建并推送到 GHCR |
| .devcontainer/Dockerfile | devcontainer 依赖调整(移除 x86_64 相关,补充依赖与 /srv/tftp) |
| .devcontainer/devcontainer.json | 扩展列表移除 x86_64 汇编插件 |
| CMakePresets.json | 移除 build_x86_64 preset,调整部分 QEMU flags |
| cmake/functions.cmake | run target 前创建 /srv/tftp 目录 |
| cmake/compile_config.cmake | 移除 x86_64 编译/链接选项 |
| cmake/3rd.cmake | 移除 U-Boot x86_64 defconfig |
| cmake/x86_64-gcc.cmake | 删除 x86_64 工具链文件 |
| src/CMakeLists.txt | 移除 x86_64 QEMU 启动参数分支 |
| src/arch/CMakeLists.txt | 移除 x86_64/apic 子目录与链接 |
| src/arch/README.md | 文档更新为仅支持 riscv64/aarch64 |
| src/arch/AGENTS.md | 文档更新并移除 x86_64 说明 |
| src/arch/aarch64/macro.S | Trap/CalleeSaved 上下文布局大幅缩减(移除 SIMD/FP 保存) |
| src/arch/aarch64/switch.S | kernel_thread_entry 改为调用 kernel_thread_bootstrap |
| src/arch/aarch64/interrupt_main.cpp | 增加 spurious INTID 过滤 |
| src/arch/aarch64/interrupt.cpp | 调整 EOIR 写入时机 |
| src/arch/aarch64/interrupt.S | 依据新 TrapContext 偏移修正返回路径判断 |
| src/arch/aarch64/timer.cpp | TickUpdate 后调用 CheckPendingSignals |
| src/arch/riscv64/macro.S | Trap/CalleeSaved 上下文布局缩减(移除 FPU 保存) |
| src/arch/riscv64/switch.S | kernel_thread_entry 改为调用 kernel_thread_bootstrap |
| src/arch/riscv64/interrupt.S | 更新返回路径中 sstatus 偏移 |
| src/arch/riscv64/timer.cpp | TickUpdate 后调用 CheckPendingSignals |
| src/arch/x86_64/* | 删除 x86_64 架构实现与 APIC 相关代码 |
| src/include/interrupt_base.h | 文档移除 APIC 引用 |
| src/include/expected.hpp | 删除 APIC 错误码,新增 signal 错误码与信息 |
| src/include/kernel_config.hpp | 提升 task/blocked/ready 等容量参数 |
| src/include/signal.hpp | 新增信号数据结构与默认动作 |
| src/include/syscall.hpp | 新增 kill/sigaction/sigprocmask/affinity syscall 号与声明 |
| src/libc/include/sk_stdlib.h | strtod 条件编译移除 x86_64 SSE 分支 |
| src/libc/sk_stdlib.c | 同步更新 strtod 条件编译 |
| src/main.cpp | 移除示例测试任务,增加 atomic_flag 防止多核重复启动主入口 |
| src/memory/memory.cpp | bmalloc 增加 SpinLock 锁适配实现线程安全 |
| src/memory/include/virtual_memory.hpp | 文档移除 x86_64 描述 |
| src/syscall.cpp | 新增 kill/sigaction/sigprocmask/affinity syscall 分发与实现 |
| src/task/CMakeLists.txt | 编译加入 signal.cpp |
| src/task/block.cpp | 增加“已持 sched lock”版本 Block(cpu_sched, ...) |
| src/task/exit.cpp | Exit 流程调整:延后 Wakeup、调整 reparent 时机 |
| src/task/include/scheduler_base.hpp | 声明 kernel_thread_bootstrap |
| src/task/include/task_control_block.hpp | TaskAuxData 增加 SignalState |
| src/task/include/task_fsm.hpp | 增加跨核可见 cached_state_,GetStateId 改读 atomic |
| src/task/include/task_manager.hpp | 增加信号 API;扩展 Block/Wakeup/WakeupOne 接口与注释 |
| src/task/mutex.cpp | Mutex::Lock 增加快慢路径与防丢失唤醒阻塞;UnLock 改 WakeupOne |
| src/task/schedule.cpp | 增加 kernel_thread_bootstrap 实现;调整 scheduler_started 设置时机 |
| src/task/signal.cpp | 新增信号发送/检查/掩码/动作设置实现 |
| src/task/sleep.cpp | Sleep 返回后调用 CheckPendingSignals |
| src/task/wait.cpp | Wait 锁顺序调整、ECHILD 返回、阻塞逻辑改为持两把锁下 Block |
| src/task/wakeup.cpp | Wakeup 改为跨核扫描;新增 WakeupOne;拆分为持锁版本 Wakeup(cpu_sched, ...) |
| src/filesystem/vfs/open.cpp | Open 后调用 FileOps::Open() 准备底层句柄 |
| src/filesystem/vfs/include/vfs_types.hpp | FileOps 新增可覆写 Open(File*) 默认空实现 |
| src/filesystem/fatfs/include/fatfs.hpp | 声明 FatFsFileOps::Open |
| src/filesystem/fatfs/fatfs.cpp | mkdir 允许 FR_EXIST;实现 FatFsFileOps::Open |
| tests/system_test/CMakeLists.txt | system_test 源文件列表与 QEMU 启动参数更新(移除 x86_64 分支) |
| tests/system_test/system_test.h | system test 声明重命名/新增;QemuExit 逻辑调整 |
| tests/system_test/main.cpp | 注册更多 system tests;runner 记录 pid 修正;atomic_flag 防重入 |
| tests/system_test/*_test.cpp | 新增/调整多项 system test(yield/tick/zombie_reap/stress/fork/affinity 等) |
| tests/system_test/*system_test.cpp | 多个函数重命名(*_system_test → *_test),以及 PID 分配策略调整 |
| tests/integration_test/CMakeLists.txt | 移除 x86_64 分支与子目录逻辑 |
| tests/integration_test/aarch64_minimal/main.cpp | 移除手工 SetupFpu 调用 |
| tests/AGENTS.md | 更新 unit test 运行说明为 build_{arch} |
| tests/unit_test/README.md | 移除 x86_64 单元测试条目 |
| docs/docker.md | 文档更新为 riscv64/aarch64,移除 x86_64 示例 |
| tools/README.md | 移除 x86_64 tool 说明 |
| tools/.pre-commit-config.yaml.in | clang-tidy exclude 过滤规则调整(移除 x86_64) |
| tools/Dockerfile | 删除旧工具镜像 Dockerfile |
| tools/x86_64_boot_scr.txt | 删除 x86_64 U-Boot 启动脚本 |
| tools/x86_64_qemu_virt.its.in | 删除 x86_64 FIT 模板 |
| README.md | 文档更新为双架构、移除 x86_64 |
| README_ENG.md | 同上 |
| AGENTS.md | 同上(两架构) |
| 3rd/cpu_io | submodule 更新 |
| .gitignore | 忽略 .claude |
| src/arch/x86_64/apic/* | 删除 APIC 子模块与文档 |
| docs/docker.md | devcontainer 使用示例改为 riscv64 |
| .github/workflows/dev-image.yml | 新增镜像构建 workflow |
Comments suppressed due to low confidence (12)
tests/system_test/CMakeLists.txt:1
- CMakeLists.txt 引用了 thread_group_test.cpp / wait_test.cpp / clone_test.cpp / exit_test.cpp / ramfs_test.cpp / fatfs_test.cpp,但本 PR 中对应实现文件的 diff 仍显示为 thread_group_system_test.cpp / wait_system_test.cpp / clone_system_test.cpp / exit_system_test.cpp / ramfs_system_test.cpp / fatfs_system_test.cpp(未看到文件重命名)。这会导致 system_test 目标在配置/构建阶段直接失败。建议:要么实际重命名这些源文件以匹配新的命名;要么回退 CMakeLists.txt 的文件名列表与现有文件保持一致。
src/arch/riscv64/timer.cpp:1 - 同 aarch64:在 timer IRQ 里直接调用 CheckPendingSignals() 可能导致在中断上下文内执行 Exit/Schedule 等不可重入操作。建议把信号投递处理迁移到 trap_return 或明确的调度安全点,IRQ handler 仅负责 TickUpdate 与设置待处理标志。
src/task/exit.cpp:1 - 当 parent_pid == 0 时,Exit 仅把任务置为 kExited,但不再像旧逻辑那样立即 ReapTask();这会导致“无父进程/孤儿”的任务永远留在 task_table_(资源与 TCB 泄漏),长时间运行会耗尽 PID/任务表容量。建议恢复 parent_pid==0 分支的即时回收(ReapTask),或引入等价的后台回收机制并确保不会与 Wait 的回收重复。
src/task/exit.cpp:1 - 当 parent_pid == 0 时,Exit 仅把任务置为 kExited,但不再像旧逻辑那样立即 ReapTask();这会导致“无父进程/孤儿”的任务永远留在 task_table_(资源与 TCB 泄漏),长时间运行会耗尽 PID/任务表容量。建议恢复 parent_pid==0 分支的即时回收(ReapTask),或引入等价的后台回收机制并确保不会与 Wait 的回收重复。
src/task/exit.cpp:1 - 当 parent_pid == 0 时,Exit 仅把任务置为 kExited,但不再像旧逻辑那样立即 ReapTask();这会导致“无父进程/孤儿”的任务永远留在 task_table_(资源与 TCB 泄漏),长时间运行会耗尽 PID/任务表容量。建议恢复 parent_pid==0 分支的即时回收(ReapTask),或引入等价的后台回收机制并确保不会与 Wait 的回收重复。
src/task/exit.cpp:1 - 当 parent_pid == 0 时,Exit 仅把任务置为 kExited,但不再像旧逻辑那样立即 ReapTask();这会导致“无父进程/孤儿”的任务永远留在 task_table_(资源与 TCB 泄漏),长时间运行会耗尽 PID/任务表容量。建议恢复 parent_pid==0 分支的即时回收(ReapTask),或引入等价的后台回收机制并确保不会与 Wait 的回收重复。
src/task/wait.cpp:1 - Wait 试图通过“持 cpu_sched.lock + task_table_lock_ 时 Block”来避免丢失唤醒,但当前 Exit() 在唤醒父进程时并未持有 task_table_lock_(且 Wakeup 在锁外跨核扫描)。当父子在不同核上并发时,存在经典竞态:父进程完成扫描但尚未入 blocked_tasks,子进程 Exit→Wakeup 先发生且未看到等待者,随后父进程 Block 并永久睡眠。建议让 Exit 在决定进入 zombie/唤醒父进程时也参与同一同步机制(例如在持 task_table_lock_ 的临界区内触发唤醒,或引入专用 wait-queue 锁/条件变量式序列号),从根因上消除 missed wakeup。
src/task/wait.cpp:1 - Wait 试图通过“持 cpu_sched.lock + task_table_lock_ 时 Block”来避免丢失唤醒,但当前 Exit() 在唤醒父进程时并未持有 task_table_lock_(且 Wakeup 在锁外跨核扫描)。当父子在不同核上并发时,存在经典竞态:父进程完成扫描但尚未入 blocked_tasks,子进程 Exit→Wakeup 先发生且未看到等待者,随后父进程 Block 并永久睡眠。建议让 Exit 在决定进入 zombie/唤醒父进程时也参与同一同步机制(例如在持 task_table_lock_ 的临界区内触发唤醒,或引入专用 wait-queue 锁/条件变量式序列号),从根因上消除 missed wakeup。
src/task/signal.cpp:1 - SendSignal 在未持有目标任务所属 cpu_sched.lock(或其他保护锁)的情况下读取/写入多个非原子字段(如 aux->blocked_on、sched_info.wake_tick),并基于 GetStatus() 的瞬时值执行 Wakeup()。这会引入数据竞争与状态撕裂风险(blocked_on 可能同时被 Block/Wakeup 修改,sleep 队列也可能并发维护)。建议:在定位到 target 后,按任务所属调度器的锁粒度获取相应 cpu_sched.lock,再读取 blocked_on / 修改 wake_tick 并执行唤醒;或将 blocked_on/wake_tick 设计为原子并配套必要的内存序与队列一致性策略。
src/arch/riscv64/macro.S:1 - RISC-V Trap/CalleeSaved 上下文同样移除了浮点寄存器与 fcsr 的保存/恢复。除非内核与用户态都被强约束为不使用 FPU(并且 toolchain 不会生成相关指令),否则会在中断返回/上下文切换后出现寄存器破坏。建议与 aarch64 一样:明确通过编译参数/ABI 禁用浮点,或恢复保存/恢复逻辑并确保与 cpu_io::TrapContext/CalleeSavedContext 布局一致。
src/arch/riscv64/macro.S:1 - RISC-V Trap/CalleeSaved 上下文同样移除了浮点寄存器与 fcsr 的保存/恢复。除非内核与用户态都被强约束为不使用 FPU(并且 toolchain 不会生成相关指令),否则会在中断返回/上下文切换后出现寄存器破坏。建议与 aarch64 一样:明确通过编译参数/ABI 禁用浮点,或恢复保存/恢复逻辑并确保与 cpu_io::TrapContext/CalleeSavedContext 布局一致。
src/filesystem/vfs/open.cpp:1 - Open 失败路径目前仅执行 dentry->ref_count-- 与 delete file,但未展示与 dentry/inode 引用管理一致的“统一释放路径”(例如是否需要回滚 inode/dentry 的其他引用/状态、或需要调用与成功路径对称的清理逻辑)。建议将失败回滚封装为与 Close/PutDentry 等一致的 helper(或复用现有释放函数),避免未来在 Open 逻辑继续扩展时遗漏回滚步骤导致 ref_count 泄漏或双重释放。
| name: build | ||
|
|
||
| on: | ||
| - push | ||
| - pull_request | ||
| - release | ||
| push: | ||
| pull_request: | ||
| release: | ||
| types: [published] |
There was a problem hiding this comment.
PR 描述聚焦于 CI 性能优化,但该 PR 同时包含大量内核功能变更(信号机制、Wait/Exit 并发语义调整)、系统测试大规模新增、以及 x86_64 架构与相关构建/文档的整体移除。这会显著增加 review 与回滚成本;建议将 CI/workflow 变更与内核/架构变更拆分为独立 PR,或至少在 PR 描述中明确列出这些非 CI 范畴的重大改动与迁移影响。
| cpu_io::ICC_EOIR1_EL1::Write(cause); | ||
| interrupt_handlers_[cause](cause, context); |
There was a problem hiding this comment.
GICv3 通常应在完成中断处理后再写 EOIR(或至少在完成需要保持 active 状态的处理后再 de-activate),否则可能导致同一中断在 handler 期间被重新触发,出现重入/丢事件等异常行为。建议将 cpu_io::ICC_EOIR1_EL1::Write(cause) 移回 handler 调用之后,或明确采用“early EOI”策略并在注释中说明其正确性前提(例如: edge-triggered、handler 不会依赖 active 状态)。
| cpu_io::ICC_EOIR1_EL1::Write(cause); | |
| interrupt_handlers_[cause](cause, context); | |
| interrupt_handlers_[cause](cause, context); | |
| cpu_io::ICC_EOIR1_EL1::Write(cause); |
| TaskManagerSingleton::instance().TickUpdate(); | ||
| auto& tm = TaskManagerSingleton::instance(); | ||
| tm.TickUpdate(); | ||
| (void)tm.CheckPendingSignals(); |
There was a problem hiding this comment.
在定时器中断上下文里调用 CheckPendingSignals() 风险很高:CheckPendingSignals 可能触发 Exit()(进而 Schedule() 等),通常不应在 IRQ handler 中执行会改变当前任务/调度状态的逻辑,否则容易导致中断重入、锁顺序破坏或在 trap context 尚未完成恢复时切换任务。建议将信号投递检查移动到“安全点”(例如从中断返回到内核/用户态的路径、或调度点 Schedule() 前后),在 IRQ handler 中仅设置标志位/记录 pending 状态。
| (void)tm.CheckPendingSignals(); |
| * @brief TrapContext 结构体大小 | ||
| */ | ||
| .equ kTrapContextSize, 896 | ||
| .equ kTrapContextSize, 320 |
There was a problem hiding this comment.
该改动将 TrapContext 从 896 缩减到 320,并移除了对浮点/SIMD(q0-q31、fpsr/fpcr 等)的保存/恢复。如果内核/用户态任一部分使用了 FP/NEON(哪怕是编译器自动生成的 memcpy/优化路径),中断/异常与任务切换将破坏寄存器内容,导致不可预测错误。建议:要么在全局编译选项中明确禁止生成 FP/NEON 指令并保证所有依赖也满足(并在构建系统/文档中注明);要么恢复对 FP/SIMD 上下文的保存/恢复,或实现 lazy-FPU 策略。
| // 分配栈空间 (320 字节) | ||
| sub sp, sp, #kTrapContextSize |
There was a problem hiding this comment.
该改动将 TrapContext 从 896 缩减到 320,并移除了对浮点/SIMD(q0-q31、fpsr/fpcr 等)的保存/恢复。如果内核/用户态任一部分使用了 FP/NEON(哪怕是编译器自动生成的 memcpy/优化路径),中断/异常与任务切换将破坏寄存器内容,导致不可预测错误。建议:要么在全局编译选项中明确禁止生成 FP/NEON 指令并保证所有依赖也满足(并在构建系统/文档中注明);要么恢复对 FP/SIMD 上下文的保存/恢复,或实现 lazy-FPU 策略。
| // 偏移 784-831: _padding1 (不需要显式保存) | ||
|
|
||
| // 保存系统寄存器 (偏移 832-895,相对 x28 偏移 64-127) | ||
| // 保存系统寄存器 (偏移 256-319) |
There was a problem hiding this comment.
该改动将 TrapContext 从 896 缩减到 320,并移除了对浮点/SIMD(q0-q31、fpsr/fpcr 等)的保存/恢复。如果内核/用户态任一部分使用了 FP/NEON(哪怕是编译器自动生成的 memcpy/优化路径),中断/异常与任务切换将破坏寄存器内容,导致不可预测错误。建议:要么在全局编译选项中明确禁止生成 FP/NEON 指令并保证所有依赖也满足(并在构建系统/文档中注明);要么恢复对 FP/SIMD 上下文的保存/恢复,或实现 lazy-FPU 策略。
| cmake --preset=build_x86_64 | ||
| cmake --build build_x86_64 --target SimpleKernel unit-test coverage docs | ||
| path: build_riscv64/ | ||
| key: cmake-riscv64-${{ runner.arch }}-${{ hashFiles('CMakeLists.txt', 'cmake/**', 'src/**') }} |
There was a problem hiding this comment.
当前缓存 key 将 'src/' 全量纳入 hashFiles,意味着几乎任意源码改动都会导致缓存完全失效,从而降低“增量编译缓存”的命中率与收益。更可维护/更高命中率的做法通常是:缓存更细粒度(例如 ccache 或 Conan/vcpkg 产物),或只对会影响构建系统配置的文件生成 key(CMakeLists/cmake/ + toolchain + 3rd 依赖版本),再用 restore-keys 做回退。
| key: cmake-riscv64-${{ runner.arch }}-${{ hashFiles('CMakeLists.txt', 'cmake/**', 'src/**') }} | |
| key: cmake-riscv64-${{ runner.arch }}-${{ hashFiles('CMakeLists.txt', 'cmake/**') }} |
Summary
CI 流程优化,通过并行化、预构建镜像、缓存和浅克隆大幅减少 CI 耗时。
Changes
workflow.yml— 主构建 workflow 重写build-riscv64+build-aarch64并行执行,publish等待两者完成container: ghcr.io/simple-xx/simplekernel-dev:latest替代每个 step 调用devcontainers/ci@v0.3,消除重复容器启动开销fetch-depth: 1+git submodule update --depth 1,减少 git clone 时间actions/cache@v4缓存build_{arch}/目录,支持增量编译codecov-actionv3→v4,actions-gh-pagesv3→v4dev-image.yml— 新增 Docker 镜像构建 workflow.devcontainer/Dockerfile或自身变更时触发,支持workflow_dispatch手动触发ghcr.io/simple-xx/simplekernel-dev:latest和:<sha>双 tagExpected Impact
Note
首次合并后需手动触发一次
dev-imageworkflow(Actions → dev-image → Run workflow)来构建初始镜像,之后buildworkflow 才能正常拉取容器。