* 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 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