Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: remove unnecessary __GFP_HIGHMEM in __p*d_alloc_one_*()

__{pgd,p4d,pud,pmd,pte}_alloc_one_*() always allocate pages with GFP flag
GFP_PGTABLE_KERNEL/GFP_PGTABLE_USER. These two macros are defined as
follows:

#define GFP_PGTABLE_KERNEL (GFP_KERNEL | __GFP_ZERO)
#define GFP_PGTABLE_USER (GFP_PGTABLE_KERNEL | __GFP_ACCOUNT)

There is no __GFP_HIGHMEM in them, so we needn't to clear __GFP_HIGHMEM
explicitly.

Link: https://lkml.kernel.org/r/20251109021817.346181-1-chenhuacai@loongson.cn
Link: https://lkml.kernel.org/r/20251107095536.3101371-1-chenhuacai@loongson.cn
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Huacai Chen and committed by
Andrew Morton
05be0287 c0ae966f

+1 -5
+1 -5
include/asm-generic/pgalloc.h
··· 18 18 */ 19 19 static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm) 20 20 { 21 - struct ptdesc *ptdesc = pagetable_alloc_noprof(GFP_PGTABLE_KERNEL & 22 - ~__GFP_HIGHMEM, 0); 21 + struct ptdesc *ptdesc = pagetable_alloc_noprof(GFP_PGTABLE_KERNEL, 0); 23 22 24 23 if (!ptdesc) 25 24 return NULL; ··· 177 178 178 179 if (mm == &init_mm) 179 180 gfp = GFP_PGTABLE_KERNEL; 180 - gfp &= ~__GFP_HIGHMEM; 181 181 182 182 ptdesc = pagetable_alloc_noprof(gfp, 0); 183 183 if (!ptdesc) ··· 234 236 235 237 if (mm == &init_mm) 236 238 gfp = GFP_PGTABLE_KERNEL; 237 - gfp &= ~__GFP_HIGHMEM; 238 239 239 240 ptdesc = pagetable_alloc_noprof(gfp, 0); 240 241 if (!ptdesc) ··· 281 284 282 285 if (mm == &init_mm) 283 286 gfp = GFP_PGTABLE_KERNEL; 284 - gfp &= ~__GFP_HIGHMEM; 285 287 286 288 ptdesc = pagetable_alloc_noprof(gfp, order); 287 289 if (!ptdesc)