From nobody Thu Apr 2 22:17:39 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1DE71F4615 for ; Thu, 26 Mar 2026 07:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774511781; cv=none; b=cc8jOPU414RBevEqkICW0biAyQG/TDIiLhwe+alvSCbmxrbP7unT2RX/xhNoWwCHURPio/Xv72JXk8qoJISBNm48IkpTpPmwC979WoIgvpLJUJgQ7iGff/2iK3RkfsfNeySMDjxHdIOy7lTV1KXzNPcb4KmPcZYSgwcFmfEZdQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774511781; c=relaxed/simple; bh=0F1gANuVjYzMSZjuxQgeUMTsogXmUTShgSaVdjFVHMc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=UZWpg+8q2OFjsIJSGDVi/DBtptuDvTXwl2S8WTnc5tvEG1WqqVi2JKw3NMGD/QhDTWS1xPts4JP9xi6aRmR1oHpHHv4vHMg1L/BUrzgyX0Laq9hGSqFmn84LBYNI9ru6Bx4FM8RKge9tyUHVMMR0MT+oGHTtB6A0udmLZkvqOHQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=5KP2guBT; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="5KP2guBT" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=KeGe31pnWU9sNlgHOU08IcjrMTmyK9AVvW8hheCO5Vg=; b=5KP2guBTNY9EPm3IfhFvAiVTNpoS3bd7gvfWq35qe7MpWYcTGkA7i8+0bXkF3ihNoBiphWjpw kCOnIeK6N+Fd4ZnahR6I+jryyngzyHlVOrFYazy1aXUNPdA6m7S4FRwPMKtgB4UyF9zQAnfvI26 4vLPTVKzQh0MG6IlXoiytqk= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fhGCH6lmCzLlT0; Thu, 26 Mar 2026 15:50:03 +0800 (CST) Received: from dggpemf200002.china.huawei.com (unknown [7.185.36.244]) by mail.maildlp.com (Postfix) with ESMTPS id 4D2B140561; Thu, 26 Mar 2026 15:56:09 +0800 (CST) Received: from huawei.com (10.50.87.109) by dggpemf200002.china.huawei.com (7.185.36.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 26 Mar 2026 15:56:08 +0800 From: Yang Yingliang To: , , , , , , , , , , CC: , Subject: [PATCH -next] mm: vmstat: make refresh interval take effect immediately Date: Thu, 26 Mar 2026 15:55:46 +0800 Message-ID: <20260326075546.3357901-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To dggpemf200002.china.huawei.com (7.185.36.244) Content-Type: text/plain; charset="utf-8" The refresh workqueue is re-queued after last timer is triggered, so when the refresh interval is set, it doesn't take effect immediately. It leads a problem like this: if current interval is 8640000s (100 days), and we want changing it to 1s, the new interval can't take effect until 100 days later. So call mod_delayed_work() after updating interval to make the new value take effect immediately. Signed-off-by: Yang Yingliang --- mm/vmstat.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 2370c6fb1fcd..7b4a9c30cc80 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1968,6 +1968,9 @@ static int sysctl_stat_interval __read_mostly =3D HZ; static int vmstat_late_init_done; =20 #ifdef CONFIG_PROC_FS +static int sysctl_stat_interval_handler(const struct ctl_table *table, int= write, + void *buffer, size_t *length, loff_t *ppos); + static void refresh_vm_stats(struct work_struct *work) { refresh_cpu_vm_stats(true); @@ -2151,6 +2154,38 @@ static void vmstat_shepherd(struct work_struct *w) round_jiffies_relative(sysctl_stat_interval)); } =20 +#ifdef CONFIG_PROC_FS +static int sysctl_stat_interval_handler(const struct ctl_table *table, int= write, + void *buffer, size_t *length, loff_t *ppos) +{ + int cpu; + int ret =3D proc_dointvec_jiffies(table, write, buffer, length, ppos); + + if (ret || !write) + return ret; + + cpus_read_lock(); + for_each_online_cpu(cpu) { + struct delayed_work *dw =3D &per_cpu(vmstat_work, cpu); + + scoped_guard(rcu) { + if (cpu_is_isolated(cpu)) + continue; + + if (delayed_work_pending(dw)) + mod_delayed_work(system_wq, dw, round_jiffies_relative(sysctl_stat_int= erval)); + } + + cond_resched(); + } + cpus_read_unlock(); + + mod_delayed_work(system_wq, &shepherd, round_jiffies_relative(sysctl_stat= _interval)); + + return ret; +} +#endif + static void __init start_shepherd_timer(void) { int cpu; @@ -2237,7 +2272,7 @@ static const struct ctl_table vmstat_table[] =3D { .data =3D &sysctl_stat_interval, .maxlen =3D sizeof(sysctl_stat_interval), .mode =3D 0644, - .proc_handler =3D proc_dointvec_jiffies, + .proc_handler =3D sysctl_stat_interval_handler, }, { .procname =3D "stat_refresh", --=20 2.25.1