linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon/core: set initial quota->charged_from to INITIAL_JIFFIES
@ 2025-08-18 18:38 Sang-Heon Jeon
  2025-08-18 23:01 ` SeongJae Park
  2025-08-19  5:25 ` SeongJae Park
  0 siblings, 2 replies; 6+ messages in thread
From: Sang-Heon Jeon @ 2025-08-18 18:38 UTC (permalink / raw)
  To: sj, honggyu.kim; +Cc: damon, linux-mm, Sang-Heon Jeon

Kernel initialize "jiffies" timer as 5 minutes below zero, as shown in
include/linux/jiffies.h

 /*
  * Have the 32 bit jiffies value wrap 5 minutes after boot
  * so jiffies wrap bugs show up earlier.
  */
  #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))

In 32bit system, if quota->charged_from is initialized to 0 as it now,
it will not adjust event if reset_interval_ms passes for the first 5
minutes.

So change initialize value of quota->charged_from to INITIAL_JIFFIES.
This soultion has already been applied in commit 7d70e15480c0 ("writeback:
add missing INITIAL_JIFFIES init in global_update_bandwidth()") or else.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
I think it would be good to add selftest of below senario. 

1. Set DAMON with quota.
2. Wait and check esz is updated well.
3. If esz is not updated after quite long time, set test to fail.

but I'm not sure that selftest can support environment handling; jiffies
with INITIAL_JIFFIES or near there.

If there is another method that i don't know. Could you please let me
know? Or any better idea?

---
 mm/damon/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index cb41fddca78c..90317a3bcf78 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -366,7 +366,7 @@ static struct damos_quota *damos_quota_init(struct damos_quota *quota)
 	quota->total_charged_sz = 0;
 	quota->total_charged_ns = 0;
 	quota->charged_sz = 0;
-	quota->charged_from = 0;
+	quota->charged_from = INITIAL_JIFFIES;
 	quota->charge_target_from = NULL;
 	quota->charge_addr_from = 0;
 	quota->esz_bp = 0;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-19  7:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 18:38 [PATCH] mm/damon/core: set initial quota->charged_from to INITIAL_JIFFIES Sang-Heon Jeon
2025-08-18 23:01 ` SeongJae Park
2025-08-19  1:52   ` Sang-Heon Jeon
2025-08-19  4:10     ` SeongJae Park
2025-08-19  5:25 ` SeongJae Park
2025-08-19  7:30   ` Sang-Heon Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).