[PATCH 4/4] x86/mm: replace GFP_ATOMIC with GFP_KERNEL for direct map allocations

From: Mike Rapoport
Date: Thu Nov 11 2021 - 06:03:07 EST


From: Mike Rapoport <rppt@xxxxxxxxxxxxx>

The allocations of the direct map pages are mostly happen very early during
the system boot and they use either the page table cache in brk area of bss
or memblock.

The few callers that effectively use page allocator for the direct map
updates are gart_iommu_init() and memory hotplug. Neither of them happen in
an atomic context so there is no reason to use GFP_ATOMIC for these
allocations.

Replace GFP_ATOMIC with GFP_KERNEL to avoid using atomic reserves for
allocations that do not require that.

Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
---
arch/x86/mm/init.c | 2 +-
arch/x86/mm/init_64.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 1895986842b9..c01f144e0015 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -120,7 +120,7 @@ __ref void *alloc_low_pages(unsigned int num)
unsigned int order;

order = get_order((unsigned long)num << PAGE_SHIFT);
- return (void *)__get_free_pages(GFP_ATOMIC | __GFP_ZERO, order);
+ return (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
}

if ((pgt_buf_end + num) > pgt_buf_top || !can_use_brk_pgt) {
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e46d2f18d895..f3924f1a953d 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -227,7 +227,7 @@ static __ref void *spp_getpage(void)
void *ptr;

if (after_bootmem)
- ptr = (void *) get_zeroed_page(GFP_ATOMIC);
+ ptr = (void *) get_zeroed_page(GFP_KERNEL);
else
ptr = memblock_alloc(PAGE_SIZE, PAGE_SIZE);

--
2.28.0