Skip to contentSkip to conversation

mm/damon: Prevent unnecessary age reset for regions

PATCH In review Hyeongtak Ji 2 participants 3 messages Aug 7, 2023 – Aug 8, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/damon: Prevent unnecessary age reset for regions

DAMON resets the age of each region after applying each scheme, regardless of whether the scheme has been successfully applied.

This patch adds a simple condition to prevent the age of regions from being reset when schemes have not been actually applied.

---
 mm/damon/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/core.c +1 -1
index 91cff7f2997e..4044fcf18ac1 100644
@@ -908,7 +908,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
 			quota->charge_addr_from = r->ar.end + 1;
 		}
 	}
-	if (s->action != DAMOS_STAT)
+	if (s->action != DAMOS_STAT && sz_applied > 0)
 		r->age = 0;
 
 update_stat:
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi Hyeongtak,

Thank you for this patch!

Quoted 5 lines · On Mon, 7 Aug 2023 18:44:35 +0900 Hyeongtak Ji <[email protected]> wrote:

DAMON resets the age of each region after applying each scheme, regardless of whether the scheme has been successfully applied.

This patch adds a simple condition to prevent the age of regions from being reset when schemes have not been actually applied.

We consider applying the action as making a change to the region, and hence reset the age to zero. Even if the action was not completely applied, that might be enough to make some change to the region. The behavior is also to limit a scheme too repeatedly and frequently applied to a region.

So, this is not a bug but an intended behavior, and I think this change might not what really necessary.

Is there a specific use case that this change is needed? If so, I think we can think about extending the interface to support the case.

Thanks,
SJ

Quoted 22 lines
---
 mm/damon/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/core.c +1 -1
index 91cff7f2997e..4044fcf18ac1 100644
@@ -908,7 +908,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
 			quota->charge_addr_from = r->ar.end + 1;
 		}
 	}
-	if (s->action != DAMOS_STAT)
+	if (s->action != DAMOS_STAT && sz_applied > 0)
 		r->age = 0;
 
 update_stat:
Signature · 1 line
2.7.4
author
#2 lore raw

Hello,

Thank you for your review. I really appreciate it.

Quoted 11 lines · SeongJae Park

Hi Hyeongtak,

Thank you for this patch!

Quoted 3 lines · On Mon, 7 Aug 2023 18:44:35 +0900 Hyeongtak Ji <[email protected]> wrote:

DAMON resets the age of each region after applying each scheme, regardless of whether the scheme has been successfully applied.

Quoted 7 lines
Quoted 2 lines

This patch adds a simple condition to prevent the age of regions from being reset when schemes have not been actually applied.

We consider applying the action as making a change to the region, and hence reset the age to zero. Even if the action was not completely applied, that might be enough to make some change to the region. The behavior is also to limit a scheme too repeatedly and frequently applied to a region.

This is what I have totally overlooked.

Quoted 3 lines

So, this is not a bug but an intended behavior, and I think this change might not what really necessary.

Now I understand that this patch is not necessary.

Quoted 3 lines

Is there a specific use case that this change is needed? If so, I think we can think about extending the interface to support the case.

Not for now, but if I find any use cases for this situation, I will let you know.

Quoted 5 lines

Thanks,
SJ