linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon: make region calculations more precise
@ 2025-05-21  7:07 Enze Li
  2025-05-21 17:18 ` SeongJae Park
  2025-05-29  5:53 ` kernel test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Enze Li @ 2025-05-21  7:07 UTC (permalink / raw)
  To: sj; +Cc: damon, linux-mm, lienze

The damon_sz_region() function misses counting one element when
calculating region size, which leads to inaccurate results.  This patch
corrects the size calculation by properly accounting for all elements.

Signed-off-by: Enze Li <lienze@kylinos.cn>
---
 include/linux/damon.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 47e36e6ea203..70473863f7fe 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -808,7 +808,7 @@ static inline struct damon_region *damon_first_region(struct damon_target *t)
 
 static inline unsigned long damon_sz_region(struct damon_region *r)
 {
-	return r->ar.end - r->ar.start;
+	return r->ar.end - r->ar.start + 1;
 }
 
 

base-commit: 4a95bc121ccdaee04c4d72f84dbfa6b880a514b6
-- 
2.43.0



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

* Re: [PATCH] mm/damon: make region calculations more precise
  2025-05-21  7:07 [PATCH] mm/damon: make region calculations more precise Enze Li
@ 2025-05-21 17:18 ` SeongJae Park
  2025-05-22  1:53   ` Enze Li
  2025-05-29  5:53 ` kernel test robot
  1 sibling, 1 reply; 6+ messages in thread
From: SeongJae Park @ 2025-05-21 17:18 UTC (permalink / raw)
  To: Enze Li; +Cc: SeongJae Park, damon, linux-mm

Hi Enze,

On Wed, 21 May 2025 15:07:47 +0800 Enze Li <lienze@kylinos.cn> wrote:

> The damon_sz_region() function misses counting one element when
> calculating region size, which leads to inaccurate results.  This patch
> corrects the size calculation by properly accounting for all elements.

Thank you for this patch, but I don't think the current calculation is wrong.
Please refer to the below comment.

> 
> Signed-off-by: Enze Li <lienze@kylinos.cn>
> ---
>  include/linux/damon.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 47e36e6ea203..70473863f7fe 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -808,7 +808,7 @@ static inline struct damon_region *damon_first_region(struct damon_target *t)
>  
>  static inline unsigned long damon_sz_region(struct damon_region *r)
>  {
> -	return r->ar.end - r->ar.start;
> +	return r->ar.end - r->ar.start + 1;
>  }

'ar' here is 'struct damon_addr_range' which is for a half-open range.  Refer
to the comment on 'struct damon_addr_range' definition on include/linux/damon.h
for detail.  So I don't think the current calculation is wrong.

If you think this function also deserves a short comment for clarifying this,
your patch for that wil be welcomed :)

Please let me know if I'm missing something.


Thanks,
SJ

[...]


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

* Re: [PATCH] mm/damon: make region calculations more precise
  2025-05-21 17:18 ` SeongJae Park
@ 2025-05-22  1:53   ` Enze Li
  2025-05-22 17:16     ` SeongJae Park
  0 siblings, 1 reply; 6+ messages in thread
From: Enze Li @ 2025-05-22  1:53 UTC (permalink / raw)
  To: SeongJae Park; +Cc: damon, linux-mm


Hi SeongJae,

On Wed, May 21 2025 at 10:18:09 AM -0700, SeongJae Park wrote:

> Hi Enze,
>
> On Wed, 21 May 2025 15:07:47 +0800 Enze Li <lienze@kylinos.cn> wrote:
>
>> The damon_sz_region() function misses counting one element when
>> calculating region size, which leads to inaccurate results.  This patch
>> corrects the size calculation by properly accounting for all elements.
>
> Thank you for this patch, but I don't think the current calculation is wrong.
> Please refer to the below comment.
>
>> 
>> Signed-off-by: Enze Li <lienze@kylinos.cn>
>> ---
>>  include/linux/damon.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/include/linux/damon.h b/include/linux/damon.h
>> index 47e36e6ea203..70473863f7fe 100644
>> --- a/include/linux/damon.h
>> +++ b/include/linux/damon.h
>> @@ -808,7 +808,7 @@ static inline struct damon_region *damon_first_region(struct damon_target *t)
>>  
>>  static inline unsigned long damon_sz_region(struct damon_region *r)
>>  {
>> -	return r->ar.end - r->ar.start;
>> +	return r->ar.end - r->ar.start + 1;
>>  }
>
> 'ar' here is 'struct damon_addr_range' which is for a half-open range.  Refer
> to the comment on 'struct damon_addr_range' definition on include/linux/damon.h
> for detail.  So I don't think the current calculation is wrong.

