Conversation
Co-authored-by: lxh <lxh050013@outlook.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a new axplat::percpu module to provide common CPU-local (per-CPU) helpers inside axplat, and updates example kernels to use the new initialization and access APIs (removing the x86_64-specific axcpu::init::init_percpu call in examples).
Changes:
- Add
axplat::percpuwith per-CPUCPU_ID/IS_BSPstorage plusinit_primary/init_secondary. - Update
hello-kernel,irq-kernel, andsmp-kernelexamples to initialize per-CPU state viaaxplat::percpuand read CPU ID viaaxplat::percpu::this_cpu_id(). - Adjust
hello-kernellinker script to includelinkme_*sections and drop the directaxcpudependency for x86_64.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| platforms/axplat-riscv64-qemu-virt/src/irq.rs | Minor import formatting change. |
| examples/smp-kernel/src/irq.rs | Switch timer IRQ log to use axplat::percpu::this_cpu_id(). |
| examples/smp-kernel/src/init.rs | Replace local per-CPU CPU_ID plumbing with axplat::percpu::init_primary/init_secondary. |
| examples/irq-kernel/src/main.rs | Use axplat::percpu::init_primary instead of x86_64-only axcpu percpu init. |
| examples/hello-kernel/src/main.rs | Use axplat::percpu::init_primary unconditionally. |
| examples/hello-kernel/linker.lds.S | Add linkme_* sections (IRQ + PAGE_FAULT) inserted after .data. |
| examples/hello-kernel/Cargo.toml | Remove x86_64-only axcpu dependency. |
| axplat/src/percpu.rs | New per-CPU API surface (CPU ID + BSP flag + init helpers). |
| axplat/src/lib.rs | Export the new percpu module. |
| axplat/Cargo.toml | Add percpu crate dependency. |
| Cargo.lock | Lockfile updates for new dependency graph. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1336243 to
693ab95
Compare
693ab95 to
bcd906b
Compare
| } | ||
| } | ||
|
|
||
| SECTIONS { |
There was a problem hiding this comment.
These sections are unnecessary for hello-kernel.
There was a problem hiding this comment.
Removing it will cause builds to fail on aarch64 and riscv64, just like in https://github.com/arceos-org/axplat_crates/actions/runs/21898792110?pr=42. I don't actually know why.
| #[cfg(feature = "irq")] | ||
| pub mod irq; | ||
| pub mod mem; | ||
| pub mod percpu; |
There was a problem hiding this comment.
Add a feature for percpu? Introducing percpu requires modifying the linker script, which some kernels may not want.
Move part of
axhal::percpufrom ArceOS intoaxplat.Useful for PLIC.
axcpu::init::init_percpu(x86_64) will be removed later.