[PATCH 2/2] sched/psi: convert trigger window/threshold to ns in u64
From: Tao Cui
Date: Fri Jul 24 2026 - 00:12:50 EST
From: Tao Cui <cuitao@xxxxxxxxxx>
psi_trigger_create() scales the trigger threshold and window from
microseconds to nanoseconds as
t->threshold = threshold_us * NSEC_PER_USEC;
t->win.size = window_us * NSEC_PER_USEC;
NSEC_PER_USEC is 1000L, so on 32-bit the multiply is done in 32 bits and
wraps for windows larger than ~4.29s (WINDOW_MAX_US is 10s): a 10s window
is stored as ~1.41s and the trigger fires much too eagerly. Cast to u64
before multiplying.
Fixes: 0e94682b73bf ("psi: introduce psi monitor")
Signed-off-by: Tao Cui <cuitao@xxxxxxxxxx>
---
kernel/sched/psi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 6514b44222cf..7fbe9b94fafa 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -1390,8 +1390,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf,
t->group = group;
t->state = state;
- t->threshold = threshold_us * NSEC_PER_USEC;
- t->win.size = window_us * NSEC_PER_USEC;
+ t->threshold = (u64)threshold_us * NSEC_PER_USEC;
+ t->win.size = (u64)window_us * NSEC_PER_USEC;
window_reset(&t->win, sched_clock(),
group->total[PSI_POLL][t->state], 0);
--
2.43.0