diff options
author | Zhou Chengming <zhouchengming1@huawei.com> | 2016-07-28 18:48:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-28 19:07:41 -0400 |
commit | 91fd8b95d656dcd3f0a4e17b6583e7b0220b0747 (patch) | |
tree | 8e33bf623881a0471ff611f3176f603cc27efe7d | |
parent | 98c42d945238c55ab56e5716e89553fb7de45b66 (diff) |
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 <zhouchengming1@huawei.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Li Bin <huawei.libin@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/sparse.c | 12 |
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) | |||
100 | } | 100 | } |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | /* | 103 | #ifdef CONFIG_SPARSEMEM_EXTREME |
104 | * Although written for the SPARSEMEM_EXTREME case, this happens | ||
105 | * to also work for the flat array case because | ||
106 | * NR_SECTION_ROOTS==NR_MEM_SECTIONS. | ||
107 | */ | ||
108 | int __section_nr(struct mem_section* ms) | 104 | int __section_nr(struct mem_section* ms) |
109 | { | 105 | { |
110 | unsigned long root_nr; | 106 | unsigned long root_nr; |
@@ -123,6 +119,12 @@ int __section_nr(struct mem_section* ms) | |||
123 | 119 | ||
124 | return (root_nr * SECTIONS_PER_ROOT) + (ms - root); | 120 | return (root_nr * SECTIONS_PER_ROOT) + (ms - root); |
125 | } | 121 | } |
122 | #else | ||
123 | int __section_nr(struct mem_section* ms) | ||
124 | { | ||
125 | return (int)(ms - mem_section[0]); | ||
126 | } | ||
127 | #endif | ||
126 | 128 | ||
127 | /* | 129 | /* |
128 | * During early boot, before section_mem_map is used for an actual | 130 | * During early boot, before section_mem_map is used for an actual |