scx_layered: Add stats for XLLC/XNUMA preemptions

Add stats for XLLC/XNUMA preemptions.

Signed-off-by: Daniel Hodges <hodges.daniel.scott@gmail.com>
This commit is contained in:
Daniel Hodges 2024-09-19 09:31:18 -04:00
parent c15ecbb3a4
commit 5d9d32b65c
No known key found for this signature in database
GPG Key ID: D295F6D6F3E97B18
4 changed files with 1665 additions and 1 deletions

1645
rust/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,8 @@ enum layer_stat_idx {
LSTAT_KEEP_FAIL_BUSY,
LSTAT_PREEMPT,
LSTAT_PREEMPT_FIRST,
LSTAT_PREEMPT_XLLC,
LSTAT_PREEMPT_XNUMA,
LSTAT_PREEMPT_IDLE,
LSTAT_PREEMPT_FAIL,
LSTAT_EXCL_COLLISION,

View File

@ -883,6 +883,7 @@ find_cpu:
if (try_preempt(preempt_cpu, p, cctx, tctx, layer, false)) {
bpf_cpumask_release(attempted);
bpf_cpumask_release(topo_cpus);
lstat_inc(LSTAT_PREEMPT_XLLC, layer, cctx);
return;
}
bpf_cpumask_clear_cpu(preempt_cpu, topo_cpus);
@ -909,6 +910,7 @@ find_cpu:
if (try_preempt(preempt_cpu, p, cctx, tctx, layer, false)) {
bpf_cpumask_release(attempted);
bpf_cpumask_release(topo_cpus);
lstat_inc(LSTAT_PREEMPT_XNUMA, layer, cctx);
return;
}
bpf_cpumask_clear_cpu(preempt_cpu, topo_cpus);
@ -929,6 +931,13 @@ find_cpu:
* not bother with atomic ops on $preempt_cursor.
*/
preempt_cursor = (cand + 1) % nr_possible_cpus;
struct cpu_ctx *new_cctx;
if ((new_cctx = lookup_cpu_ctx(cand))) {
if (new_cctx->node_idx != nodec->id && new_cctx->node_idx == nodec->id)
lstat_inc(LSTAT_PREEMPT_XLLC, layer, cctx);
if (new_cctx->node_idx != nodec->id)
lstat_inc(LSTAT_PREEMPT_XLLC, layer, cctx);
}
return;
}
}

View File

@ -75,6 +75,10 @@ pub struct LayerStats {
pub open_idle: f64,
#[stat(desc = "% preempted other tasks")]
pub preempt: f64,
#[stat(desc = "% preempted XLLC tasks")]
pub preempt_xllc: f64,
#[stat(desc = "% preempted XNUMA tasks")]
pub preempt_xnuma: f64,
#[stat(desc = "% first-preempted other tasks")]
pub preempt_first: f64,
#[stat(desc = "% idle-preempted other tasks")]
@ -178,6 +182,8 @@ impl LayerStats {
min_exec_us: (lstat(bpf_intf::layer_stat_idx_LSTAT_MIN_EXEC_NS) / 1000) as u64,
open_idle: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_OPEN_IDLE),
preempt: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT),
preempt_xllc: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT_XLLC),
preempt_xnuma: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT_XNUMA),
preempt_first: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT_FIRST),
preempt_idle: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT_IDLE),
preempt_fail: lstat_pct(bpf_intf::layer_stat_idx_LSTAT_PREEMPT_FAIL),
@ -253,10 +259,12 @@ impl LayerStats {
writeln!(
w,
" {:<width$} preempt/first/idle/fail={}/{}/{}/{} min_exec={}/{:7.2}ms",
" {:<width$} preempt/first/xllc/xnuma/idle/fail={}/{}/{}/{}/{}/{} min_exec={}/{:7.2}ms",
"",
fmt_pct(self.preempt),
fmt_pct(self.preempt_first),
fmt_pct(self.preempt_xllc),
fmt_pct(self.preempt_xnuma),
fmt_pct(self.preempt_idle),
fmt_pct(self.preempt_fail),
fmt_pct(self.min_exec),