diff options
author | Oscar Salvador <osalvador@suse.de> | 2018-08-17 18:46:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-17 19:20:29 -0400 |
commit | 4fbce633910ed80b135b84160a22b219080c8082 (patch) | |
tree | 719985a2f3a69277b26a6e3ba124829b7bf44eee /drivers/base/node.c | |
parent | d5b6f6a3610b05e6712cb9c61a85a6dff16e91cf (diff) |
mm/memory_hotplug.c: make register_mem_sect_under_node() a callback of walk_memory_range()
link_mem_sections() and walk_memory_range() share most of the code, so
we can use convert link_mem_sections() into a dummy function that calls
walk_memory_range() with a callback to register_mem_sect_under_node().
This patch converts register_mem_sect_under_node() in order to match a
walk_memory_range's callback, getting rid of the check_nid argument and
checking instead if the system is still boothing, since we only have to
check for the nid if the system is in such state.
Link: http://lkml.kernel.org/r/20180622111839.10071-4-osalvador@techadventures.net
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Suggested-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Tested-by: Reza Arbab <arbab@linux.vnet.ibm.com>
Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Pavel Tatashin <pavel.tatashin@microsoft.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base/node.c')
-rw-r--r-- | drivers/base/node.c | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index a5e821d09656..845d5523812b 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -399,10 +399,9 @@ static int __ref get_nid_for_pfn(unsigned long pfn) | |||
399 | } | 399 | } |
400 | 400 | ||
401 | /* register memory section under specified node if it spans that node */ | 401 | /* register memory section under specified node if it spans that node */ |
402 | int register_mem_sect_under_node(struct memory_block *mem_blk, int nid, | 402 | int register_mem_sect_under_node(struct memory_block *mem_blk, void *arg) |
403 | bool check_nid) | ||
404 | { | 403 | { |
405 | int ret; | 404 | int ret, nid = *(int *)arg; |
406 | unsigned long pfn, sect_start_pfn, sect_end_pfn; | 405 | unsigned long pfn, sect_start_pfn, sect_end_pfn; |
407 | 406 | ||
408 | if (!mem_blk) | 407 | if (!mem_blk) |
@@ -433,7 +432,7 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid, | |||
433 | * case, during hotplug we know that all pages in the memory | 432 | * case, during hotplug we know that all pages in the memory |
434 | * block belong to the same node. | 433 | * block belong to the same node. |
435 | */ | 434 | */ |
436 | if (check_nid) { | 435 | if (system_state == SYSTEM_BOOTING) { |
437 | page_nid = get_nid_for_pfn(pfn); | 436 | page_nid = get_nid_for_pfn(pfn); |
438 | if (page_nid < 0) | 437 | if (page_nid < 0) |
439 | continue; | 438 | continue; |
@@ -490,41 +489,10 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, | |||
490 | return 0; | 489 | return 0; |
491 | } | 490 | } |
492 | 491 | ||
493 | int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages, | 492 | int link_mem_sections(int nid, unsigned long start_pfn, unsigned long end_pfn) |
494 | bool check_nid) | ||
495 | { | 493 | { |
496 | unsigned long end_pfn = start_pfn + nr_pages; | 494 | return walk_memory_range(start_pfn, end_pfn, (void *)&nid, |
497 | unsigned long pfn; | 495 | register_mem_sect_under_node); |
498 | struct memory_block *mem_blk = NULL; | ||
499 | int err = 0; | ||
500 | |||
501 | for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { | ||
502 | unsigned long section_nr = pfn_to_section_nr(pfn); | ||
503 | struct mem_section *mem_sect; | ||
504 | int ret; | ||
505 | |||
506 | if (!present_section_nr(section_nr)) | ||
507 | continue; | ||
508 | mem_sect = __nr_to_section(section_nr); | ||
509 | |||
510 | /* same memblock ? */ | ||
511 | if (mem_blk) | ||
512 | if ((section_nr >= mem_blk->start_section_nr) && | ||
513 | (section_nr <= mem_blk->end_section_nr)) | ||
514 | continue; | ||
515 | |||
516 | mem_blk = find_memory_block_hinted(mem_sect, mem_blk); | ||
517 | |||
518 | ret = register_mem_sect_under_node(mem_blk, nid, check_nid); | ||
519 | if (!err) | ||
520 | err = ret; | ||
521 | |||
522 | /* discard ref obtained in find_memory_block() */ | ||
523 | } | ||
524 | |||
525 | if (mem_blk) | ||
526 | kobject_put(&mem_blk->dev.kobj); | ||
527 | return err; | ||
528 | } | 496 | } |
529 | 497 | ||
530 | #ifdef CONFIG_HUGETLBFS | 498 | #ifdef CONFIG_HUGETLBFS |