Skip to content

mm/memory_hotplug: fixup crash during uevent handling

Hannes Reinecke linux-mm 4 versions – Applied

Status from this message: [merged mm-stable] drivers-base-move-memory_block_add_nid-into-the-caller.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 4 repliesApplied 3/3
  2. v33 patches 5 repliesSuperseded
  3. v23 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches13 repliesSuperseded

Changes to v2 from the cover letter

- Move changes to nid setting into the last patch
- Add reviews from David Hildenbrand

Patches in v4 All 3 applied

#Subject and filesSizeRepliesApplied
1/3drivers/base/memory: add node id parameter to add_memory_block()drivers/base/memory.c+4 -110 repliesApplied
2/3mm/memory_hotplug: activate node before adding new memory blocksdrivers/base/memory.c include/linux/memory.h mm/memory_hotplug.c+20 -180 repliesApplied
3/3drivers/base: move memory_block_add_nid() into the callerdrivers/base/memory.c drivers/base/node.c include/linux/memory.h+23 -260 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchDavid HildenbrandOscar SalvadorDonet Tom
1/3A-b A-b R-b
2/3A-b A-b R-b
3/3A-b A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v4 thread

Cover letter [PATCHv4 0/3] mm/memory_hotplug: fixup crash during uevent handling

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.

Changes to the original submission:
- Add patch to rename memory_block_add_nid()
- Add reviews

Changes to v2:
- Move changes to nid setting into the last patch
- Add reviews from David Hildenbrand

Changes to v3:
- Add reviews
- Rebase to mm-unstable

Hannes Reinecke (3):
drivers/base/memory: add node id parameter to add_memory_block() mm/memory_hotplug: activate node before adding new memory blocks drivers/base: move memory_block_add_nid() into the caller

 drivers/base/memory.c  | 53 ++++++++++++++++++------------------------
 drivers/base/node.c    | 10 ++++----
 include/linux/memory.h |  5 ++--
 mm/memory_hotplug.c    | 32 +++++++++++++------------
 4 files changed, 46 insertions(+), 54 deletions(-)
Signature · 1 line
2.43.0