Skip to content

Commit 4a0100f

Browse files
davem330torvalds
authored andcommitted
sparc64: use RCU page table freeing
Make use of the generic RCU page table freeing on Sparc64, doing so allows for race-free software page-table walkers like gup_fast(). Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4dedbf8 commit 4a0100f

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎arch/sparc/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ config SPARC64
4141
select HAVE_FUNCTION_TRACE_MCOUNT_TEST
4242
select HAVE_KRETPROBES
4343
select HAVE_KPROBES
44+
select HAVE_RCU_TABLE_FREE if SMP
4445
select HAVE_MEMBLOCK
4546
select HAVE_SYSCALL_WRAPPERS
4647
select HAVE_DYNAMIC_FTRACE

‎arch/sparc/include/asm/pgalloc_64.h‎

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,51 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
7676

7777
#define check_pgt_cache() do { } while (0)
7878

79-
#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte)
80-
#define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd)
79+
static inline void pgtable_free(void *table, bool is_page)
80+
{
81+
if (is_page)
82+
free_page((unsigned long)table);
83+
else
84+
kmem_cache_free(pgtable_cache, table);
85+
}
86+
87+
#ifdef CONFIG_SMP
88+
89+
struct mmu_gather;
90+
extern void tlb_remove_table(struct mmu_gather *, void *);
91+
92+
static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is_page)
93+
{
94+
unsigned long pgf = (unsigned long)table;
95+
if (is_page)
96+
pgf |= 0x1UL;
97+
tlb_remove_table(tlb, (void *)pgf);
98+
}
99+
100+
static inline void __tlb_remove_table(void *_table)
101+
{
102+
void *table = (void *)((unsigned long)_table & ~0x1UL);
103+
bool is_page = false;
104+
105+
if ((unsigned long)_table & 0x1UL)
106+
is_page = true;
107+
pgtable_free(table, is_page);
108+
}
109+
#else /* CONFIG_SMP */
110+
static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is_page)
111+
{
112+
pgtable_free(table, is_page);
113+
}
114+
#endif /* !CONFIG_SMP */
115+
116+
static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
117+
unsigned long address)
118+
{
119+
pgtable_page_dtor(ptepage);
120+
pgtable_free_tlb(tlb, page_address(ptepage), true);
121+
}
122+
123+
#define __pmd_free_tlb(tlb, pmd, addr) \
124+
pgtable_free_tlb(tlb, pmd, false)
81125

82126
#endif /* _SPARC64_PGALLOC_H */

0 commit comments

Comments
 (0)