diff options
| author | Ohhoon Kwon <[email protected]> | 2021-09-02 21:57:01 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2021-09-03 16:58:14 +0000 |
| commit | fc1f5e980a463325cf41d39ac6a69aa3cca73995 (patch) | |
| tree | 79507c488549d1a0c253e3d2b67d9fb24c093637 /drivers/base/memory.c | |
| parent | mm: sparse: pass section_nr to section_mark_present (diff) | |
| download | kernel-fc1f5e980a463325cf41d39ac6a69aa3cca73995.tar.gz kernel-fc1f5e980a463325cf41d39ac6a69aa3cca73995.zip | |
mm: sparse: pass section_nr to find_memory_block
With CONFIG_SPARSEMEM_EXTREME enabled, __section_nr() which converts
mem_section to section_nr could be costly since it iterates all section
roots to check if the given mem_section is in its range.
On the other hand, __nr_to_section() which converts section_nr to
mem_section can be done in O(1).
Let's pass section_nr instead of mem_section ptr to find_memory_block() in
order to reduce needless iterations.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ohhoon Kwon <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Acked-by: Mike Rapoport <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Cc: Baoquan He <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'drivers/base/memory.c')
| -rw-r--r-- | drivers/base/memory.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index aa31a21f33d7..e3fd2dbf4eea 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -578,9 +578,9 @@ static struct memory_block *find_memory_block_by_id(unsigned long block_id) /* * Called under device_hotplug_lock. */ -struct memory_block *find_memory_block(struct mem_section *section) +struct memory_block *find_memory_block(unsigned long section_nr) { - unsigned long block_id = memory_block_id(__section_nr(section)); + unsigned long block_id = memory_block_id(section_nr); return find_memory_block_by_id(block_id); } |
