From c653622ed903b65b215dca45d2fd497621a1818e Mon Sep 17 00:00:00 2001 From: Changwoo Min Date: Sat, 20 Jul 2024 12:00:50 +0900 Subject: [PATCH] scx_lavd: add LAVD_VDL_LOOSENESS_FT in calculating virtual deadline LAVD_VDL_LOOSENESS_FT represents how loose the deadline is. The smaller value means the deadline is tighter. While it is unlikely to be tuned, let's keep it as a tunable for now. Signed-off-by: Changwoo Min --- scheds/rust/scx_lavd/src/bpf/intf.h | 1 + scheds/rust/scx_lavd/src/bpf/main.bpf.c | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/scheds/rust/scx_lavd/src/bpf/intf.h b/scheds/rust/scx_lavd/src/bpf/intf.h index 47700ae..e50209f 100644 --- a/scheds/rust/scx_lavd/src/bpf/intf.h +++ b/scheds/rust/scx_lavd/src/bpf/intf.h @@ -60,6 +60,7 @@ enum consts { LAVD_SLICE_MIN_NS = (30 * NSEC_PER_USEC), /* min time slice */ LAVD_SLICE_MAX_NS = ( 3 * NSEC_PER_MSEC), /* max time slice */ LAVD_SLICE_UNDECIDED = SCX_SLICE_INF, + LAVD_VDL_LOOSENESS_FT = 100, LAVD_LC_FREQ_MAX = 1000000, LAVD_LC_RUNTIME_MAX = LAVD_TARGETED_LATENCY_NS, diff --git a/scheds/rust/scx_lavd/src/bpf/main.bpf.c b/scheds/rust/scx_lavd/src/bpf/main.bpf.c index bfccff4..c13e71f 100644 --- a/scheds/rust/scx_lavd/src/bpf/main.bpf.c +++ b/scheds/rust/scx_lavd/src/bpf/main.bpf.c @@ -1092,21 +1092,17 @@ static void boost_lat(struct task_struct *p, struct task_ctx *taskc, taskc->lat_cri = log2_u64(lat_cri_raw + 1) + is_wakeup; } -static u64 calc_virtual_deadline_delta(struct task_struct *p, - struct task_ctx *taskc, - struct cpu_ctx *cpuc, - u64 enq_flags) +static void calc_virtual_deadline_delta(struct task_struct *p, + struct task_ctx *taskc, + struct cpu_ctx *cpuc, + u64 enq_flags) { - u64 vdeadline_delta_ns; bool is_wakeup; is_wakeup = is_wakeup_ef(enq_flags); boost_lat(p, taskc, cpuc, is_wakeup); - vdeadline_delta_ns = (taskc->run_time_ns * 1000) / taskc->lat_cri; - - taskc->vdeadline_delta_ns = vdeadline_delta_ns; - - return vdeadline_delta_ns; + taskc->vdeadline_delta_ns = (taskc->run_time_ns * + LAVD_VDL_LOOSENESS_FT) / taskc->lat_cri; } static u64 calc_task_load_actual(struct task_ctx *taskc)