The patch titled Subject: lib: test_hmm: use min() to improve dmirror_exclusive() has been added to the -mm mm-unstable branch. Its filename is lib-test_hmm-use-min-to-improve-dmirror_exclusive.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-test_hmm-use-min-to-improve-dmirror_exclusive.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: Thorsten Blum <thorsten.blum@xxxxxxxxxx> Subject: lib: test_hmm: use min() to improve dmirror_exclusive() Date: Fri, 26 Jul 2024 15:12:46 +0200 Use min() to simplify the dmirror_exclusive() function and improve its readability. Link: https://lkml.kernel.org/r/20240726131245.161695-1-thorsten.blum@xxxxxxxxxx Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxxx> Cc: Jérôme Glisse <jglisse@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/test_hmm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/lib/test_hmm.c~lib-test_hmm-use-min-to-improve-dmirror_exclusive +++ a/lib/test_hmm.c @@ -799,10 +799,7 @@ static int dmirror_exclusive(struct dmir unsigned long mapped = 0; int i; - if (end < addr + (ARRAY_SIZE(pages) << PAGE_SHIFT)) - next = end; - else - next = addr + (ARRAY_SIZE(pages) << PAGE_SHIFT); + next = min(end, addr + (ARRAY_SIZE(pages) << PAGE_SHIFT)); ret = make_device_exclusive_range(mm, addr, next, pages, NULL); /* _ Patches currently in -mm which might be from thorsten.blum@xxxxxxxxxx are lib-test_hmm-use-min-to-improve-dmirror_exclusive.patch lib-checksum-use-array_size-to-improve-assert_setup_correct.patch