diff options
author | David Hildenbrand <david@redhat.com> | 2019-07-18 15:57:50 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-18 17:08:06 -0700 |
commit | ea8846411ad686ff626e00bb2c3821b3db2ab56a (patch) | |
tree | 8a2b9366c597e450d4f0a23c24e53136ea86f1ed /mm/memory_hotplug.c | |
parent | fbcf73ce65827c3d8935f38b832a43153a0c78d1 (diff) | |
download | linux-ea8846411ad686ff626e00bb2c3821b3db2ab56a.tar.bz2 |
mm/memory_hotplug: move and simplify walk_memory_blocks()
Let's move walk_memory_blocks() to the place where memory block logic
resides and simplify it. While at it, add a type for the callback
function.
Link: http://lkml.kernel.org/r/20190614100114.311-6-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Andrew Banman <andrew.banman@hpe.com>
Cc: Mike Travis <mike.travis@hpe.com>
Cc: Oscar Salvador <osalvador@suse.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Arun KS <arunks@codeaurora.org>
Cc: Qian Cai <cai@lca.pw>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory_hotplug.c')
-rw-r--r-- | mm/memory_hotplug.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b3ef84e408fa..fafee5f13ef2 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1659,62 +1659,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) { return __offline_pages(start_pfn, start_pfn + nr_pages); } -#endif /* CONFIG_MEMORY_HOTREMOVE */ -/** - * walk_memory_blocks - walk through all present memory blocks overlapped - * by the range [start, start + size) - * - * @start: start address of the memory range - * @size: size of the memory range - * @arg: argument passed to func - * @func: callback for each memory block walked - * - * This function walks through all present memory blocks overlapped by the - * range [start, start + size), calling func on each memory block. - * - * Returns the return value of func. - */ -int walk_memory_blocks(unsigned long start, unsigned long size, - void *arg, int (*func)(struct memory_block *, void *)) -{ - const unsigned long start_pfn = PFN_DOWN(start); - const unsigned long end_pfn = PFN_UP(start + size - 1); - struct memory_block *mem = NULL; - struct mem_section *section; - unsigned long pfn, section_nr; - int ret; - - for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { - section_nr = pfn_to_section_nr(pfn); - if (!present_section_nr(section_nr)) - continue; - - section = __nr_to_section(section_nr); - /* same memblock? */ - if (mem) - if ((section_nr >= mem->start_section_nr) && - (section_nr <= mem->end_section_nr)) - continue; - - mem = find_memory_block_hinted(section, mem); - if (!mem) - continue; - - ret = func(mem, arg); - if (ret) { - kobject_put(&mem->dev.kobj); - return ret; - } - } - - if (mem) - kobject_put(&mem->dev.kobj); - - return 0; -} - -#ifdef CONFIG_MEMORY_HOTREMOVE static int check_memblock_offlined_cb(struct memory_block *mem, void *arg) { int ret = !is_memblock_offlined(mem); |