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

arm: convert various functions to use ptdescs

As part of the conversions to replace pgtable constructor/destructors with
ptdesc equivalents, convert various page table functions to use ptdescs.

late_alloc() also uses the __get_free_pages() helper function. Convert
this to use pagetable_alloc() and ptdesc_address() instead to help
standardize page tables further.

Link: https://lkml.kernel.org/r/20230807230513.102486-18-vishal.moola@gmail.com
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Guo Ren <guoren@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Vishal Moola (Oracle) and committed by
Andrew Morton
358d1c39 c787ae5b

+11 -8
+7 -5
arch/arm/include/asm/tlb.h
··· 39 39 static inline void 40 40 __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, unsigned long addr) 41 41 { 42 - pgtable_pte_page_dtor(pte); 42 + struct ptdesc *ptdesc = page_ptdesc(pte); 43 + 44 + pagetable_pte_dtor(ptdesc); 43 45 44 46 #ifndef CONFIG_ARM_LPAE 45 47 /* ··· 52 50 __tlb_adjust_range(tlb, addr - PAGE_SIZE, 2 * PAGE_SIZE); 53 51 #endif 54 52 55 - tlb_remove_table(tlb, pte); 53 + tlb_remove_ptdesc(tlb, ptdesc); 56 54 } 57 55 58 56 static inline void 59 57 __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) 60 58 { 61 59 #ifdef CONFIG_ARM_LPAE 62 - struct page *page = virt_to_page(pmdp); 60 + struct ptdesc *ptdesc = virt_to_ptdesc(pmdp); 63 61 64 - pgtable_pmd_page_dtor(page); 65 - tlb_remove_table(tlb, page); 62 + pagetable_pmd_dtor(ptdesc); 63 + tlb_remove_ptdesc(tlb, ptdesc); 66 64 #endif 67 65 } 68 66
+4 -3
arch/arm/mm/mmu.c
··· 737 737 738 738 static void *__init late_alloc(unsigned long sz) 739 739 { 740 - void *ptr = (void *)__get_free_pages(GFP_PGTABLE_KERNEL, get_order(sz)); 740 + void *ptdesc = pagetable_alloc(GFP_PGTABLE_KERNEL & ~__GFP_HIGHMEM, 741 + get_order(sz)); 741 742 742 - if (!ptr || !pgtable_pte_page_ctor(virt_to_page(ptr))) 743 + if (!ptdesc || !pagetable_pte_ctor(ptdesc)) 743 744 BUG(); 744 - return ptr; 745 + return ptdesc_to_virt(ptdesc); 745 746 } 746 747 747 748 static pte_t * __init arm_pte_alloc(pmd_t *pmd, unsigned long addr,