scx_rustland_core: export counter of online CPUs

Introduce a helper to get the amount of online CPUs tracked by the BPF
part.

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
This commit is contained in:
Andrea Righi 2024-08-05 21:07:22 +02:00
parent d9c9f78e3e
commit 9a0e7755df
2 changed files with 9 additions and 2 deletions

View File

@ -302,6 +302,12 @@ impl<'cb> BpfScheduler<'cb> {
} }
} }
// Counter of the online CPUs.
#[allow(dead_code)]
pub fn nr_online_cpus_mut(&mut self) -> &mut u64 {
&mut self.skel.bss_mut().nr_online_cpus
}
// Counter of currently running tasks. // Counter of currently running tasks.
#[allow(dead_code)] #[allow(dead_code)]
pub fn nr_running_mut(&mut self) -> &mut u64 { pub fn nr_running_mut(&mut self) -> &mut u64 {

View File

@ -582,9 +582,10 @@ impl<'a> Scheduler<'a> {
// Print internal scheduler statistics (fetched from the BPF part). // Print internal scheduler statistics (fetched from the BPF part).
fn print_stats(&mut self) { fn print_stats(&mut self) {
// Show minimum vruntime (this should be constantly incrementing). // Show online CPUs, minimum vruntime and time slice.
info!( info!(
"min_vruntime={} slice={}us", "cpus={} min_vruntime={} slice={}us",
*self.bpf.nr_online_cpus_mut(),
self.min_vruntime, self.min_vruntime,
self.slice_ns / NSEC_PER_USEC, self.slice_ns / NSEC_PER_USEC,
); );