From: Hannes Reinecke <hare@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: Oscar Salvador <osalvador@suse.de>,
linux-mm@kvack.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 0/2] mm/memory_hotplug: fixup crash during uevent handling
Date: Tue, 1 Jul 2025 13:41:52 +0200 [thread overview]
Message-ID: <20250701114155.16452-1-hare@kernel.org> (raw)
From: Hannes Reinecke <hare@suse.de>
Hi all,
we have some udev rules trying to read the sysfs attribute 'valid_zones' during
an memory 'add' event, causing a crash in zone_for_pfn_range(). Debugging found
that mem->nid was set to NUMA_NO_NODE, which crashed in NODE_DATA(nid).
Further analysis revealed that we're running into a race with udev event
processing: add_memory_resource() has this function calls:
1) __try_online_node()
2) arch_add_memory()
3) create_memory_block_devices()
-> calls device_register() -> memory 'add' event
4) node_set_online()/__register_one_node()
-> calls device_register() -> node 'add' event
5) register_memory_blocks_under_node()
-> sets mem->nid
Which, to the uninitated, is ... weird ...
Why do we try to online the node in 1), but only register
the node in 4) _after_ we have created the memory blocks in 3) ?
And why do we set the 'nid' value in 5), when the uevent
(which might need to see the correct 'nid' value) is sent out
in 3) ?
There must be a reason, I'm sure ...
So here's a small patchset to fixup uevent ordering.
The first patch adds a 'nid' parameter to add_memory_blocks()
(to avoid mem->nid being initialized with NUMA_NO_NODE), and
the second patch reshuffles the code in add_memory_resource()
to fully initialize the node prior to calling
create_memory_block_devices() so that the node is valid at
that time and uevent processing will see correct values in sysfs.
As usual, comments and reviews are welcome.
Hannes Reinecke (2):
drivers/base/memory: add node id parameter to add_memory_block()
mm/memory_hotplug: activate node before adding new memory blocks
drivers/base/memory.c | 32 ++++++++++++--------------------
include/linux/memory.h | 2 +-
mm/memory_hotplug.c | 32 +++++++++++++++++---------------
3 files changed, 30 insertions(+), 36 deletions(-)
--
2.43.0
next reply other threads:[~2025-07-01 11:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 11:41 Hannes Reinecke [this message]
2025-07-01 11:41 ` [PATCH 1/2] drivers/base/memory: add node id parameter to add_memory_block() Hannes Reinecke
2025-07-01 11:55 ` David Hildenbrand
2025-07-01 13:57 ` Oscar Salvador
2025-07-01 11:41 ` [PATCH 2/2] mm/memory_hotplug: activate node before adding new memory blocks Hannes Reinecke
2025-07-01 12:09 ` David Hildenbrand
2025-07-01 12:18 ` Hannes Reinecke
2025-07-01 14:02 ` Oscar Salvador
2025-07-01 18:52 ` Oscar Salvador
2025-07-01 18:55 ` Oscar Salvador
2025-07-01 19:23 ` David Hildenbrand
2025-07-02 5:24 ` Oscar Salvador
2025-07-02 6:25 ` Donet Tom
2025-07-02 6:36 ` David Hildenbrand
2025-07-02 7:52 ` Hannes Reinecke
2025-07-01 11:53 ` [PATCH 0/2] mm/memory_hotplug: fixup crash during uevent handling David Hildenbrand
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=20250701114155.16452-1-hare@kernel.org \
--to=hare@kernel.org \
--cc=david@redhat.com \
--cc=hare@suse.de \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.