Thanks for pointing out this - I overlooked it :(

>
> If you think this function also deserves a short comment for clarifying this,
> your patch for that wil be welcomed :)

Since this is already documented in the definition, repeating it here
would be redundant.  If someone submits a similar patch for this in the
future, we can consider adding comments then.

Thanks,
Enze

[...]

>
> Please let me know if I'm missing something.
>
>
> Thanks,
> SJ
>
> [...]


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

* Re: [PATCH] mm/damon: make region calculations more precise
  2025-05-22  1:53   ` Enze Li
@ 2025-05-22 17:16     ` SeongJae Park
  0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2025-05-22 17:16 UTC (permalink / raw)
  To: Enze Li; +Cc: SeongJae Park, damon, linux-mm

On Thu, 22 May 2025 09:53:17 +0800 Enze Li <lienze@kylinos.cn> wrote:

> 
> Hi SeongJae,
> 
> On Wed, May 21 2025 at 10:18:09 AM -0700, SeongJae Park wrote:
> 
> > Hi Enze,
> >
> > On Wed, 21 May 2025 15:07:47 +0800 Enze Li <lienze@kylinos.cn> wrote:
[...]
> > If you think this function also deserves a short comment for clarifying this,
> > your patch for that wil be welcomed :)
> 
> Since this is already documented in the definition, repeating it here
> would be redundant.  If someone submits a similar patch for this in the
> future, we can consider adding comments then.

Makes sense!


Thanks,
SJ

[...]


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

