From: Maximilian Pezzullo Setting vm.stat_interval to 0 causes excessive kworker CPU usage because vmstat_shepherd() and vmstat_update() reschedule themselves with round_jiffies_relative(0), which resolves to an immediate reschedule and creates a busy-loop. Add a custom sysctl handler that rejects 0 and restores the previous value, similar to how dirtytime_interval_handler() handles vm.dirtytime_expire_seconds. Reported-by: Terry M Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220226 Signed-off-by: Maximilian Pezzullo --- mm/vmstat.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 86b14b0f77b5..6eeb4341b215 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2114,6 +2114,18 @@ void vmstat_flush_workqueue(void) flush_workqueue(mm_percpu_wq); } +static int vmstat_interval_handler(const struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + int ret = proc_dointvec_jiffies(table, write, buffer, lenp, ppos); + + if (ret == 0 && write && sysctl_stat_interval == 0) { + sysctl_stat_interval = HZ; + return -EINVAL; + } + return ret; +} + static void vmstat_shepherd(struct work_struct *w) { int cpu; @@ -2236,7 +2248,7 @@ static const struct ctl_table vmstat_table[] = { .data = &sysctl_stat_interval, .maxlen = sizeof(sysctl_stat_interval), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = vmstat_interval_handler, }, { .procname = "stat_refresh", --- base-commit: af4e9ef3d78420feb8fe58cd9a1ab80c501b3c08 change-id: 20260304-mm-vmstat-reject-zero-vm-stat_interval-to-prevent-busy-loop-ba5446a527aa Best regards, -- Maximilian Pezzullo