mm/damon/core: reinitialize when passed_sample_intervals occurred overflow
Subsystems (2)
PATCH 1/1 mm/damon/core: reinitialize when passed_sample_intervals occurred overflow
To concisely explain the variables that calculate the time flow in kdamond_fn(), we write them as follows:
unsigned long ctx->passed_sample_intervals: c.psi
unsigned long ctx->next_ops_update_sis: c.nui
Normal:
[-----------------+---------------+-------------------+----------]
c.psi c.nui
---------------> next c.nui
if (c.psi >= c.nui) ---------->Overflow(OF):
[-----------------+---------------+-------------------+----------]
c.psi c.nui
-------------------->
if (c.psi >= c.nui) ---> OF[-----+-----------
next c.nui
Overflow(OF) occurred if (c.psi >= next c.nui):
Overflow may occur as shown above. In this case, re-run kdamond_init_ctx() to reinitialize the relevant variables.
Signed-off-by JaeJoon Jung <[email protected]>
--- mm/damon/core.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/damon/core.c +5 -0
@@ -2740,6 +2740,11 @@ static int kdamond_fn(void *data)if (ctx->ops.update) ctx->ops.update (ctx); sz_limit =damon_region_sz_limit (ctx); + +/* reinitialize when overflow occurs */ +if (ctx->passed_sample_intervals >= + ctx->next_ops_update_sis) +kdamond_init_ctx (ctx); } } done:
--
2.43.0