From 02d943110ee75b132f18be9caef2fa7f93a47a56 Mon Sep 17 00:00:00 2001 From: li041 Date: Wed, 10 Dec 2025 20:50:09 +0800 Subject: [PATCH 01/10] feat(axfeat): tie ipi to smp feature --- api/axfeat/Cargo.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/axfeat/Cargo.toml b/api/axfeat/Cargo.toml index 875d302d0a..207000c86f 100644 --- a/api/axfeat/Cargo.toml +++ b/api/axfeat/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://arceos-org.github.io/arceos/axfeat/index.html" default = [] # Multicore -smp = ["axhal/smp", "axruntime/smp", "axtask?/smp", "kspin/smp"] +smp = ["axhal/smp", "axruntime/smp", "axtask?/smp", "kspin/smp", "axmm/smp", "axipi/smp", "ipi"] # Floating point/SIMD fp-simd = ["axhal/fp-simd"] @@ -116,7 +116,8 @@ axinput = { workspace = true, optional = true } axipi = { workspace = true, optional = true } axlog.workspace = true axnet = { workspace = true, optional = true } -axruntime.workspace = true +axmm = {workspace = true, optional = true} +axruntime = { workspace = true } axsync = { workspace = true, optional = true } axtask = { workspace = true, optional = true } kspin = { workspace = true, optional = true } From fad5887c4d623e06009d84ade56a175102e2ac5d Mon Sep 17 00:00:00 2001 From: li041 Date: Wed, 10 Dec 2025 21:23:35 +0800 Subject: [PATCH 02/10] feat(tlb): add sync mechanism for ipi and support lazy flush tlb --- modules/axipi/Cargo.toml | 5 + modules/axipi/src/event.rs | 3 + modules/axipi/src/lib.rs | 186 ++++++++++++++++++++++++++++++++--- modules/axipi/src/queue.rs | 17 +++- modules/axipi/src/tlb.rs | 30 ++++++ modules/axmm/Cargo.toml | 1 + modules/axruntime/src/lib.rs | 11 ++- modules/axtask/src/task.rs | 3 + 8 files changed, 236 insertions(+), 20 deletions(-) create mode 100644 modules/axipi/src/tlb.rs diff --git a/modules/axipi/Cargo.toml b/modules/axipi/Cargo.toml index 54e0ba12ea..76b7b71ebd 100644 --- a/modules/axipi/Cargo.toml +++ b/modules/axipi/Cargo.toml @@ -11,6 +11,7 @@ documentation = "https://arceos-org.github.io/arceos/axipi/index.html" [features] default = [] +smp = [] [dependencies] axconfig.workspace = true @@ -19,3 +20,7 @@ kspin.workspace = true lazyinit.workspace = true log.workspace = true percpu.workspace = true +crate_interface = "0.1.4" +axcpu = { git = "https://github.com/arceos-org/axcpu.git", tag = "dev-v03" } +axtask = { workspace = true, features = ["task-ext"] } +page_table_multiarch.workspace = true \ No newline at end of file diff --git a/modules/axipi/src/event.rs b/modules/axipi/src/event.rs index 1c33982245..0c61f00354 100644 --- a/modules/axipi/src/event.rs +++ b/modules/axipi/src/event.rs @@ -1,4 +1,5 @@ use alloc::{boxed::Box, sync::Arc}; +use core::sync::atomic::AtomicBool; /// A callback function that will be called when an [`IpiEvent`] is received and handled. pub struct Callback(Box); @@ -50,8 +51,10 @@ impl From for MulticastCallback { /// An IPI event that is sent from a source CPU to the target CPU. pub struct IpiEvent { + pub name: &'static str, /// The source CPU ID that sent the IPI event. pub src_cpu_id: usize, /// The callback function that will be called when the IPI event is handled. pub callback: Callback, + pub done: Option>, } diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index 178e5187f8..3bde5ee9f8 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -6,16 +6,34 @@ extern crate log; extern crate alloc; -use axhal::irq::{IPI_IRQ, IpiTarget}; -use axhal::percpu::this_cpu_id; +use alloc::{sync::Arc, vec::Vec}; +use core::sync::atomic::{AtomicBool, Ordering}; + +use axhal::{ + irq::{IPI_IRQ, IpiTarget}, + percpu::this_cpu_id, +}; +use axtask::AxCpuMask; use kspin::SpinNoIrq; use lazyinit::LazyInit; +use queue::IpiEventQueue; + +use crate::event::{Callback, MulticastCallback}; mod event; mod queue; +#[cfg(feature = "smp")] +mod tlb; -pub use event::{Callback, MulticastCallback}; -use queue::IpiEventQueue; +static SECONDARY_CPUS_STARTED: AtomicBool = AtomicBool::new(false); + +pub fn start_secondary_cpus_done() { + SECONDARY_CPUS_STARTED.store(true, Ordering::Release); +} + +pub fn secondary_cpus_ready() -> bool { + SECONDARY_CPUS_STARTED.load(Ordering::Acquire) +} #[percpu::def_percpu] static IPI_EVENT_QUEUE: LazyInit> = LazyInit::new(); @@ -28,21 +46,136 @@ pub fn init() { } /// Executes a callback on the specified destination CPU via IPI. -pub fn run_on_cpu>(dest_cpu: usize, callback: T) { - info!("Send IPI event to CPU {dest_cpu}"); +pub fn run_on_cpu>(name: &'static str, dest_cpu: usize, callback: T, wait: bool) { + info!("Send IPI event to CPU {}", dest_cpu); if dest_cpu == this_cpu_id() { // Execute callback on current CPU immediately callback.into().call(); } else { + let done_flag = if wait { + Some(Arc::new(AtomicBool::new(false))) + } else { + None + }; unsafe { IPI_EVENT_QUEUE.remote_ref_raw(dest_cpu) } .lock() - .push(this_cpu_id(), callback.into()); + .push(name, this_cpu_id(), callback.into(), done_flag.clone()); axhal::irq::send_ipi(IPI_IRQ, IpiTarget::Other { cpu_id: dest_cpu }); + if wait { + if let Some(df) = done_flag { + while !df.load(Ordering::Acquire) { + core::hint::spin_loop(); + } + } + } + } +} + +pub fn run_on_bitmask_except_self>( + name: &'static str, + callback: T, + cpu_mask: AxCpuMask, + wait: bool, +) { + let current_cpu_id = this_cpu_id(); + let cpu_num = axconfig::plat::CPU_NUM; + let callback = callback.into(); + + let mut done_flags: Vec> = Vec::new(); + + for cpu_id in 0..cpu_num { + if cpu_id != current_cpu_id && cpu_mask.get(cpu_id) { + let done_flag = if wait { + Some(Arc::new(AtomicBool::new(false))) + } else { + None + }; + if let Some(df) = &done_flag { + done_flags.push(df.clone()); + } + + unsafe { IPI_EVENT_QUEUE.remote_ref_raw(cpu_id) } + .lock() + .push( + name, + current_cpu_id, + callback.clone().into_unicast(), + done_flag, + ); + } + } + if done_flags.is_empty() { + return; + } + for cpu_id in 0..cpu_num { + if cpu_id != current_cpu_id && cpu_mask.get(cpu_id) { + axhal::irq::send_ipi(IPI_IRQ, IpiTarget::Other { cpu_id }); + } + } + if wait { + for df in done_flags { + while !df.load(Ordering::Acquire) { + core::hint::spin_loop(); + } + } + } +} + +pub fn run_on_each_cpu_except_self>( + name: &'static str, + callback: T, + wait: bool, +) { + let current_cpu_id = this_cpu_id(); + let cpu_num = axconfig::plat::CPU_NUM; + let callback = callback.into(); + + let mut done_flags: Vec> = Vec::new(); + + // Push the callback to all other CPUs' IPI event queues + for cpu_id in 0..cpu_num { + if cpu_id != current_cpu_id { + let done_flag = if wait { + Some(Arc::new(AtomicBool::new(false))) + } else { + None + }; + if let Some(df) = &done_flag { + done_flags.push(df.clone()); + } + + unsafe { IPI_EVENT_QUEUE.remote_ref_raw(cpu_id) } + .lock() + .push( + name, + current_cpu_id, + callback.clone().into_unicast(), + done_flag, + ); + } + } + if done_flags.is_empty() { + return; + } + // Send IPI to all other CPUs to trigger their callbacks + axhal::irq::send_ipi( + IPI_IRQ, + IpiTarget::AllExceptCurrent { + cpu_id: current_cpu_id, + cpu_num, + }, + ); + if wait { + for df in done_flags { + while !df.load(Ordering::Acquire) { + core::hint::spin_loop(); + } + } } } /// Executes a callback on all other CPUs via IPI. -pub fn run_on_each_cpu>(callback: T) { +pub fn run_on_each_cpu>(name: &'static str, callback: T, wait: bool) { info!("Send IPI event to all other CPUs"); let current_cpu_id = this_cpu_id(); let cpu_num = axconfig::plat::CPU_NUM; @@ -50,12 +183,27 @@ pub fn run_on_each_cpu>(callback: T) { // Execute callback on current CPU immediately callback.clone().call(); + + let mut done_flags: Vec> = Vec::new(); // Push the callback to all other CPUs' IPI event queues for cpu_id in 0..cpu_num { if cpu_id != current_cpu_id { + let done_flag = if wait { + Some(Arc::new(AtomicBool::new(false))) + } else { + None + }; + if let Some(df) = &done_flag { + done_flags.push(df.clone()); + } unsafe { IPI_EVENT_QUEUE.remote_ref_raw(cpu_id) } .lock() - .push(current_cpu_id, callback.clone().into_unicast()); + .push( + name, + current_cpu_id, + callback.clone().into_unicast(), + done_flag, + ); } } // Send IPI to all other CPUs to trigger their callbacks @@ -66,15 +214,27 @@ pub fn run_on_each_cpu>(callback: T) { cpu_num, }, ); + if wait { + for df in done_flags { + while !df.load(Ordering::Acquire) { + core::hint::spin_loop(); + } + } + } } -/// The handler for IPI events. It retrieves the events from the queue and calls the corresponding callbacks. +/// The handler for IPI events. It retrieves the events from the queue and calls +/// the corresponding callbacks. pub fn ipi_handler() { - while let Some((src_cpu_id, callback)) = unsafe { IPI_EVENT_QUEUE.current_ref_mut_raw() } - .lock() - .pop_one() + while let Some((_name, src_cpu_id, callback, done)) = + unsafe { IPI_EVENT_QUEUE.current_ref_raw() } + .lock() + .pop_one() { debug!("Received IPI event from CPU {src_cpu_id}"); callback.call(); + if let Some(done) = done { + done.store(true, Ordering::Release); + } } } diff --git a/modules/axipi/src/queue.rs b/modules/axipi/src/queue.rs index d11f5c541b..271ac03de5 100644 --- a/modules/axipi/src/queue.rs +++ b/modules/axipi/src/queue.rs @@ -1,4 +1,5 @@ -use alloc::collections::VecDeque; +use alloc::{collections::VecDeque, sync::Arc}; +use core::sync::atomic::AtomicBool; use crate::event::{Callback, IpiEvent}; @@ -26,10 +27,18 @@ impl IpiEventQueue { } /// Push a new event into the queue. - pub fn push(&mut self, src_cpu_id: usize, callback: Callback) { + pub fn push( + &mut self, + name: &'static str, + src_cpu_id: usize, + callback: Callback, + done: Option>, + ) { self.events.push_back(IpiEvent { + name, src_cpu_id, callback, + done, }); } @@ -37,9 +46,9 @@ impl IpiEventQueue { /// /// Return `None` if no event is available. #[must_use] - pub fn pop_one(&mut self) -> Option<(usize, Callback)> { + pub fn pop_one(&mut self) -> Option<(&'static str, usize, Callback, Option>)> { if let Some(e) = self.events.pop_front() { - Some((e.src_cpu_id, e.callback)) + Some((e.name, e.src_cpu_id, e.callback, e.done)) } else { None } diff --git a/modules/axipi/src/tlb.rs b/modules/axipi/src/tlb.rs new file mode 100644 index 0000000000..64e3414da0 --- /dev/null +++ b/modules/axipi/src/tlb.rs @@ -0,0 +1,30 @@ +use axhal::mem::VirtAddr; +use axtask::{TaskExt, current}; +use page_table_multiarch::TlbFlushIf; + +use crate::{ + MulticastCallback, run_on_bitmask_except_self, run_on_each_cpu_except_self, + secondary_cpus_ready, this_cpu_id, +}; + +struct TlbFlushImpl; + +#[crate_interface::impl_interface] +impl TlbFlushIf for TlbFlushImpl { + fn flush_all(vaddr: Option) { + if axconfig::plat::CPU_NUM == 1 || !secondary_cpus_ready() { + // local + axhal::asm::flush_tlb(None); + } else { + let callback = MulticastCallback::new(move || { + axhal::asm::flush_tlb(vaddr); + }); + if let Some(ext) = current().task_ext() { + let on_cpu_mask = ext.on_cpu_mask(); + run_on_bitmask_except_self("flush", callback, on_cpu_mask, true); + } else { + run_on_each_cpu_except_self("flush", callback, true); + } + } + } +} diff --git a/modules/axmm/Cargo.toml b/modules/axmm/Cargo.toml index 760d7f7d6c..3a14815d3c 100644 --- a/modules/axmm/Cargo.toml +++ b/modules/axmm/Cargo.toml @@ -12,6 +12,7 @@ documentation = "https://arceos-org.github.io/arceos/axmm/index.html" [features] default = [] copy = ["page_table_multiarch/copy-from"] +smp = ["page_table_multiarch/smp"] [dependencies] axalloc = { workspace = true } diff --git a/modules/axruntime/src/lib.rs b/modules/axruntime/src/lib.rs index 4bccbaa64d..462c8ac89c 100644 --- a/modules/axruntime/src/lib.rs +++ b/modules/axruntime/src/lib.rs @@ -230,6 +230,8 @@ pub fn rust_main(cpu_id: usize, arg: usize) -> ! { while !is_init_ok() { core::hint::spin_loop(); } + #[cfg(all(feature = "smp", feature = "ipi"))] + axipi::start_secondary_cpus_done(); unsafe { main() }; @@ -300,9 +302,12 @@ fn init_interrupt() { }); #[cfg(feature = "ipi")] - axhal::irq::register(axhal::irq::IPI_IRQ, || { - axipi::ipi_handler(); - }); + { + axipi::init(); + axhal::irq::register(axhal::irq::IPI_IRQ, || { + axipi::ipi_handler(); + }); + } // Enable IRQs before starting app axhal::asm::enable_irqs(); diff --git a/modules/axtask/src/task.rs b/modules/axtask/src/task.rs index d61b8da7ad..c8aab652c5 100644 --- a/modules/axtask/src/task.rs +++ b/modules/axtask/src/task.rs @@ -54,6 +54,9 @@ pub unsafe trait TaskExt { fn on_enter(&self) {} /// Called when the task is switched out. fn on_leave(&self) {} + fn on_cpu_mask(&self) -> AxCpuMask { + AxCpuMask::new() + } } /// The inner task structure. From 3631e25d523d20455ebac54bc35663c0803925e8 Mon Sep 17 00:00:00 2001 From: li041 Date: Tue, 23 Dec 2025 15:02:35 +0800 Subject: [PATCH 03/10] rm unused import --- modules/axipi/src/tlb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/axipi/src/tlb.rs b/modules/axipi/src/tlb.rs index 64e3414da0..9a66ca7e43 100644 --- a/modules/axipi/src/tlb.rs +++ b/modules/axipi/src/tlb.rs @@ -4,7 +4,7 @@ use page_table_multiarch::TlbFlushIf; use crate::{ MulticastCallback, run_on_bitmask_except_self, run_on_each_cpu_except_self, - secondary_cpus_ready, this_cpu_id, + secondary_cpus_ready, }; struct TlbFlushImpl; From 5d5490ec2ac57a7b1f8f7f9fd8f350b068bcf507 Mon Sep 17 00:00:00 2001 From: li041 Date: Tue, 23 Dec 2025 15:13:39 +0800 Subject: [PATCH 04/10] task copilot advice --- modules/axipi/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index 3bde5ee9f8..d6da1cb059 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -104,9 +104,6 @@ pub fn run_on_bitmask_except_self>( ); } } - if done_flags.is_empty() { - return; - } for cpu_id in 0..cpu_num { if cpu_id != current_cpu_id && cpu_mask.get(cpu_id) { axhal::irq::send_ipi(IPI_IRQ, IpiTarget::Other { cpu_id }); From 7d3fbc589753c96849e250789190bc35c9000bee Mon Sep 17 00:00:00 2001 From: li041 Date: Tue, 23 Dec 2025 15:17:13 +0800 Subject: [PATCH 05/10] pre-alloc with cpu num for `done_flags` --- modules/axipi/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index d6da1cb059..a3dcdf603f 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -81,7 +81,7 @@ pub fn run_on_bitmask_except_self>( let cpu_num = axconfig::plat::CPU_NUM; let callback = callback.into(); - let mut done_flags: Vec> = Vec::new(); + let mut done_flags: Vec> = Vec::new(cpu_num - 1); for cpu_id in 0..cpu_num { if cpu_id != current_cpu_id && cpu_mask.get(cpu_id) { @@ -127,7 +127,7 @@ pub fn run_on_each_cpu_except_self>( let cpu_num = axconfig::plat::CPU_NUM; let callback = callback.into(); - let mut done_flags: Vec> = Vec::new(); + let mut done_flags: Vec> = Vec::new(cpu_num - 1); // Push the callback to all other CPUs' IPI event queues for cpu_id in 0..cpu_num { @@ -181,7 +181,7 @@ pub fn run_on_each_cpu>(name: &'static str, callback: // Execute callback on current CPU immediately callback.clone().call(); - let mut done_flags: Vec> = Vec::new(); + let mut done_flags: Vec> = Vec::new(cpu_num); // Push the callback to all other CPUs' IPI event queues for cpu_id in 0..cpu_num { if cpu_id != current_cpu_id { From 12e5fb5c7fd3d21d582dbab6474bcbcd115bedc0 Mon Sep 17 00:00:00 2001 From: li041 Date: Tue, 23 Dec 2025 17:10:09 +0800 Subject: [PATCH 06/10] rm unnecessary check for `done_flags` --- modules/axipi/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index a3dcdf603f..e670f85696 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -151,9 +151,6 @@ pub fn run_on_each_cpu_except_self>( ); } } - if done_flags.is_empty() { - return; - } // Send IPI to all other CPUs to trigger their callbacks axhal::irq::send_ipi( IPI_IRQ, From 69d207311353baed1b2be0d03409a469c8f1087e Mon Sep 17 00:00:00 2001 From: li041 Date: Tue, 23 Dec 2025 19:30:31 +0800 Subject: [PATCH 07/10] fix vec init --- modules/axipi/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index e670f85696..351dabae1c 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -81,7 +81,7 @@ pub fn run_on_bitmask_except_self>( let cpu_num = axconfig::plat::CPU_NUM; let callback = callback.into(); - let mut done_flags: Vec> = Vec::new(cpu_num - 1); + let mut done_flags: Vec> = Vec::with_capacity(cpu_num - 1); for cpu_id in 0..cpu_num { if cpu_id != current_cpu_id && cpu_mask.get(cpu_id) { @@ -127,7 +127,7 @@ pub fn run_on_each_cpu_except_self>( let cpu_num = axconfig::plat::CPU_NUM; let callback = callback.into(); - let mut done_flags: Vec> = Vec::new(cpu_num - 1); + let mut done_flags: Vec> = Vec::with_capacity(cpu_num - 1); // Push the callback to all other CPUs' IPI event queues for cpu_id in 0..cpu_num { @@ -178,7 +178,7 @@ pub fn run_on_each_cpu>(name: &'static str, callback: // Execute callback on current CPU immediately callback.clone().call(); - let mut done_flags: Vec> = Vec::new(cpu_num); + let mut done_flags: Vec> = Vec::with_capacity(cpu_num); // Push the callback to all other CPUs' IPI event queues for cpu_id in 0..cpu_num { if cpu_id != current_cpu_id { From 74e63acd0b862cdc401d620319897529bef18e07 Mon Sep 17 00:00:00 2001 From: li041 Date: Tue, 30 Dec 2025 19:32:40 +0800 Subject: [PATCH 08/10] disable preempt during sending ipi --- modules/axipi/Cargo.toml | 3 ++- modules/axipi/src/lib.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/axipi/Cargo.toml b/modules/axipi/Cargo.toml index 76b7b71ebd..142bc4e519 100644 --- a/modules/axipi/Cargo.toml +++ b/modules/axipi/Cargo.toml @@ -23,4 +23,5 @@ percpu.workspace = true crate_interface = "0.1.4" axcpu = { git = "https://github.com/arceos-org/axcpu.git", tag = "dev-v03" } axtask = { workspace = true, features = ["task-ext"] } -page_table_multiarch.workspace = true \ No newline at end of file +page_table_multiarch.workspace = true +kernel_guard = { workspace = true } \ No newline at end of file diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index 351dabae1c..542177e8ae 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -47,6 +47,7 @@ pub fn init() { /// Executes a callback on the specified destination CPU via IPI. pub fn run_on_cpu>(name: &'static str, dest_cpu: usize, callback: T, wait: bool) { + let gurad = kernel_guard::NoPreempt::new(); info!("Send IPI event to CPU {}", dest_cpu); if dest_cpu == this_cpu_id() { // Execute callback on current CPU immediately @@ -69,6 +70,7 @@ pub fn run_on_cpu>(name: &'static str, dest_cpu: usize, callba } } } + drop(gurad); // rescheduling may occur when preemption is re-enabled. } pub fn run_on_bitmask_except_self>( @@ -77,6 +79,7 @@ pub fn run_on_bitmask_except_self>( cpu_mask: AxCpuMask, wait: bool, ) { + let guard = kernel_guard::NoPreempt::new(); let current_cpu_id = this_cpu_id(); let cpu_num = axconfig::plat::CPU_NUM; let callback = callback.into(); @@ -116,6 +119,7 @@ pub fn run_on_bitmask_except_self>( } } } + drop(guard); // rescheduling may occur when preemption is re-enabled. } pub fn run_on_each_cpu_except_self>( @@ -123,6 +127,7 @@ pub fn run_on_each_cpu_except_self>( callback: T, wait: bool, ) { + let guard = kernel_guard::NoPreempt::new(); let current_cpu_id = this_cpu_id(); let cpu_num = axconfig::plat::CPU_NUM; let callback = callback.into(); @@ -166,10 +171,12 @@ pub fn run_on_each_cpu_except_self>( } } } + drop(guard); // rescheduling may occur when preemption is re-enabled. } /// Executes a callback on all other CPUs via IPI. pub fn run_on_each_cpu>(name: &'static str, callback: T, wait: bool) { + let gurad = kernel_guard::NoPreempt::new(); info!("Send IPI event to all other CPUs"); let current_cpu_id = this_cpu_id(); let cpu_num = axconfig::plat::CPU_NUM; @@ -215,6 +222,7 @@ pub fn run_on_each_cpu>(name: &'static str, callback: } } } + drop(gurad); // rescheduling may occur when preemption is re-enabled. } /// The handler for IPI events. It retrieves the events from the queue and calls From c82e4cc895c0018ee53f3d7dc02d722c6ac6a25b Mon Sep 17 00:00:00 2001 From: li041 Date: Wed, 31 Dec 2025 12:50:12 +0800 Subject: [PATCH 09/10] rename functions --- modules/axipi/src/tlb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/axipi/src/tlb.rs b/modules/axipi/src/tlb.rs index 9a66ca7e43..7de09b5623 100644 --- a/modules/axipi/src/tlb.rs +++ b/modules/axipi/src/tlb.rs @@ -11,7 +11,7 @@ struct TlbFlushImpl; #[crate_interface::impl_interface] impl TlbFlushIf for TlbFlushImpl { - fn flush_all(vaddr: Option) { + fn flush_other_cpus(vaddr: Option) { if axconfig::plat::CPU_NUM == 1 || !secondary_cpus_ready() { // local axhal::asm::flush_tlb(None); From 9b530e18de4fe5d24efd05fc947a51162d3b3473 Mon Sep 17 00:00:00 2001 From: li041 Date: Wed, 31 Dec 2025 15:28:43 +0800 Subject: [PATCH 10/10] fix typo --- modules/axipi/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/axipi/src/lib.rs b/modules/axipi/src/lib.rs index 542177e8ae..cffc50a33e 100644 --- a/modules/axipi/src/lib.rs +++ b/modules/axipi/src/lib.rs @@ -47,7 +47,7 @@ pub fn init() { /// Executes a callback on the specified destination CPU via IPI. pub fn run_on_cpu>(name: &'static str, dest_cpu: usize, callback: T, wait: bool) { - let gurad = kernel_guard::NoPreempt::new(); + let guard = kernel_guard::NoPreempt::new(); info!("Send IPI event to CPU {}", dest_cpu); if dest_cpu == this_cpu_id() { // Execute callback on current CPU immediately @@ -70,7 +70,7 @@ pub fn run_on_cpu>(name: &'static str, dest_cpu: usize, callba } } } - drop(gurad); // rescheduling may occur when preemption is re-enabled. + drop(guard); // rescheduling may occur when preemption is re-enabled. } pub fn run_on_bitmask_except_self>( @@ -176,7 +176,7 @@ pub fn run_on_each_cpu_except_self>( /// Executes a callback on all other CPUs via IPI. pub fn run_on_each_cpu>(name: &'static str, callback: T, wait: bool) { - let gurad = kernel_guard::NoPreempt::new(); + let guard = kernel_guard::NoPreempt::new(); info!("Send IPI event to all other CPUs"); let current_cpu_id = this_cpu_id(); let cpu_num = axconfig::plat::CPU_NUM; @@ -222,7 +222,7 @@ pub fn run_on_each_cpu>(name: &'static str, callback: } } } - drop(gurad); // rescheduling may occur when preemption is re-enabled. + drop(guard); // rescheduling may occur when preemption is re-enabled. } /// The handler for IPI events. It retrieves the events from the queue and calls