From: Vlastimil Babka <vbabka@suse.cz>
To: Oscar Salvador <osalvador@suse.de>,
Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Rakie Kim <rakie.kim@sk.com>, Harry Yoo <harry.yoo@oracle.com>
Subject: Re: [PATCH v3 2/3] mm,memory_hotplug: Implement numa node notifier
Date: Mon, 5 May 2025 15:58:50 +0200 [thread overview]
Message-ID: <d70a95e2-78ab-4bb6-94f6-2adc56737adc@suse.cz> (raw)
In-Reply-To: <20250502083624.49849-3-osalvador@suse.de>
On 5/2/25 10:36, Oscar Salvador wrote:
> There are at least six 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 and vice versa.
>
> 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>
> Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Some cleanup suggestions below:
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index b1caedbade5b..777f98326908 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -701,24 +701,18 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)
>
> /* check which state of node_states will be changed when online memory */
> static void node_states_check_changes_online(unsigned long nr_pages,
> - struct zone *zone, struct memory_notify *arg)
> + struct zone *zone, struct node_notify *arg)
I've noticed nr_pages parameter is unused.
Also the function became rather trivial, you could just move the code into
its only caller now?
> {
> int nid = zone_to_nid(zone);
>
> arg->status_change_nid = NUMA_NO_NODE;
> - arg->status_change_nid_normal = NUMA_NO_NODE;
>
> if (!node_state(nid, N_MEMORY))
> arg->status_change_nid = nid;
> - if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY))
> - arg->status_change_nid_normal = nid;
> }
>
> -static void node_states_set_node(int node, struct memory_notify *arg)
> +static void node_states_set_node(int node, struct node_notify *arg)
This one too.
> {
> - if (arg->status_change_nid_normal >= 0)
> - node_set_state(node, N_NORMAL_MEMORY);
> -
> if (arg->status_change_nid >= 0)
> node_set_state(node, N_MEMORY);
> }
> @@ -1177,7 +1171,9 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
> int need_zonelists_rebuild = 0;
> const int nid = zone_to_nid(zone);
> int ret;
> - struct memory_notify arg;
> + struct memory_notify mem_arg;
> + struct node_notify node_arg;
> + bool cancel_mem_notifier_on_err = false, cancel_node_notifier_on_err = false;
>
> /*
> * {on,off}lining is constrained to full memory sections (or more
> @@ -1194,11 +1190,22 @@ int online_pages(unsigned long pfn, unsigned long nr_pages,
> /* associate pfn range with the zone */
> move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_ISOLATE);
>
> - arg.start_pfn = pfn;
> - arg.nr_pages = nr_pages;
> - node_states_check_changes_online(nr_pages, zone, &arg);
> + mem_arg.start_pfn = pfn;
> + mem_arg.nr_pages = nr_pages;
You could move the two lines below where the rest of mem_arg is filled.
> + node_states_check_changes_online(nr_pages, zone, &node_arg);
> +
> + if (node_arg.status_change_nid >= 0) {
> + /* Node is becoming memory aware. Notify consumers */
> + cancel_node_notifier_on_err = true;
> + ret = node_notify(NODE_BECOMING_MEM_AWARE, &node_arg);
> + ret = notifier_to_errno(ret);
> + if (ret)
> + goto failed_addition;
> + }
>
> - ret = memory_notify(MEM_GOING_ONLINE, &arg);
> + cancel_mem_notifier_on_err = true;
> + mem_arg.status_change_nid = node_arg.status_change_nid;
> + ret = memory_notify(MEM_GOING_ONLINE, &mem_arg);
> ret = notifier_to_errno(ret);
> if (ret)
> goto failed_addition;
next prev parent reply other threads:[~2025-05-05 13:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 8:36 [PATCH v3 0/3] " Oscar Salvador
2025-05-02 8:36 ` [PATCH v3 1/3] mm,slub: Do not special case N_NORMAL nodes for slab_nodes Oscar Salvador
2025-05-05 13:43 ` Vlastimil Babka
2025-05-02 8:36 ` [PATCH v3 2/3] mm,memory_hotplug: Implement numa node notifier Oscar Salvador
2025-05-02 15:28 ` Gregory Price
2025-05-05 14:51 ` Dan Carpenter
2025-05-28 2:23 ` Honggyu Kim
2025-06-03 9:14 ` Oscar Salvador
2025-05-02 19:09 ` ALOK TIWARI
2025-05-05 13:58 ` Vlastimil Babka [this message]
2025-05-02 8:36 ` [PATCH v3 3/3] mm,memory_hotplug: Rename status_change_nid parameter in memory_notify Oscar Salvador
2025-05-02 19:15 ` ALOK TIWARI
2025-05-04 3:03 ` [PATCH v3 0/3] Implement numa node notifier Andrew Morton
2025-05-04 5:44 ` Oscar Salvador
2025-05-04 6:16 ` Andrew Morton
2025-05-05 17:07 ` Gregory Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d70a95e2-78ab-4bb6-94f6-2adc56737adc@suse.cz \
--to=vbabka@suse.cz \
--cc=42.hyeyoo@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=harry.yoo@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=rakie.kim@sk.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®