Skip to content

Commit 40d1bb9

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: tlb: convert __p*d_free_tlb() to inline functions
This is to prepare for enabling MMU_GATHER_RCU_TABLE_FREE. No functionality changes. Signed-off-by: Jisheng Zhang <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 8246601 commit 40d1bb9

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

arch/riscv/include/asm/pgalloc.h

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,16 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)
9595
__pud_free(mm, pud);
9696
}
9797

98-
#define __pud_free_tlb(tlb, pud, addr) \
99-
do { \
100-
if (pgtable_l4_enabled) { \
101-
pagetable_pud_dtor(virt_to_ptdesc(pud)); \
102-
tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pud)); \
103-
} \
104-
} while (0)
98+
static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
99+
unsigned long addr)
100+
{
101+
if (pgtable_l4_enabled) {
102+
struct ptdesc *ptdesc = virt_to_ptdesc(pud);
103+
104+
pagetable_pud_dtor(ptdesc);
105+
tlb_remove_page_ptdesc(tlb, ptdesc);
106+
}
107+
}
105108

106109
#define p4d_alloc_one p4d_alloc_one
107110
static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
@@ -130,11 +133,12 @@ static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
130133
__p4d_free(mm, p4d);
131134
}
132135

133-
#define __p4d_free_tlb(tlb, p4d, addr) \
134-
do { \
135-
if (pgtable_l5_enabled) \
136-
tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(p4d)); \
137-
} while (0)
136+
static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d,
137+
unsigned long addr)
138+
{
139+
if (pgtable_l5_enabled)
140+
tlb_remove_page_ptdesc(tlb, virt_to_ptdesc(p4d));
141+
}
138142
#endif /* __PAGETABLE_PMD_FOLDED */
139143

140144
static inline void sync_kernel_mappings(pgd_t *pgd)
@@ -159,19 +163,25 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
159163

160164
#ifndef __PAGETABLE_PMD_FOLDED
161165

162-
#define __pmd_free_tlb(tlb, pmd, addr) \
163-
do { \
164-
pagetable_pmd_dtor(virt_to_ptdesc(pmd)); \
165-
tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pmd)); \
166-
} while (0)
166+
static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
167+
unsigned long addr)
168+
{
169+
struct ptdesc *ptdesc = virt_to_ptdesc(pmd);
170+
171+
pagetable_pmd_dtor(ptdesc);
172+
tlb_remove_page_ptdesc(tlb, ptdesc);
173+
}
167174

168175
#endif /* __PAGETABLE_PMD_FOLDED */
169176

170-
#define __pte_free_tlb(tlb, pte, buf) \
171-
do { \
172-
pagetable_pte_dtor(page_ptdesc(pte)); \
173-
tlb_remove_page_ptdesc((tlb), page_ptdesc(pte));\
174-
} while (0)
177+
static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
178+
unsigned long addr)
179+
{
180+
struct ptdesc *ptdesc = page_ptdesc(pte);
181+
182+
pagetable_pte_dtor(ptdesc);
183+
tlb_remove_page_ptdesc(tlb, ptdesc);
184+
}
175185
#endif /* CONFIG_MMU */
176186

177187
#endif /* _ASM_RISCV_PGALLOC_H */

0 commit comments

Comments
 (0)