Re: [PATCH v1] drivers/base/node.c: get rid of get_nid_for_pfn()

From: David Hildenbrand
Date: Thu Nov 28 2019 - 06:23:19 EST


On 28.11.19 11:25, David Hildenbrand wrote:
>
>
>> Am 28.11.2019 um 11:20 schrieb Michal Hocko <mhocko@xxxxxxxxxx>:
>>
>> ïOn Wed 27-11-19 18:41:26, David Hildenbrand wrote:
>>> Since commit d84f2f5a7552 ("drivers/base/node.c: simplify
>>> unregister_memory_block_under_nodes()") we only have a single user of
>>> get_nid_for_pfn(). Let's just inline that code and get rid of
>>> get_nid_for_pfn().
>>>
>>> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
>>> Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
>>> Cc: Michal Hocko <mhocko@xxxxxxxxxx>
>>> Cc: Oscar Salvador <osalvador@xxxxxxx>
>>> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>>> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
>>
>> I am not really sure this is an improvement. The code is ugly as hell
>> and open coding it just makes register_mem_sect_under_node harder to
>> read.
>
> The issue I see is that this is a dangerous wrapper for pfn_to_nid() that is absolutely not obvious. The old second user on the memory removal path was completely buggy. IMHO nobody should be reusing that function. But it looks like a general âsafe wrapper to get a nidâ - itâs not.
>
> How can we make that more obvious instead?
>

What about something like this (untested):