Re: [PATCH v2 1/2] mm/damon/stat: change last_refresh_jiffies to a global variable
From: SeongJae Park
Date: Thu Oct 30 2025 - 10:31:24 EST
On Thu, 30 Oct 2025 10:07:45 +0800 Quanmin Yan <yanquanmin1@xxxxxxxxxx> wrote:
> In DAMON_STAT's damon_stat_damon_call_fn(), time_before_eq() is used to
> avoid unnecessarily frequent stat update.
>
> On 32-bit systems, the kernel initializes jiffies to "-5 minutes" to make
> jiffies wrap bugs appear earlier. However, this causes time_before_eq()
> in DAMON_STAT to unexpectedly return true during the first 5 minutes
> after boot on 32-bit systems (see [1] for more explanation, which fixes
> another jiffies-related issue before). As a result, DAMON_STAT does not
> update any monitoring results during that period, which becomes more
> confusing when DAMON_STAT_ENABLED_DEFAULT is enabled.
>
> There is also an issue unrelated to the system’s word size[2]: if the
> user stops DAMON_STAT just after last_refresh_jiffies is updated and
> restarts it after 5 seconds or a longer delay, last_refresh_jiffies will
> retain an older value, causing time_before_eq() to return false and the
> update to happen earlier than expected.
>
> Fix these issues by making last_refresh_jiffies a global variable and
> initializing it each time DAMON_STAT is started.
>
> [1] https://lkml.kernel.org/r/20250822025057.1740854-1-ekffu200098@xxxxxxxxx
> [2] https://lore.kernel.org/all/20251028143250.50144-1-sj@xxxxxxxxxx/
Thank you for finding and fixing these!
>
> Fixes: fabdd1e911da ("mm/damon/stat: calculate and expose estimated memory bandwidth")
> Suggested-by: SeongJae Park <sj@xxxxxxxxxx>
> Signed-off-by: Quanmin Yan <yanquanmin1@xxxxxxxxxx>
Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
Thanks,
SJ
[...]