[PATCH 07/16] mm/migration: use helper macro min_t in do_pages_stat

From: Miaohe Lin
Date: Fri Mar 04 2022 - 04:35:45 EST


We could use helper macro min_t to help set the chunk_nr to simplify
the code.

Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
---
mm/migrate.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index bc79d7338780..c84eec19072a 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1858,9 +1858,7 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
while (nr_pages) {
unsigned long chunk_nr;

- chunk_nr = nr_pages;
- if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
- chunk_nr = DO_PAGES_STAT_CHUNK_NR;
+ chunk_nr = min_t(unsigned long, nr_pages, DO_PAGES_STAT_CHUNK_NR);

if (in_compat_syscall()) {
if (get_compat_pages_array(chunk_pages, pages,
--
2.23.0