Commit 91fd8b95 authored by Zhou Chengming's avatar Zhou Chengming Committed by Linus Torvalds

make __section_nr() more efficient

When CONFIG_SPARSEMEM_EXTREME is disabled, __section_nr can get the
section number with a subtraction directly.

Link: default avatarZhou Chengming <>
Cc: Dave Hansen <>
Cc: Tejun Heo <>
Cc: Hanjun Guo <>
Cc: Li Bin <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 98c42d94
......@@ -100,11 +100,7 @@ static inline int sparse_index_init(unsigned long section_nr, int nid)
* Although written for the SPARSEMEM_EXTREME case, this happens
* to also work for the flat array case because
int __section_nr(struct mem_section* ms)
unsigned long root_nr;
......@@ -123,6 +119,12 @@ int __section_nr(struct mem_section* ms)
return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
int __section_nr(struct mem_section* ms)
return (int)(ms - mem_section[0]);
* During early boot, before section_mem_map is used for an actual
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment