scx_bpfland: make output more compact

Abbreviate the statistics reported to stdout and remove the slice_ms
metric: this metric can be easily derived from slice_ns, slice_ns_min
and nr_wait, which is already reported to stdout.

Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
This commit is contained in:
Andrea Righi 2024-08-12 14:24:05 +02:00
parent 8656effa50
commit a6e977c70b

View File

@ -166,8 +166,6 @@ struct Scheduler<'a> {
skel: BpfSkel<'a>,
struct_ops: Option<libbpf_rs::Link>,
metrics: Metrics,
slice_ns: u64,
slice_ns_min: u64,
}
impl<'a> Scheduler<'a> {
@ -223,15 +221,9 @@ impl<'a> Scheduler<'a> {
skel,
struct_ops,
metrics: Metrics::new(),
slice_ns: opts.slice_us * 1000,
slice_ns_min: opts.slice_us_min * 1000,
})
}
fn effective_slice(&self, nr_waiting: u64) -> u64 {
std::cmp::max(self.slice_ns / (nr_waiting + 1), self.slice_ns_min)
}
fn update_stats(&mut self) {
let nr_cpus = self.skel.maps.bss_data.nr_online_cpus;
let nr_running = self.skel.maps.bss_data.nr_running;
@ -264,15 +256,13 @@ impl<'a> Scheduler<'a> {
.nr_shared_dispatches
.set(nr_shared_dispatches as f64);
let slice_ms = self.effective_slice(nr_waiting) as f64 / 1_000_000.0;
// Log scheduling statistics.
info!("running: {:>4}/{:<4} interactive: {:<4} wait: {:<4} | slice: {:5.2}ms | nvcsw: {:<4} | direct: {:<6} prio: {:<6} shared: {:<6}",
info!("[{}] tasks -> run: {:>2}/{:<2} int: {:<2} wait: {:<4} | nvcsw: {:<4} | dispatch -> dir: {:<5} prio: {:<5} shr: {:<5}",
SCHEDULER_NAME,
nr_running,
nr_cpus,
nr_interactive,
nr_waiting,
slice_ms,
nvcsw_avg_thresh,
nr_direct_dispatches,
nr_prio_dispatches,