mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-29 04:40:22 +00:00
scx_layered: Don't call scx_bpf_cpuperf_set() unnecessarily
layered_running() is calling scx_bpf_cpuperf_set() whenever a task of a layer w/ cpuperf setting starts running which can be every task switch. There's no reason to repeatedly call with the same value. Remember the last value and call iff the new value is different. This reduces the bpftop reported CPU consumption of scx_bpf_cpuperf_set() from ~1.2% to ~0.7% while running rd-hashd at full CPU saturation on Ryzen 3900x.
This commit is contained in:
parent
75dd81e3e6
commit
51d4945d69
@ -115,6 +115,7 @@ struct cpu_ctx {
|
|||||||
u32 layer_idx;
|
u32 layer_idx;
|
||||||
u32 cache_idx;
|
u32 cache_idx;
|
||||||
u32 node_idx;
|
u32 node_idx;
|
||||||
|
u32 perf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cache_ctx {
|
struct cache_ctx {
|
||||||
|
@ -2136,8 +2136,10 @@ void BPF_STRUCT_OPS(layered_running, struct task_struct *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer->perf > 0)
|
if (layer->perf > 0 && cctx->perf != layer->perf) {
|
||||||
scx_bpf_cpuperf_set(task_cpu, layer->perf);
|
scx_bpf_cpuperf_set(task_cpu, layer->perf);
|
||||||
|
cctx->perf = layer->perf;
|
||||||
|
}
|
||||||
|
|
||||||
cctx->maybe_idle = false;
|
cctx->maybe_idle = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user