diff --git a/scheds/rust/scx_layered/src/bpf/intf.h b/scheds/rust/scx_layered/src/bpf/intf.h index 493580a..5090c62 100644 --- a/scheds/rust/scx_layered/src/bpf/intf.h +++ b/scheds/rust/scx_layered/src/bpf/intf.h @@ -51,6 +51,7 @@ enum layer_stat_idx { LSTAT_OPEN_IDLE, LSTAT_AFFN_VIOL, LSTAT_PREEMPT, + LSTAT_PREEMPT_FAIL, LSTAT_EXCL_COLLISION, LSTAT_EXCL_PREEMPT, NR_LSTATS, diff --git a/scheds/rust/scx_layered/src/bpf/main.bpf.c b/scheds/rust/scx_layered/src/bpf/main.bpf.c index 19938eb..120b3c0 100644 --- a/scheds/rust/scx_layered/src/bpf/main.bpf.c +++ b/scheds/rust/scx_layered/src/bpf/main.bpf.c @@ -524,8 +524,10 @@ void BPF_STRUCT_OPS(layered_enqueue, struct task_struct *p, u64 enq_flags) preempt_cursor = (cpu + 1) % nr_possible_cpus; lstat_inc(LSTAT_PREEMPT, layer, cctx); - break; + return; } + + lstat_inc(LSTAT_PREEMPT_FAIL, layer, cctx); } void BPF_STRUCT_OPS(layered_dispatch, s32 cpu, struct task_struct *prev) diff --git a/scheds/rust/scx_layered/src/main.rs b/scheds/rust/scx_layered/src/main.rs index 90fe293..32df93c 100644 --- a/scheds/rust/scx_layered/src/main.rs +++ b/scheds/rust/scx_layered/src/main.rs @@ -1093,6 +1093,7 @@ struct OpenMetricsStats { l_min_exec_us: Family, Gauge>, l_open_idle: Family, Gauge>, l_preempt: Family, Gauge>, + l_preempt_fail: Family, Gauge>, l_affn_viol: Family, Gauge>, l_excl_collision: Family, Gauge>, l_excl_preempt: Family, Gauge>, @@ -1175,6 +1176,10 @@ impl OpenMetricsStats { l_preempt, "% of scheduling events that preempted other tasks" ); + register!( + l_preempt_fail, + "% of scheduling events that attempted to preempt other tasks but failed" + ); register!( l_affn_viol, "% of scheduling events that violated configured policies due to CPU affinity restrictions" @@ -1606,6 +1611,10 @@ impl<'a> Scheduler<'a> { lstat_pct(bpf_intf::layer_stat_idx_LSTAT_OPEN_IDLE) ); let l_preempt = set!(l_preempt, lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT)); + let l_preempt_fail = set!( + l_preempt_fail, + lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT_FAIL) + ); let l_affn_viol = set!( l_affn_viol, lstat_pct(bpf_intf::layer_stat_idx_LSTAT_AFFN_VIOL) @@ -1633,15 +1642,23 @@ impl<'a> Scheduler<'a> { width = header_width, ); info!( - " {: Scheduler<'a> { format_bitvec(&layer.cpus), width = header_width ); - match &layer.kind { - LayerKind::Confined { min_exec_us, .. } - | LayerKind::Grouped { min_exec_us, .. } - | LayerKind::Open { min_exec_us, .. } => { - if *min_exec_us > 0 { - info!( - " {: { if *exclusive { @@ -1684,7 +1680,8 @@ impl<'a> Scheduler<'a> { ); } else if l_excl_collision.get() != 0.0 || l_excl_preempt.get() != 0.0 { warn!( - "exclusive is off but excl_coll={} excl_preempt={}", + "{}: exclusive is off but excl_coll={} excl_preempt={}", + spec.name, fmt_pct(l_excl_collision.get()), fmt_pct(l_excl_preempt.get()), );