Patch "drivers/base/node.c: simplify unregister_memory_block_under_nodes()" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drivers/base/node.c: simplify unregister_memory_block_under_nodes()

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drivers-base-node.c-simplify-unregister_memory_block_under_nodes.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From foo@baz Tue 28 Jan 2020 02:32:10 PM CET
From: David Hildenbrand <david@xxxxxxxxxx>
Date: Tue, 28 Jan 2020 10:50:18 +0100
Subject: drivers/base/node.c: simplify unregister_memory_block_under_nodes()
To: stable@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx, Michal Hocko <mhocko@xxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, "Aneesh Kumar K . V" <aneesh.kumar@xxxxxxxxxxxxx>, Baoquan He <bhe@xxxxxxxxxx>, Dan Williams <dan.j.williams@xxxxxxxxx>, Oscar Salvador <osalvador@xxxxxxx>, Wei Yang <richard.weiyang@xxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>
Message-ID: <20200128095021.8076-22-david@xxxxxxxxxx>

From: David Hildenbrand <david@xxxxxxxxxx>

commit d84f2f5a755208da3f93e17714631485cb3da11c upstream.

We don't allow to offline memory block devices that belong to multiple
numa nodes.  Therefore, such devices can never get removed.  It is
sufficient to process a single node when removing the memory block.  No
need to iterate over each and every PFN.

We already have the nid stored for each memory block.  Make sure that the
nid always has a sane value.

Please note that checking for node_online(nid) is not required.  If we
would have a memory block belonging to a node that is no longer offline,
then we would have a BUG in the node offlining code.

Link: http://lkml.kernel.org/r/20190719135244.15242-1-david@xxxxxxxxxx
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Oscar Salvador <osalvador@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/base/memory.c |    1 +
 drivers/base/node.c   |   39 +++++++++++++++------------------------
 2 files changed, 16 insertions(+), 24 deletions(-)

--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -693,6 +693,7 @@ static int init_memory_block(struct memo
 	mem->state = state;
 	start_pfn = section_nr_to_pfn(mem->start_section_nr);
 	mem->phys_device = arch_get_memory_phys_device(start_pfn);
+	mem->nid = NUMA_NO_NODE;
 
 	ret = register_memory(mem);
 
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -409,8 +409,6 @@ int register_mem_sect_under_node(struct
 	int ret, nid = *(int *)arg;
 	unsigned long pfn, sect_start_pfn, sect_end_pfn;
 
-	mem_blk->nid = nid;
-
 	sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr);
 	sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr);
 	sect_end_pfn += PAGES_PER_SECTION - 1;
@@ -439,6 +437,13 @@ int register_mem_sect_under_node(struct
 			if (page_nid != nid)
 				continue;
 		}
+
+		/*
+		 * If this memory block spans multiple nodes, we only indicate
+		 * the last processed node.
+		 */
+		mem_blk->nid = nid;
+
 		ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
 					&mem_blk->dev.kobj,
 					kobject_name(&mem_blk->dev.kobj));
@@ -454,32 +459,18 @@ int register_mem_sect_under_node(struct
 }
 
 /*
- * Unregister memory block device under all nodes that it spans.
- * Has to be called with mem_sysfs_mutex held (due to unlinked_nodes).
+ * Unregister a memory block device under the node it spans. Memory blocks
+ * with multiple nodes cannot be offlined and therefore also never be removed.
  */
 void unregister_memory_block_under_nodes(struct memory_block *mem_blk)
 {
-	unsigned long pfn, sect_start_pfn, sect_end_pfn;
-	static nodemask_t unlinked_nodes;
-
-	nodes_clear(unlinked_nodes);
-	sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr);
-	sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr);
-	for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
-		int nid;
+	if (mem_blk->nid == NUMA_NO_NODE)
+		return;
 
-		nid = get_nid_for_pfn(pfn);
-		if (nid < 0)
-			continue;
-		if (!node_online(nid))
-			continue;
-		if (node_test_and_set(nid, unlinked_nodes))
-			continue;
-		sysfs_remove_link(&node_devices[nid]->dev.kobj,
-			 kobject_name(&mem_blk->dev.kobj));
-		sysfs_remove_link(&mem_blk->dev.kobj,
-			 kobject_name(&node_devices[nid]->dev.kobj));
-	}
+	sysfs_remove_link(&node_devices[mem_blk->nid]->dev.kobj,
+			  kobject_name(&mem_blk->dev.kobj));
+	sysfs_remove_link(&mem_blk->dev.kobj,
+			  kobject_name(&node_devices[mem_blk->nid]->dev.kobj));
 }
 
 int link_mem_sections(int nid, unsigned long start_pfn, unsigned long end_pfn)


Patches currently in stable-queue which might be from david@xxxxxxxxxx are

queue-4.19/mm-memory_hotplug-remove-memory-block-devices-before-arch_remove_memory.patch
queue-4.19/mm-hotplug-kill-is_dev_zone-usage-in-__remove_pages.patch
queue-4.19/mm-memory_hotplug-create-memory-block-devices-after-arch_add_memory.patch
queue-4.19/drivers-base-memory-pass-a-block_id-to-init_memory_block.patch
queue-4.19/drivers-base-memory.c-clean-up-relics-in-function-parameters.patch
queue-4.19/mm-memory_hotplug-update-a-comment-in-unregister_memory.patch
queue-4.19/mm-memory_hotplug-shrink-zones-when-offlining-memory.patch
queue-4.19/mm-memory_hotplug-make-unregister_memory_block_under_nodes-never-fail.patch
queue-4.19/mm-memunmap-don-t-access-uninitialized-memmap-in-memunmap_pages.patch
queue-4.19/mm-memory_hotplug-make-__remove_section-never-fail.patch
queue-4.19/mm-sparse-drop-pgdat_resize_lock-in-sparse_add-remove_one_section.patch
queue-4.19/mm-memory_hotplug-make-unregister_memory_section-never-fail.patch
queue-4.19/mm-memory_hotplug-release-memory-resource-after-arch_remove_memory.patch
queue-4.19/mm-memory_hotplug-add-nid-parameter-to-arch_remove_memory.patch
queue-4.19/powerpc-mm-fix-section-mismatch-warning.patch
queue-4.19/mm-memory_hotplug-allow-arch_remove_memory-without-config_memory_hotremove.patch
queue-4.19/mm-memory_hotplug-make-remove_memory-take-the-device_hotplug_lock.patch
queue-4.19/mm-memory_hotplug-make-__remove_pages-and-arch_remove_memory-never-fail.patch
queue-4.19/mm-memory_hotplug-fix-try_offline_node.patch
queue-4.19/mm-memory_hotplug-remove-zone-parameter-from-sparse_remove_one_section.patch
queue-4.19/drivers-base-memory.c-remove-an-unnecessary-check-on-nr_mem_sections.patch
queue-4.19/drivers-base-node.c-simplify-unregister_memory_block_under_nodes.patch
queue-4.19/s390x-mm-implement-arch_remove_memory.patch
queue-4.19/mm-sparse-pass-nid-instead-of-pgdat-to-sparse_add_one_section.patch





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux