Skip to content

Commit

Permalink
mm/migration: use helper macro min in do_pages_stat
Browse files Browse the repository at this point in the history
We could use helper macro min to help set the chunk_nr to simplify the
code.

Link: https://lkml.kernel.org/r/20220318111709.60311-7-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Miaohe Lin authored and akpm committed Apr 29, 2022
1 parent cb1c37b commit 3eefb82
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1842,16 +1842,12 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
const void __user * __user *pages,
int __user *status)
{
#define DO_PAGES_STAT_CHUNK_NR 16
#define DO_PAGES_STAT_CHUNK_NR 16UL
const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];
int chunk_status[DO_PAGES_STAT_CHUNK_NR];

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;
unsigned long chunk_nr = min(nr_pages, DO_PAGES_STAT_CHUNK_NR);

if (in_compat_syscall()) {
if (get_compat_pages_array(chunk_pages, pages,
Expand Down

0 comments on commit 3eefb82

Please sign in to comment.