Re: [PATCH 1/2] mm,memory_hotplug: Implement numa node notifier

Jonathan Cameron
2025-04-03T12:44:20Z

On Tue, 1 Apr 2025 11:27:15 +0200
Oscar Salvador <osalvador@suse.de> wrote:

> There are at least four consumers of hotplug_memory_notifier that what they
> really are interested in is whether any numa node changed its state, e.g: going
> from being memory aware to becoming memoryless.

Cover letter says 5. Whilst that's at least 4, maybe update this if you do
a v2 to say at least 5 :)

>
> Implement a specific notifier for numa nodes when their state gets changed,
> and have those consumers that only care about numa node state changes use it.
>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>

A couple of trivial things below. To me this looks fine otherwise.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> +#define hotplug_node_notifier(fn, pri) ({ \
> + static __meminitdata struct notifier_block fn##_node_nb =\
> + { .notifier_call = fn, .priority = pri };\
> + register_node_notifier(&fn##_node_nb); \
> +})

Trivial but spacing before \ seems rather random. Maybe I'm missing
how it is consistent.

> +
> #ifdef CONFIG_NUMA
> void memory_block_add_nid(struct memory_block *mem, int nid,
> enum meminit_context context);

> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 75401866fb76..4bb9ff282ec9 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c

> @@ -2106,27 +2143,32 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
> * Make sure to mark the node as memory-less before rebuilding the zone
> * list. Otherwise this node would still appear in the fallback lists.
> */
> - node_states_clear_node(node, &arg);
> + node_states_clear_node(node, &node_arg);
> if (!populated_zone(zone)) {
> zone_pcp_reset(zone);
> build_all_zonelists(NULL);
> }
>
> - if (arg.status_change_nid >= 0) {
> + if (node_arg.status_change_nid >= 0) {
> kcompactd_stop(node);
> kswapd_stop(node);
> + /*Node went memoryless. Notifiy interested consumers */

Trivial: missing space after *

> + node_notify(NODE_BECAME_MEMORYLESS, &node_arg);
> }
>
> writeback_set_ratelimit();
>
> - memory_notify(MEM_OFFLINE, &arg);
> + memory_notify(MEM_OFFLINE, &mem_arg);
> remove_pfn_range_from_zone(zone, start_pfn, nr_pages);
> return 0;
>
> failed_removal_isolated:
> /* pushback to free area */
> undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
> - memory_notify(MEM_CANCEL_OFFLINE, &arg);
> + if (cancel_node_notifier_on_err)
> + node_notify(NODE_CANCEL_MEMORYLESS, &node_arg);
> + if (cancel_mem_notifier_on_err)
> + memory_notify(MEM_CANCEL_OFFLINE, &mem_arg);
> failed_removal_pcplists_disabled:
> lru_cache_enable();
> zone_pcp_enable(zone);