On Thu, Aug 23, 2018 at 03:21:12PM +0200, Michal Hocko wrote: >[Cc Dave] > >On Thu 23-08-18 21:07:31, Wei Yang wrote: >> When CONFIG_SPARSEMEM_EXTREME is not defined, mem_section is a static >> two dimension array. This means !mem_section[SECTION_NR_TO_ROOT(nr)] is >> always true. >> >> This patch expand the CONFIG_SPARSEMEM_EXTREME range to return a proper >> mem_section when CONFIG_SPARSEMEM_EXTREME is not defined. > >As long as all callers provide a valid section number then yes. I am not >really sure this is the case though. > I don't get your point. When CONFIG_SPARSEMEM_EXTREME is not defined, each section number is a valid one in this context. Because for eavry section number in [0, NR_MEM_SECTIONS - 1], we have a mem_sectioin structure there. This patch helps to reduce a meaningless check when CONFIG_SPARSEMEM_EXTREME=n. >> Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> >> --- >> include/linux/mmzone.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h >> index 32699b2dc52a..33086f86d1a7 100644 >> --- a/include/linux/mmzone.h >> +++ b/include/linux/mmzone.h >> @@ -1155,9 +1155,9 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) >> #ifdef CONFIG_SPARSEMEM_EXTREME >> if (!mem_section) >> return NULL; >> -#endif >> if (!mem_section[SECTION_NR_TO_ROOT(nr)]) >> return NULL; >> +#endif >> return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; >> } >> extern int __section_nr(struct mem_section* ms); >> -- >> 2.15.1 >> > >-- >Michal Hocko >SUSE Labs -- Wei Yang Help you, Help me