Skip to contentSkip to conversation

mm, memory_hotplug: consider offline memblocks removable

PATCH New [email protected] 1 participant 1 message Jul 6, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 48/108 mm, memory_hotplug: consider offline memblocks removable

From: Michal Hocko <[email protected]>
Subject: mm, memory_hotplug: consider offline memblocks removable

is_pageblock_removable_nolock() relies on having zone association to examine all the page blocks to check whether they are movable or free. This is just wasting of cycles when the memblock is offline. Later patch in the series will also change the time when the page is associated with a zone so we let's bail out early if the memblock is offline.

Cc Andi Kleen <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Balbir Singh <[email protected]>
Cc Dan Williams <[email protected]>
Cc Daniel Kiper <[email protected]>
Cc David Rientjes <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Jerome Glisse <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Reza Arbab <[email protected]>
Cc Tobias Regnery <[email protected]>
Cc Toshi Kani <[email protected]>
Cc Vitaly Kuznetsov <[email protected]>
Cc Xishi Qiu <[email protected]>
Cc Yasuaki Ishimatsu <[email protected]>

---

 drivers/base/memory.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/base/memory.c renamed from drivers/base/memory.c~mm-memory_hotplug-consider-offline-memblocks-removable +4 -0
diff -puN drivers/base/memory.c~mm-memory_hotplug-consider-offline-memblocks-removable drivers/base/memory.c
@@ -128,6 +128,9 @@ static ssize_t show_mem_removable(struct
 	int ret = 1;
 	struct memory_block *mem = to_memory_block(dev);
 
+	if (mem->state != MEM_ONLINE)
+		goto out;
+
 	for (i = 0; i < sections_per_block; i++) {
 		if (!present_section_nr(mem->start_section_nr + i))
 			continue;
@@ -135,6 +138,7 @@ static ssize_t show_mem_removable(struct
 		ret &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
 	}
 
+out:
 	return sprintf(buf, "%d\n", ret);
 }
 

_