scx_lavd: add a sanity check if runtime is negative

Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
Changwoo Min 2024-03-19 21:53:46 +09:00
parent fa2282363b
commit 8860f26ff4

View File

@ -1482,6 +1482,14 @@ static bool slice_fully_consumed(struct cpu_ctx *cpuc, struct task_ctx *taskc)
{
u64 run_time_ns;
/*
* Sanity check just to make sure the runtime is positive.
*/
if (taskc->last_stop_clk < taskc->last_start_clk) {
scx_bpf_error("run_time_ns is negative: 0x%llu - 0x%llu",
taskc->last_stop_clk, taskc->last_start_clk);
}
run_time_ns = taskc->last_stop_clk - taskc->last_start_clk;
return run_time_ns >= taskc->slice_ns;