From: Zhou Chengming Date: Thu, 28 Jul 2016 22:48:35 +0000 (-0700) Subject: make __section_nr() more efficient X-Git-Tag: v4.14-rc1~2792^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91fd8b95d656dcd3f0a4e17b6583e7b0220b0747;p=platform%2Fkernel%2Flinux-rpi.git make __section_nr() more efficient When CONFIG_SPARSEMEM_EXTREME is disabled, __section_nr can get the section number with a subtraction directly. Link: http://lkml.kernel.org/r/1468988310-11560-1-git-send-email-zhouchengming1@huawei.com Signed-off-by: Zhou Chengming Cc: Dave Hansen Cc: Tejun Heo Cc: Hanjun Guo Cc: Li Bin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/sparse.c b/mm/sparse.c index 5d0cf45..36d7bbb 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -100,11 +100,7 @@ static inline int sparse_index_init(unsigned long section_nr, int nid) } #endif -/* - * Although written for the SPARSEMEM_EXTREME case, this happens - * to also work for the flat array case because - * NR_SECTION_ROOTS==NR_MEM_SECTIONS. - */ +#ifdef CONFIG_SPARSEMEM_EXTREME 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); } +#else +int __section_nr(struct mem_section* ms) +{ + return (int)(ms - mem_section[0]); +} +#endif /* * During early boot, before section_mem_map is used for an actual