The patch titled Subject: mm/damon/vaddr: Add 'nr_piece == 1' check in damon_va_evenly_split_region() has been added to the -mm mm-unstable branch. Its filename is mm-damon-vaddr-add-nr_piece-==-1-check-in-damon_va_evenly_split_region.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-vaddr-add-nr_piece-==-1-check-in-damon_va_evenly_split_region.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Zheng Yejian <zhengyejian@xxxxxxxxxxxxxxx> Subject: mm/damon/vaddr: Add 'nr_piece == 1' check in damon_va_evenly_split_region() Date: Tue, 22 Oct 2024 16:39:27 +0800 As discussed in [1], damon_va_evenly_split_region() is called to size-evenly split a region into 'nr_pieces' small regions, when nr_pieces == 1, no actual split is required. Check that case for better code readability and add a simple kunit testcase. [1] https://lore.kernel.org/all/20241021163316.12443-1-sj@xxxxxxxxxx/ Link: https://lkml.kernel.org/r/20241022083927.3592237-3-zhengyejian@xxxxxxxxxxxxxxx Signed-off-by: Zheng Yejian <zhengyejian@xxxxxxxxxxxxxxx> Reviewed-by: SeongJae Park <sj@xxxxxxxxxx> Cc: Fernand Sieber <sieberf@xxxxxxxxxx> Cc: Leonard Foerster <foersleo@xxxxxxxxx> Cc: Shakeel Butt <shakeel.butt@xxxxxxxxx> Cc: Ye Weihua <yeweihua4@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/damon/tests/vaddr-kunit.h | 1 + mm/damon/vaddr.c | 3 +++ 2 files changed, 4 insertions(+) --- a/mm/damon/tests/vaddr-kunit.h~mm-damon-vaddr-add-nr_piece-==-1-check-in-damon_va_evenly_split_region +++ a/mm/damon/tests/vaddr-kunit.h @@ -300,6 +300,7 @@ static void damon_test_split_evenly(stru damon_test_split_evenly_fail(test, 0, 100, 0); damon_test_split_evenly_succ(test, 0, 100, 10); damon_test_split_evenly_succ(test, 5, 59, 5); + damon_test_split_evenly_succ(test, 4, 6, 1); damon_test_split_evenly_succ(test, 0, 3, 2); damon_test_split_evenly_fail(test, 5, 6, 2); } --- a/mm/damon/vaddr.c~mm-damon-vaddr-add-nr_piece-==-1-check-in-damon_va_evenly_split_region +++ a/mm/damon/vaddr.c @@ -72,6 +72,9 @@ static int damon_va_evenly_split_region( if (!r || !nr_pieces) return -EINVAL; + if (nr_pieces == 1) + return 0; + orig_end = r->ar.end; sz_orig = damon_sz_region(r); sz_piece = ALIGN_DOWN(sz_orig / nr_pieces, DAMON_MIN_REGION); _ Patches currently in -mm which might be from zhengyejian@xxxxxxxxxxxxxxx are mm-damon-vaddr-fix-issue-in-damon_va_evenly_split_region.patch mm-damon-vaddr-add-nr_piece-==-1-check-in-damon_va_evenly_split_region.patch