[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f790b69f-f94d-72f9-ac58-765df9286f04@huawei.com>
Date: Mon, 7 Mar 2022 19:51:04 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: <mike.kravetz@...cle.com>, <shy828301@...il.com>,
<willy@...radead.org>, <ying.huang@...el.com>, <ziy@...dia.com>,
<minchan@...nel.org>, <apopple@...dia.com>,
<ave.hansen@...ux.intel.com>, <o451686892@...il.com>,
<almasrymina@...gle.com>, <jhubbard@...dia.com>,
<rcampbell@...dia.com>, <peterx@...hat.com>,
<naoya.horiguchi@....com>, <mhocko@...e.com>, <riel@...hat.com>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 07/16] mm/migration: use helper macro min_t in
do_pages_stat
On 2022/3/7 9:14, Andrew Morton wrote:
> On Fri, 4 Mar 2022 17:34:00 +0800 Miaohe Lin <linmiaohe@...wei.com> wrote:
>
>> We could use helper macro min_t to help set the chunk_nr to simplify
>> the code.
>>
>> ...
>>
>> --- 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,
>
> Getting the types correct is better than using min_t().
>
Looks good. Many thanks for your suggestion. Will do it in v2.
Thanks.
> --- a/mm/migrate.c~mm-migration-use-helper-macro-min_t-in-do_pages_stat-fix
> +++ a/mm/migrate.c
> @@ -1844,14 +1844,12 @@ static int do_pages_stat(struct mm_struc
> 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 = min_t(unsigned long, nr_pages, 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,
> _
>
> .
>
Powered by blists - more mailing lists