linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Quanmin Yan <yanquanmin1@huawei.com>
To: SeongJae Park <sj@kernel.org>
Cc: <akpm@linux-foundation.org>, <damon@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
	<wangkefeng.wang@huawei.com>, <zuoze1@huawei.com>
Subject: Re: [PATCH] mm/damon/stat: set last_refresh_jiffies to jiffies at startup
Date: Wed, 29 Oct 2025 09:32:38 +0800	[thread overview]
Message-ID: <19e22163-39b4-42f8-99b8-1be9ffb1589b@huawei.com> (raw)
In-Reply-To: <20251028141915.49989-1-sj@kernel.org>

在 2025/10/28 22:19, SeongJae Park 写道:

> On Tue, 28 Oct 2025 14:19:27 +0800 Quanmin Yan <yanquanmin1@huawei.com> 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 in DAMON). As a result, DAMON_STAT does not
>> update any monitoring results during that period, which can be more
>> confusing when DAMON_STAT_ENABLED_DEFAULT is enabled.
>>
>> Fix it by setting last_refresh_jiffies to jiffies at startup.
> Nice catch, thank you for this patch!
>
>> [1] https://lkml.kernel.org/r/20250822025057.1740854-1-ekffu200098@gmail.com
>>
>> Fixes: fabdd1e911da ("mm/damon/stat: calculate and expose estimated memory bandwidth")
>> Signed-off-by: Quanmin Yan <yanquanmin1@huawei.com>
>> ---
>>   mm/damon/stat.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/mm/damon/stat.c b/mm/damon/stat.c
>> index 6c4503d2aee3..6dc3e18de910 100644
>> --- a/mm/damon/stat.c
>> +++ b/mm/damon/stat.c
>> @@ -132,6 +132,9 @@ static int damon_stat_damon_call_fn(void *data)
>>   	struct damon_ctx *c = data;
>>   	static unsigned long last_refresh_jiffies;
>>   
>> +	if (unlikely(!last_refresh_jiffies))
>> +		last_refresh_jiffies = jiffies;
>> +
> How about doing the initialization together with the declaration?  E.g.,
>
>   static int damon_stat_damon_call_fn(void *data)
>   {
>          struct damon_ctx *c = data;
> -       static unsigned long last_refresh_jiffies;
> +       static unsigned long last_refresh_jiffies = jiffies;
>
Thank you for your suggestion. Well, I actually tried that before, but
found that jiffies is not a compile-time constant,|it| is set at runtime,
while static initializers must use constant expressions, that's why the
current patch is modified this way.


Thanks,
Quanmin Yan

[...]



      parent reply	other threads:[~2025-10-29  1:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28  6:19 Quanmin Yan
2025-10-28 14:19 ` SeongJae Park
2025-10-28 14:32   ` SeongJae Park
2025-10-29  1:30     ` SeongJae Park
2025-10-29  2:02       ` Quanmin Yan
2025-10-29  1:32   ` Quanmin Yan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19e22163-39b4-42f8-99b8-1be9ffb1589b@huawei.com \
    --to=yanquanmin1@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=zuoze1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox