Skip to contentSkip to conversation

mm/damon: Do some small changes

PATCH Superseded Xin Hao 2 participants 8 messages Nov 10, 2021 – Nov 11, 2021

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Xin Hao

author
#0 lore raw

cover mm/damon: Do some small changes

These two patches are mainly to do some small changes.

Xin Hao (2):
mm/damon: Unified access_check function naming rules mm/damon: Add 'age' of region tracepoint support

 include/trace/events/damon.h | 7 +++++--
 mm/damon/vaddr.c             | 8 ++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

--
2.31.0

author
#1 lore raw

PATCH 1/2 mm/damon: Unified access_check function naming rules

In damon/paddr.c file, two functions names start with underscore,
static void __damon_pa_prepare_access_check(struct damon_ctx *ctx,
struct damon_region *r)
static void __damon_pa_prepare_access_check(struct damon_ctx *ctx,
struct damon_region *r)
In damon/vaddr.c file, there are also two functions with the same function,
static void damon_va_prepare_access_check(struct damon_ctx *ctx,
struct mm_struct *mm, struct damon_region *r)
static void damon_va_check_access(struct damon_ctx *ctx,
struct mm_struct *mm, struct damon_region *r)

It makes sense to keep consistent, and it is not easy to be confused with the function that call them.

---
 mm/damon/vaddr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
mm/damon/vaddr.c +4 -4
index 35fe49080ee9..905e0fc8a8ec 100644
@@ -409,7 +409,7 @@ static void damon_va_mkold(struct mm_struct *mm, unsigned long addr)
  * Functions for the access checking of the regions
  */
 
-static void damon_va_prepare_access_check(struct damon_ctx *ctx,
+static void __damon_va_prepare_access_check(struct damon_ctx *ctx,
 			struct mm_struct *mm, struct damon_region *r)
 {
 	r->sampling_addr = damon_rand(r->ar.start, r->ar.end);
@@ -428,7 +428,7 @@ void damon_va_prepare_access_checks(struct damon_ctx *ctx)
 		if (!mm)
 			continue;
 		damon_for_each_region(r, t)
-			damon_va_prepare_access_check(ctx, mm, r);
+			__damon_va_prepare_access_check(ctx, mm, r);
 		mmput(mm);
 	}
 }
@@ -514,7 +514,7 @@ static bool damon_va_young(struct mm_struct *mm, unsigned long addr,
  * mm	'mm_struct' for the given virtual address space
  * r	the region to be checked
  */
-static void damon_va_check_access(struct damon_ctx *ctx,
+static void __damon_va_check_access(struct damon_ctx *ctx,
 			       struct mm_struct *mm, struct damon_region *r)
 {
 	static struct mm_struct *last_mm;
@@ -550,7 +550,7 @@ unsigned int damon_va_check_accesses(struct damon_ctx *ctx)
 		if (!mm)
 			continue;
 		damon_for_each_region(r, t) {
-			damon_va_check_access(ctx, mm, r);
+			__damon_va_check_access(ctx, mm, r);
 			max_nr_accesses = max(r->nr_accesses, max_nr_accesses);
 		}
 		mmput(mm);
Signature · 1 line
2.31.0
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH V1 1/2] mm/damon: Unified access_check function naming rules

Quoted 11 lines · On Wed, 10 Nov 2021 20:13:13 +0800 Xin Hao <[email protected]> wrote:

In damon/paddr.c file, two functions names start with underscore,
static void __damon_pa_prepare_access_check(struct damon_ctx *ctx,
struct damon_region *r)
static void __damon_pa_prepare_access_check(struct damon_ctx *ctx,
struct damon_region *r)
In damon/vaddr.c file, there are also two functions with the same function,
static void damon_va_prepare_access_check(struct damon_ctx *ctx,
struct mm_struct *mm, struct damon_region *r)
static void damon_va_check_access(struct damon_ctx *ctx,
struct mm_struct *mm, struct damon_region *r)

Quoted 4 lines

It makes sense to keep consistent, and it is not easy to be confused with the function that call them.

Thanks,
SJ

[...]

author
#3 lore raw

PATCH 2/2 mm/damon: Add 'age' of region tracepoint support

In reply to Xin Hao

In patch "mm/damon: add a tracepoint", it adds a tracepoint for DAMON, it can monitor each region for each aggregation interval, Now the region add a new 'age' variable, some primitive would calculate the priority of each region as a weight, there put it into tracepoint, so we can easily track the change of its value through perf or damon-tools.

---
 include/trace/events/damon.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
include/trace/events/damon.h +5 -2
index 2f422f4f1fb9..99ffa601e351 100644
@@ -22,6 +22,7 @@ TRACE_EVENT(damon_aggregated,
 		__field(unsigned long, start)
 		__field(unsigned long, end)
 		__field(unsigned int, nr_accesses)
+		__field(unsigned int, age)
 	),
 
 	TP_fast_assign(
@@ -30,11 +31,13 @@ TRACE_EVENT(damon_aggregated,
 		__entry->start = r->ar.start;
 		__entry->end = r->ar.end;
 		__entry->nr_accesses = r->nr_accesses;
+		__entry->age = r->age;
 	),
 
-	TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u",
+	TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u %u",
 			__entry->target_id, __entry->nr_regions,
-			__entry->start, __entry->end, __entry->nr_accesses)
+			__entry->start, __entry->end,
+			__entry->nr_accesses, __entry->age)
 );
 
 #endif /* _TRACE_DAMON_H */
Signature · 1 line
2.31.0
maintainer
#4 lore raw

Re: [PATCH V1 2/2] mm/damon: Add 'age' of region tracepoint support

Quoted 7 lines · On Wed, 10 Nov 2021 20:13:14 +0800 Xin Hao <[email protected]> wrote:

In patch "mm/damon: add a tracepoint", it adds a tracepoint for DAMON, it can monitor each region for each aggregation interval, Now the region add a new 'age' variable, some primitive would calculate the priority of each region as a weight, there put it into tracepoint, so we can easily track the change of its value through perf or damon-tools.

DAMON calculates the age using the address range and nr_accesses of the region, which are already in the tracepoint. In other words, user space can calculate the age on their own. Therefore I thought putting age in the tracepoint as adding unnecessary information, at the moment of the implementation.

Of course, I would missing some use cases that need this information in the tracepoint. Furthermore, adding just one more value in the tracepoint wouldn't incur a real issue. But, I'd like to know why this is necessary and how much benefit it provides. Xin, could you please share that?

Thanks,
SJ

Quoted 36 lines
---
 include/trace/events/damon.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
include/trace/events/damon.h +5 -2
index 2f422f4f1fb9..99ffa601e351 100644
@@ -22,6 +22,7 @@ TRACE_EVENT(damon_aggregated,
 		__field(unsigned long, start)
 		__field(unsigned long, end)
 		__field(unsigned int, nr_accesses)
+		__field(unsigned int, age)
 	),
 
 	TP_fast_assign(
@@ -30,11 +31,13 @@ TRACE_EVENT(damon_aggregated,
 		__entry->start = r->ar.start;
 		__entry->end = r->ar.end;
 		__entry->nr_accesses = r->nr_accesses;
+		__entry->age = r->age;
 	),
 
-	TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u",
+	TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u %u",
 			__entry->target_id, __entry->nr_regions,
-			__entry->start, __entry->end, __entry->nr_accesses)
+			__entry->start, __entry->end,
+			__entry->nr_accesses, __entry->age)
 );
 
 #endif /* _TRACE_DAMON_H */
Signature · 1 line
2.31.0
author
#5 lore raw

Re: [PATCH V1 2/2] mm/damon: Add 'age' of region tracepoint support

Hi Park:

Quoted 14 lines · SeongJae Park
Quoted 7 lines · On Wed, 10 Nov 2021 20:13:14 +0800 Xin Hao <[email protected]> wrote:

In patch "mm/damon: add a tracepoint", it adds a tracepoint for DAMON, it can monitor each region for each aggregation interval, Now the region add a new 'age' variable, some primitive would calculate the priority of each region as a weight, there put it into tracepoint, so we can easily track the change of its value through perf or damon-tools.

DAMON calculates the age using the address range and nr_accesses of the region, which are already in the tracepoint. In other words, user space can calculate the age on their own. Therefore I thought putting age in the tracepoint as adding unnecessary information, at the moment of the implementation.

Quoted 4 lines

Of course, I would missing some use cases that need this information in the tracepoint. Furthermore, adding just one more value in the tracepoint wouldn't incur a real issue. But, I'd like to know why this is necessary and how much benefit it provides. Xin, could you please share that?

I think these two variables nr_access &  age have different meanings, the nr_access only reflect the

period of  sample_interval,  We may be able to get the change of age through continuous long-term sampling,

But I think this is not very convenient.

We only need to observe the change of age value a small number of times to replace the continue sampling of the region.

For example, age has been increasing to 141, but nr_access shows a value of 0 at a certain time. Through this,we can

conclude that the region has a very low nr_access value for a long time.

This datas that  i used perf tool to record & script

*       kdamond.0  8282 [007]   664.187237: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 305254400-597266432: 0 140** **       kdamond.0  8282 [007]   664.187237: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 597266432-900239360: 0 140** **       kdamond.0  8282 [007]   664.187237: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 900239360-980148224: 0 140* kdamond.0  8282 [007]   664.187238: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281471544459264-281471789129728: 0 1 kdamond.0  8282 [007]   664.187238: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281471789129728-281472066732032: 0 0 kdamond.0  8282 [007]   664.187238: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472066732032-281472281972736: 0 1 kdamond.0  8282 [007]   664.187239: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472281972736-281472346124288: 1 0 kdamond.0  8282 [007]   664.187239: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472346124288-281472379187200: 0 1 kdamond.0  8282 [007]   664.187239: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472379187200-281472678154240: 1 0 kdamond.0  8282 [007]   664.187239: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472678154240-281472951209984: 1 0 kdamond.0  8282 [007]   664.187240: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472951209984-281473069228032: 2 0 kdamond.0  8282 [007]   664.187240: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473069228032-281473299972096: 0 1 kdamond.0  8282 [007]   664.187241: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473299972096-281473603727360: 0 0 kdamond.0  8282 [007]   664.187241: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473603727360-281473611063296: 0 5 kdamond.0  8282 [007]   664.187242: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281474851557376-281474851692544: 0 140 *       kdamond.0  8282 [007]   664.287642: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 4194304-305254400: 0 141* *       kdamond.0  8282 [007]   664.287643: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 305254400-597266432: 0 141* *       kdamond.0  8282 [007]   664.287643: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 597266432-900239360: 0 141* *       kdamond.0  8282 [007]   664.287650: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 900239360-980148224: 0 141* kdamond.0  8282 [007]   664.287650: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281471544459264-281471789129728: 0 2 kdamond.0  8282 [007]   664.287651: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281471789129728-281472066732032: 0 1 kdamond.0  8282 [007]   664.287651: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472066732032-281472349429760: 0 0 kdamond.0  8282 [007]   664.287651: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472349429760-281472588464128: 0 0 kdamond.0  8282 [007]   664.287652: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472588464128-281472678154240: 0 0 kdamond.0  8282 [007]   664.287652: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472678154240-281472951209984: 0 0 kdamond.0  8282 [007]   664.287652: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281472951209984-281473092300800: 1 0 kdamond.0  8282 [007]   664.287653: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473092300800-281473299972096: 0 2 kdamond.0  8282 [007]   664.287654: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473299972096-281473421471744: 0 1 kdamond.0  8282 [007]   664.287654: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473421471744-281473603727360: 2 0 kdamond.0  8282 [007]   664.287654: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281473603727360-281473611063296: 0 6 kdamond.0  8282 [007]   664.287655: damon:damon_aggregated: target_id=18446462650354140800 nr_regions=16 281474851557376-281474851692544: 0 141

Quoted 40 lines

Thanks,
SJ

Quoted 35 lines
---
  include/trace/events/damon.h | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
include/trace/events/damon.h +5 -2
index 2f422f4f1fb9..99ffa601e351 100644
@@ -22,6 +22,7 @@ TRACE_EVENT(damon_aggregated,
  		__field(unsigned long, start)
  		__field(unsigned long, end)
  		__field(unsigned int, nr_accesses)
+		__field(unsigned int, age)
  	),
 
  	TP_fast_assign(
@@ -30,11 +31,13 @@ TRACE_EVENT(damon_aggregated,
  		__entry->start = r->ar.start;
  		__entry->end = r->ar.end;
  		__entry->nr_accesses = r->nr_accesses;
+		__entry->age = r->age;
  	),
 
-	TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u",
+	TP_printk("target_id=%lu nr_regions=%u %lu-%lu: %u %u",
  			__entry->target_id, __entry->nr_regions,
-			__entry->start, __entry->end, __entry->nr_accesses)
+			__entry->start, __entry->end,
+			__entry->nr_accesses, __entry->age)
  );
 
  #endif /* _TRACE_DAMON_H */
Signature · 1 line
2.31.0
Signature · 2 lines
Best Regards!
Xin Hao
maintainer
#6 lore raw

Re: [PATCH V1 2/2] mm/damon: Add 'age' of region tracepoint support

Quoted 32 lines · On Thu, 11 Nov 2021 10:04:38 +0800 Xin Hao <[email protected]> wrote:

[-- Attachment #1: Type: text/plain, Size: 8070 bytes --]

Hi Park:

Quoted 14 lines · SeongJae Park
Quoted 7 lines · On Wed, 10 Nov 2021 20:13:14 +0800 Xin Hao <[email protected]> wrote:

In patch "mm/damon: add a tracepoint", it adds a tracepoint for DAMON, it can monitor each region for each aggregation interval, Now the region add a new 'age' variable, some primitive would calculate the priority of each region as a weight, there put it into tracepoint, so we can easily track the change of its value through perf or damon-tools.

DAMON calculates the age using the address range and nr_accesses of the region, which are already in the tracepoint. In other words, user space can calculate the age on their own. Therefore I thought putting age in the tracepoint as adding unnecessary information, at the moment of the implementation.

Quoted 4 lines

Of course, I would missing some use cases that need this information in the tracepoint. Furthermore, adding just one more value in the tracepoint wouldn't incur a real issue. But, I'd like to know why this is necessary and how much benefit it provides. Xin, could you please share that?

I think these two variables nr_access & age have different meanings, the nr_access only reflect the

period of sample_interval, We may be able to get the change of age through continuous long-term sampling,

But I think this is not very convenient.

Quoted 7 lines

We only need to observe the change of age value a small number of times to replace the continue sampling of the region.

For example, age has been increasing to 141, but nr_access shows a value of 0 at a certain time. Through this,we can

conclude that the region has a very low nr_access value for a long time.

I understand that you don't want to record all the traces and then process the huge trace data in user space in order to get the age information, because you want to save disk space and CPU cycles. Is that correct? If so, I think that makes sense, and it would be better to put that in the commit message.

Thanks,
SJ

[...]

author
#7 lore raw

Re: [PATCH V1 2/2] mm/damon: Add 'age' of region tracepoint support

Hi, Park:

Quoted 36 lines · SeongJae Park
Quoted 34 lines · On Thu, 11 Nov 2021 10:04:38 +0800 Xin Hao <[email protected]> wrote:

[-- Attachment #1: Type: text/plain, Size: 8070 bytes --]

Hi Park:

Quoted 14 lines · SeongJae Park
Quoted 7 lines · On Wed, 10 Nov 2021 20:13:14 +0800 Xin Hao <[email protected]> wrote:

In patch "mm/damon: add a tracepoint", it adds a tracepoint for DAMON, it can monitor each region for each aggregation interval, Now the region add a new 'age' variable, some primitive would calculate the priority of each region as a weight, there put it into tracepoint, so we can easily track the change of its value through perf or damon-tools.

DAMON calculates the age using the address range and nr_accesses of the region, which are already in the tracepoint. In other words, user space can calculate the age on their own. Therefore I thought putting age in the tracepoint as adding unnecessary information, at the moment of the implementation.

Quoted 4 lines

Of course, I would missing some use cases that need this information in the tracepoint. Furthermore, adding just one more value in the tracepoint wouldn't incur a real issue. But, I'd like to know why this is necessary and how much benefit it provides. Xin, could you please share that?

I think these two variables nr_access & age have different meanings, the nr_access only reflect the

period of sample_interval, We may be able to get the change of age through continuous long-term sampling,

But I think this is not very convenient.

We only need to observe the change of age value a small number of times to replace the continue sampling of the region.

Quoted 8 lines
Quoted 4 lines

For example, age has been increasing to 141, but nr_access shows a value of 0 at a certain time. Through this,we can

conclude that the region has a very low nr_access value for a long time.

I understand that you don't want to record all the traces and then process the huge trace data in user space in order to get the age information, because you want to save disk space and CPU cycles. Is that correct? If so, I think that makes sense, and it would be better to put that in the commit message.

Yes, What you said is absolutely correct, that's how I thought about it, I will add this part of the

information to the commit,thanks!

Quoted 6 lines

Thanks,
SJ

[...]

Signature · 2 lines
Best Regards!
Xin Hao