Skip to content

Commit 8b0662f

Browse files
Michal Hockotorvalds
authored andcommitted
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. Link: http://lkml.kernel.org/r/20170515085827.16474-7-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Reported-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Daniel Kiper <daniel.kiper@oracle.com> Cc: David Rientjes <rientjes@google.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Reza Arbab <arbab@linux.vnet.ibm.com> Cc: Tobias Regnery <tobias.regnery@gmail.com> Cc: Toshi Kani <toshi.kani@hpe.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: Xishi Qiu <qiuxishi@huawei.com> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9037a99 commit 8b0662f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/base/memory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ static ssize_t show_mem_removable(struct device *dev,
128128
int ret = 1;
129129
struct memory_block *mem = to_memory_block(dev);
130130

131+
if (mem->state != MEM_ONLINE)
132+
goto out;
133+
131134
for (i = 0; i < sections_per_block; i++) {
132135
if (!present_section_nr(mem->start_section_nr + i))
133136
continue;
134137
pfn = section_nr_to_pfn(mem->start_section_nr + i);
135138
ret &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
136139
}
137140

141+
out:
138142
return sprintf(buf, "%d\n", ret);
139143
}
140144

0 commit comments

Comments
 (0)