aboutsummaryrefslogtreecommitdiffstats
path: root/mm/sparse.c
diff options
context:
space:
mode:
authorZhou Chengming <[email protected]>2016-07-28 22:48:35 +0000
committerLinus Torvalds <[email protected]>2016-07-28 23:07:41 +0000
commit91fd8b95d656dcd3f0a4e17b6583e7b0220b0747 (patch)
tree8e33bf623881a0471ff611f3176f603cc27efe7d /mm/sparse.c
parentkmemleak: don't hang if user disables scanning early (diff)
downloadkernel-91fd8b95d656dcd3f0a4e17b6583e7b0220b0747.tar.gz
kernel-91fd8b95d656dcd3f0a4e17b6583e7b0220b0747.zip
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/[email protected] Signed-off-by: Zhou Chengming <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Hanjun Guo <[email protected]> Cc: Li Bin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'mm/sparse.c')
-rw-r--r--mm/sparse.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mm/sparse.c b/mm/sparse.c
index 5d0cf4540364..36d7bbb80e49 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