* Re: [PATCH] mm/damon: make region calculations more precise
  2025-05-21  7:07 [PATCH] mm/damon: make region calculations more precise Enze Li
  2025-05-21 17:18 ` SeongJae Park
@ 2025-05-29  5:53 ` kernel test robot
  2025-05-29 16:41   ` SeongJae Park
  1 sibling, 1 reply; 6+ messages in thread
From: kernel test robot @ 2025-05-29  5:53 UTC (permalink / raw)
  To: Enze Li; +Cc: oe-lkp, lkp, damon, linux-mm, sj, lienze, oliver.sang


Hello,

kernel test robot noticed "kunit.damon-operations.damon_test_split_evenly.fail" on:

commit: fe301d6b4b4aec003ff84aa4d2860e772b147225 ("[PATCH] mm/damon: make region calculations more precise")
url: https://github.com/intel-lab-lkp/linux/commits/Enze-Li/mm-damon-make-region-calculations-more-precise/20250521-151059
patch link: https://lore.kernel.org/all/20250521070747.1458270-1-lienze@kylinos.cn/
patch subject: [PATCH] mm/damon: make region calculations more precise

in testcase: kunit
version: 
with following parameters:

	group: group-03



config: x86_64-rhel-9.4-kunit
compiler: gcc-12
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (Haswell) with 16G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)




If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202505291314.d61b1bcb-lkp@intel.com


[  109.399987]     KTAP version 1
[  109.403771]     # Subtest: damon-operations
[  109.408675]     # module: vaddr
[  109.408682]     1..6
[  109.416216]     ok 1 damon_test_three_regions_in_vmas
[  109.416463]     ok 2 damon_test_apply_three_regions1
[  109.422542]     ok 3 damon_test_apply_three_regions2
[  109.428508]     ok 4 damon_test_apply_three_regions3
[  109.434509]     ok 5 damon_test_apply_three_regions4
[  109.440399]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:290
                   Expected r->ar.end == start + i * expected_width, but
                       r->ar.end == 16 (0x10)
                       start + i * expected_width == 15 (0xf)
[  109.446223]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:288
                   Expected r->ar.start == start + i++ * expected_width, but
                       r->ar.start == 16 (0x10)
                       start + i++ * expected_width == 15 (0xf)
[  109.473938]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:290
                   Expected r->ar.end == start + i * expected_width, but
                       r->ar.end == 27 (0x1b)
                       start + i * expected_width == 25 (0x19)
[  109.502332]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:288
                   Expected r->ar.start == start + i++ * expected_width, but
                       r->ar.start == 27 (0x1b)
                       start + i++ * expected_width == 25 (0x19)
[  109.530150]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:290
                   Expected r->ar.end == start + i * expected_width, but
                       r->ar.end == 38 (0x26)
                       start + i * expected_width == 35 (0x23)
[  109.558624]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:288
                   Expected r->ar.start == start + i++ * expected_width, but
                       r->ar.start == 38 (0x26)
                       start + i++ * expected_width == 35 (0x23)
[  109.586405]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:290
                   Expected r->ar.end == start + i * expected_width, but
                       r->ar.end == 49 (0x31)
                       start + i * expected_width == 45 (0x2d)
[  109.614882]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:283
                   Expected r->ar.start == start + i * expected_width, but
                       r->ar.start == 49 (0x31)
                       start + i * expected_width == 45 (0x2d)
[  109.642682]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:290
                   Expected r->ar.end == start + i * expected_width, but
                       r->ar.end == 2 (0x2)
                       start + i * expected_width == 1 (0x1)
[  109.670817]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:283
                   Expected r->ar.start == start + i * expected_width, but
                       r->ar.start == 2 (0x2)
                       start + i * expected_width == 1 (0x1)
[  109.698255]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:256
                   Expected damon_va_evenly_split_region(t, r, nr_pieces) == -22, but
                       damon_va_evenly_split_region(t, r, nr_pieces) == 0 (0x0)
[  109.751585]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:258
                   Expected damon_nr_regions(t) == 1u, but
                       damon_nr_regions(t) == 2 (0x2)
                       1u == 1 (0x1)
[  109.751634]     # damon_test_split_evenly: EXPECTATION FAILED at mm/damon/tests/vaddr-kunit.h:261
                   Expected r->ar.start == start, but
                       r->ar.start == 6 (0x6)
                       start == 5 (0x5)
[  109.776758]     not ok 6 damon_test_split_evenly
[  109.800835] # damon-operations: pass:5 fail:1 skip:0 total:6
[  109.806182] # Totals: pass:5 fail:1 skip:0 total:6
[  109.812563] not ok 4 damon-operations


The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250529/202505291314.d61b1bcb-lkp@intel.com


-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



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

* Re: [PATCH] mm/damon: make region calculations more precise
  2025-05-29  5:53 ` kernel test robot
@ 2025-05-29 16:41   ` SeongJae Park
  0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2025-05-29 16:41 UTC (permalink / raw)
  To: kernel test robot; +Cc: SeongJae Park, Enze Li, oe-lkp, lkp, damon, linux-mm

On Thu, 29 May 2025 13:53:12 +0800 kernel test robot <oliver.sang@intel.com> wrote:

> 
> Hello,
> 
> kernel test robot noticed "kunit.damon-operations.damon_test_split_evenly.fail" on:
> 
> commit: fe301d6b4b4aec003ff84aa4d2860e772b147225 ("[PATCH] mm/damon: make region calculations more precise")
> url: https://github.com/intel-lab-lkp/linux/commits/Enze-Li/mm-damon-make-region-calculations-more-precise/20250521-151059
> patch link: https://lore.kernel.org/all/20250521070747.1458270-1-lienze@kylinos.cn/
> patch subject: [PATCH] mm/damon: make region calculations more precise

Thank you for this nice report!

[...]
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <oliver.sang@intel.com>
> | Closes: https://lore.kernel.org/oe-lkp/202505291314.d61b1bcb-lkp@intel.com

Just for a clarification.  We decided to not pick this patch as is, so no fix
for this report will be made.


Thanks,
SJ

[...]


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

end of thread, other threads:[~2025-05-29 16:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21  7:07 [PATCH] mm/damon: make region calculations more precise Enze Li
2025-05-21 17:18 ` SeongJae Park
2025-05-22  1:53   ` Enze Li
2025-05-22 17:16     ` SeongJae Park
2025-05-29  5:53 ` kernel test robot
2025-05-29 16:41   ` SeongJae Park

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).