Re: [PATCH 2/3] mm/sparse: expand the CONFIG_SPARSEMEM_EXTREME range in __nr_to_section()
From: Dave Hansen <hidden>
Date: 2018-08-24 00:09:15
From: Dave Hansen <hidden>
Date: 2018-08-24 00:09:15
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. 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.