Skip to content

Commit 78049e9

Browse files
jhk16torvalds
authored andcommitted
mm/damon: prevent activated scheme from sleeping by deactivated schemes
In the DAMON, the minimum wait time of the schemes decides whether the kernel wakes up 'kdamon_fn()'. But since the minimum wait time is initialized to zero, there are corner cases against the original objective. For example, if we have several schemes for one target, and if the wait time of the first scheme is zero, the minimum wait time will set zero, which means 'kdamond_fn()' should wake up to apply this scheme. However, in the following scheme, wait time can be set to non-zero. Thus, the mininum wait time will be set to non-zero, which can cause sleeping this interval for 'kdamon_fn()' due to one deactivated last scheme. This commit prevents making DAMON monitoring inactive state due to other deactivated schemes. Link: https://lkml.kernel.org/r/20220330105302.32114-1-tome01@ajou.ac.kr Signed-off-by: Jonghyeon Kim <tome01@ajou.ac.kr> Reviewed-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bfc8089 commit 78049e9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mm/damon/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,12 +1019,15 @@ static int kdamond_wait_activation(struct damon_ctx *ctx)
10191019
struct damos *s;
10201020
unsigned long wait_time;
10211021
unsigned long min_wait_time = 0;
1022+
bool init_wait_time = false;
10221023

10231024
while (!kdamond_need_stop(ctx)) {
10241025
damon_for_each_scheme(s, ctx) {
10251026
wait_time = damos_wmark_wait_us(s);
1026-
if (!min_wait_time || wait_time < min_wait_time)
1027+
if (!init_wait_time || wait_time < min_wait_time) {
1028+
init_wait_time = true;
10271029
min_wait_time = wait_time;
1030+
}
10281031
}
10291032
if (!min_wait_time)
10301033
return 0;

0 commit comments

Comments
 (0)