From 4449d8e31c2d3a42b373e91e26609c8b166cb2f2 Mon Sep 17 00:00:00 2001 From: Changwoo Min Date: Sun, 28 Jul 2024 15:40:25 +0900 Subject: [PATCH] scx_lavd: incorporate a task's static priority in calculating its latency criticality That's because static (nice) priority is a strong hint to distinguish latency-critical tasks. Signed-off-by: Changwoo Min --- scheds/rust/scx_lavd/src/bpf/main.bpf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scheds/rust/scx_lavd/src/bpf/main.bpf.c b/scheds/rust/scx_lavd/src/bpf/main.bpf.c index aa05b3a..4b45aab 100644 --- a/scheds/rust/scx_lavd/src/bpf/main.bpf.c +++ b/scheds/rust/scx_lavd/src/bpf/main.bpf.c @@ -1079,7 +1079,15 @@ static void calc_lat_cri(struct task_struct *p, struct task_ctx *taskc) * a boost priority. We add +1 to guarantee the latency criticality * (log2-ed) is always positive. */ - taskc->lat_cri = log2_u64(lat_cri_raw + 1); + lat_cri = log2_u64(lat_cri_raw + 1); + + /* + * A user-provided nice value is a strong hint for latency-criticality. + */ + lat_cri += calc_static_prio_factor(p); + lat_cri = max(lat_cri, 1); + + taskc->lat_cri = lat_cri; } static void calc_starv_cri(struct task_ctx *taskc, bool is_wakeup)