diff options
author | David Hildenbrand <david@redhat.com> | 2019-09-23 18:35:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-24 18:54:09 -0400 |
commit | b6c88d3b9d38f9448e0fcf44847a075ea81d5ca2 (patch) | |
tree | ba7ccb02002fd017c8632a0698032c598ef090e7 | |
parent | 902ce63b337381092ff865f542e854ff3d0ebe2b (diff) |
drivers/base/memory.c: don't store end_section_nr in memory blocks
Each memory block spans the same amount of sections/pages/bytes. The size
is determined before the first memory block is created. No need to store
what we can easily calculate - and the calculations even look simpler now.
Michal brought up the idea of variable-sized memory blocks. However, if
we ever implement something like this, we will need an API compatibility
switch and reworks at various places (most code assumes a fixed memory
block size). So let's cleanup what we have right now.
While at it, fix the variable naming in register_mem_sect_under_node() -
we no longer talk about a single section.
Link: http://lkml.kernel.org/r/20190809110200.2746-1-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/base/memory.c | 1 | ||||
-rw-r--r-- | drivers/base/node.c | 10 | ||||
-rw-r--r-- | include/linux/memory.h | 1 | ||||
-rw-r--r-- | mm/memory_hotplug.c | 2 |
4 files changed, 6 insertions, 8 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 763154c82eb3..6bea4f3f8040 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -656,7 +656,6 @@ static int init_memory_block(struct memory_block **memory, | |||
656 | return -ENOMEM; | 656 | return -ENOMEM; |
657 | 657 | ||
658 | mem->start_section_nr = block_id * sections_per_block; | 658 | mem->start_section_nr = block_id * sections_per_block; |
659 | mem->end_section_nr = mem->start_section_nr + sections_per_block - 1; | ||
660 | mem->state = state; | 659 | mem->state = state; |
661 | start_pfn = section_nr_to_pfn(mem->start_section_nr); | 660 | start_pfn = section_nr_to_pfn(mem->start_section_nr); |
662 | mem->phys_device = arch_get_memory_phys_device(start_pfn); | 661 | mem->phys_device = arch_get_memory_phys_device(start_pfn); |
diff --git a/drivers/base/node.c b/drivers/base/node.c index 840c95baa1d8..257449cf061f 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -756,13 +756,13 @@ static int __ref get_nid_for_pfn(unsigned long pfn) | |||
756 | static int register_mem_sect_under_node(struct memory_block *mem_blk, | 756 | static int register_mem_sect_under_node(struct memory_block *mem_blk, |
757 | void *arg) | 757 | void *arg) |
758 | { | 758 | { |
759 | unsigned long memory_block_pfns = memory_block_size_bytes() / PAGE_SIZE; | ||
760 | unsigned long start_pfn = section_nr_to_pfn(mem_blk->start_section_nr); | ||
761 | unsigned long end_pfn = start_pfn + memory_block_pfns - 1; | ||
759 | int ret, nid = *(int *)arg; | 762 | int ret, nid = *(int *)arg; |
760 | unsigned long pfn, sect_start_pfn, sect_end_pfn; | 763 | unsigned long pfn; |
761 | 764 | ||
762 | sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr); | 765 | for (pfn = start_pfn; pfn <= end_pfn; pfn++) { |
763 | sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr); | ||
764 | sect_end_pfn += PAGES_PER_SECTION - 1; | ||
765 | for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) { | ||
766 | int page_nid; | 766 | int page_nid; |
767 | 767 | ||
768 | /* | 768 | /* |
diff --git a/include/linux/memory.h b/include/linux/memory.h index b3d9df060626..0ebb105eb261 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h | |||
@@ -25,7 +25,6 @@ | |||
25 | 25 | ||
26 | struct memory_block { | 26 | struct memory_block { |
27 | unsigned long start_section_nr; | 27 | unsigned long start_section_nr; |
28 | unsigned long end_section_nr; | ||
29 | unsigned long state; /* serialized by the dev->lock */ | 28 | unsigned long state; /* serialized by the dev->lock */ |
30 | int section_count; /* serialized by mem_sysfs_mutex */ | 29 | int section_count; /* serialized by mem_sysfs_mutex */ |
31 | int online_type; /* for passing data to online routine */ | 30 | int online_type; /* for passing data to online routine */ |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 5b8811945bbb..3706a137d880 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -1654,7 +1654,7 @@ static int check_memblock_offlined_cb(struct memory_block *mem, void *arg) | |||
1654 | phys_addr_t beginpa, endpa; | 1654 | phys_addr_t beginpa, endpa; |
1655 | 1655 | ||
1656 | beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr)); | 1656 | beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr)); |
1657 | endpa = PFN_PHYS(section_nr_to_pfn(mem->end_section_nr + 1))-1; | 1657 | endpa = beginpa + memory_block_size_bytes() - 1; |
1658 | pr_warn("removing memory fails, because memory [%pa-%pa] is onlined\n", | 1658 | pr_warn("removing memory fails, because memory [%pa-%pa] is onlined\n", |
1659 | &beginpa, &endpa); | 1659 | &beginpa, &endpa); |
1660 | 1660 | ||