book3s64/hash: Add hash_debug_pagealloc_add_slot() function
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>
Fri, 18 Oct 2024 17:29:45 +0000 (22:59 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 23 Oct 2024 07:53:18 +0000 (18:53 +1100)
This adds hash_debug_pagealloc_add_slot() function instead of open
coding that in htab_bolt_mapping(). This is required since we will be
separating kfence functionality to not depend upon debug_pagealloc.

No functionality change in this patch.

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/026f0aaa1dddd89154dc8d20ceccfca4f63ccf79.1729271995.git.ritesh.list@gmail.com
arch/powerpc/mm/book3s64/hash_utils.c

index 82151ff..6e38602 100644 (file)
@@ -328,6 +328,14 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
                                     mmu_kernel_ssize, 0);
 }
 
+static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int slot)
+{
+       if (!debug_pagealloc_enabled())
+               return;
+       if ((paddr >> PAGE_SHIFT) < linear_map_hash_count)
+               linear_map_hash_slots[paddr >> PAGE_SHIFT] = slot | 0x80;
+}
+
 int hash__kernel_map_pages(struct page *page, int numpages, int enable)
 {
        unsigned long flags, vaddr, lmi;
@@ -353,6 +361,7 @@ int hash__kernel_map_pages(struct page *page, int numpages,
 {
        return 0;
 }
+static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int slot) {}
 #endif /* CONFIG_DEBUG_PAGEALLOC */
 
 /*
@@ -513,9 +522,7 @@ repeat:
                        break;
 
                cond_resched();
-               if (debug_pagealloc_enabled() &&
-                       (paddr >> PAGE_SHIFT) < linear_map_hash_count)
-                       linear_map_hash_slots[paddr >> PAGE_SHIFT] = ret | 0x80;
+               hash_debug_pagealloc_add_slot(paddr, ret);
        }
        return ret < 0 ? ret : 0;
 }