Content-Type: multipart/mixed; boundary="===============8390516308410354254==" MIME-Version: 1.0 From: Zach O'Keefe To: kbuild-all@lists.01.org Subject: [PATCH mm-unstable] mm/khugepaged: fix struct collapse_control load_node definition Date: Fri, 02 Sep 2022 19:12:21 -0700 Message-ID: <20220903021221.1130021-1-zokeefe@google.com> List-Id: --===============8390516308410354254== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable HPAGE_PMD_ORDER is used to determine a minimal amount of bits needed to sto= re per-node counters in struct collapse_control, defining the array to be eith= er a u16[HPAGE_PMD_ORDER] or u32[HPAGE_PMD_ORDER]. For some architectures/configs, HPAGE_PMD_ORDER isn't resolved at preproces= sor time (suitable for resolving preprocessor directives) but rather expands in= to a compiler built-in that is resolved at compile-time. E.g. for 32-bit MIPS (s= ee link for full config): ---8<-- >> arch/mips/include/asm/pgtable.h:238:26: warning: "__builtin_ffs" is not = defined, evaluates to 0 [-Wundef] 238 | #define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1) | ^~~~~~~~~~~~~ arch/mips/include/asm/pgtable-32.h:65:43: note: in expansion of macro 'P= TE_T_LOG2' 65 | # define PGDIR_SHIFT (2 * PAGE_SHIFT - PTE_T_LOG2 - 1) | ^~~~~~~~~~ include/asm-generic/pgtable-nop4d.h:11:33: note: in expansion of macro '= PGDIR_SHIFT' 11 | #define P4D_SHIFT PGDIR_SHIFT | ^~~~~~~~~~~ include/asm-generic/pgtable-nopud.h:18:25: note: in expansion of macro '= P4D_SHIFT' 18 | #define PUD_SHIFT P4D_SHIFT | ^~~~~~~~~ include/asm-generic/pgtable-nopmd.h:20:25: note: in expansion of macro '= PUD_SHIFT' 20 | #define PMD_SHIFT PUD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:109:25: note: in expansion of macro 'PMD_SHIFT' 109 | #define HPAGE_PMD_SHIFT PMD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:105:26: note: in expansion of macro 'HPAGE_PMD_S= HIFT' 105 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) | ^~~~~~~~~~~~~~~ mm/khugepaged.c:90:5: note: in expansion of macro 'HPAGE_PMD_ORDER' 90 | #if HPAGE_PMD_ORDER < 16 | ^~~~~~~~~~~~~~~ >> arch/mips/include/asm/pgtable.h:238:39: error: missing binary operator b= efore token "(" 238 | #define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1) | ^ arch/mips/include/asm/pgtable-32.h:65:43: note: in expansion of macro 'P= TE_T_LOG2' 65 | # define PGDIR_SHIFT (2 * PAGE_SHIFT - PTE_T_LOG2 - 1) | ^~~~~~~~~~ include/asm-generic/pgtable-nop4d.h:11:33: note: in expansion of macro '= PGDIR_SHIFT' 11 | #define P4D_SHIFT PGDIR_SHIFT | ^~~~~~~~~~~ include/asm-generic/pgtable-nopud.h:18:25: note: in expansion of macro '= P4D_SHIFT' 18 | #define PUD_SHIFT P4D_SHIFT | ^~~~~~~~~ include/asm-generic/pgtable-nopmd.h:20:25: note: in expansion of macro '= PUD_SHIFT' 20 | #define PMD_SHIFT PUD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:109:25: note: in expansion of macro 'PMD_SHIFT' 109 | #define HPAGE_PMD_SHIFT PMD_SHIFT | ^~~~~~~~~ include/linux/huge_mm.h:105:26: note: in expansion of macro 'HPAGE_PMD_S= HIFT' 105 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT) | ^~~~~~~~~~~~~~~ mm/khugepaged.c:90:5: note: in expansion of macro 'HPAGE_PMD_ORDER' 90 | #if HPAGE_PMD_ORDER < 16 | ^~~~~~~~~~~~~~~ ---8<-- load_node is already special-cased for CONFIG_PPC64 in "mm-khugepaged-add-struct-collapse_control-fix-fix", and we could continue = down that path by #define'ing away edge cases, but I think@this point it easi= er to just let load_node be an array of u32s. If it's ever an issue, we can revisit. This essentially rolls back both: "mm/khugepaged: use minimal bits to store num page < HPAGE_PMD_NR" "mm-khugepaged-add-struct-collapse_control-fix-fix" (though we'll leave it as a u32 vs an int). Link: https://lore.kernel.org/linux-mm/202209021349.F73i5d6X-lkp(a)intel.co= m/ Fixes: 5f7bb00bd9cd ("mm/khugepaged: use minimal bits to store num page < H= PAGE_PMD_NR") Fixes: 03053c821af2 ("mm-khugepaged-add-struct-collapse_control-fix-fix") Signed-off-by: Zach O'Keefe --- mm/khugepaged.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index af3b07eb2389..29142a35d24c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -93,13 +93,8 @@ struct collapse_control { bool is_khugepaged; = /* Num pages scanned per node */ -#if defined(CONFIG_PPC64) u32 node_load[MAX_NUMNODES]; -#elif HPAGE_PMD_ORDER < 16 - u16 node_load[MAX_NUMNODES]; -#else - u32 node_load[MAX_NUMNODES]; -#endif + /* Last target selected in hpage_collapse_find_target_node() */ int last_target_node; }; -- = 2.37.2.789.g6183377224-goog --===============8390516308410354254==--