Re: [Patch v2 2/4] mm/migrate.c: wrap do_move_pages_to_node() and store_status()

From: David Hildenbrand
Date: Wed Jan 29 2020 - 04:29:04 EST


On 29.01.20 01:38, Wei Yang wrote:
> On Tue, Jan 28, 2020 at 11:14:55AM +0100, David Hildenbrand wrote:
>> On 22.01.20 02:16, Wei Yang wrote:
>>> Usually do_move_pages_to_node() and store_status() is a pair. There are
>>> three places call this pair of functions with almost the same form.
>>
>> I'd suggest
>>
>> "
>> Usually, do_move_pages_to_node() and store_status() are used in
>> combination. We have three similar call sites.
>>
>> Let's provide a wrapper for both function calls -
>> move_pages_and_store_status - to make the calling code easier to
>> maintain and fix (as noted by Yang Shi, the return value handling of
>> do_move_pages_to_node() has a flaw).
>> "
>
> Looks good.
>
>>
>>>
>>> This patch just wrap it to make it friendly to audience and also
>>> consolidate the move and store action into one place. Also mentioned by
>>> Yang Shi, the handling of do_move_pages_to_node()'s return value is not
>>> proper. Now we can fix it in one place.
>>>
>>> Signed-off-by: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>
>>> Acked-by: Michal Hocko <mhocko@xxxxxxxx>
>>> ---
>>> mm/migrate.c | 30 +++++++++++++++++++-----------
>>> 1 file changed, 19 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/mm/migrate.c b/mm/migrate.c
>>> index 4c2a21856717..a4d3bd6475e1 100644
>>> --- a/mm/migrate.c
>>> +++ b/mm/migrate.c
>>> @@ -1583,6 +1583,19 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr,
>>> return err;
>>> }
>>>
>>> +static int move_pages_and_store_status(struct mm_struct *mm, int node,
>>> + struct list_head *pagelist, int __user *status,
>>> + int start, int nr)
>>
>> nit: indentation
>>
>
> You mean indent like this?
>
> static int move_pages_and_store_status(struct mm_struct *mm, int node,
> struct list_head *pagelist,
> int __user *status,
>
> This would be along list and I am afraid this is not the only valid code
> style?

Yes, that's what I meant. Documentation/process/coding-style.rst doesn't
mention any specific way, but this is the most commonly used one.

Indentation in this file mostly sticks to something like this as well,
but yeah, it's often a mess and not consistent.

That's why I note it whenever I see it, to make it eventually more
consistent (and only make it a nit) :)

--
Thanks,

David / dhildenb