On Thu, Aug 23, 2018 at 05:09:12PM -0700, Dave Hansen wrote: >On 08/23/2018 06:21 AM, Michal Hocko wrote: >> --- 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]; >> } > >This patch has no practical effect and only adds unnecessary churn. > >#ifdef CONFIG_SPARSEMEM_EXTREME >... >#else >struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]; >#endif > >The compiler knows that NR_SECTION_ROOTS==1 and that >!mem_section[SECTION_NR_TO_ROOT(nr) is always false. It doesn't need >our help. > I didn't know the compile would optimize the code when this is a one dimension array. Just wrote a code and their assembly looks the same. Thanks for pointing out. >My goal with the sparsemem code, and code in general is t avoid #ifdefs >whenever possible and limit their scope to the smallest possible area >whenever possible. -- Wei Yang Help you, Help me