c7cc58a1ad
That patch used to just add a hook to page table flushing but pulling that string brought out a whole bunch of issues, so it now does that and more: - We now make the RCU batching of page freeing SMP only, as I believe it was intended initially. We make a few more things compile to nothing on !CONFIG_SMP - Some macros are turned into functions, though that forced me to out of line a few stuffs due to unsolvable include depenencies, however it's probably better that way anyway, it's not -that- critical code path. - 32-bit didn't call pte_free_finish() on tlb_flush() which means that it wouldn't push out the batch to RCU for delayed freeing when a bunch of page tables have been freed, they would just stay in there until the batch gets full. 64-bit BookE will use that hook to maintain the virtually linear page tables or the indirect entries in the TLB when using the HW loader. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
70 lines
1.7 KiB
C
70 lines
1.7 KiB
C
#ifndef _ASM_POWERPC_PGALLOC_H
|
|
#define _ASM_POWERPC_PGALLOC_H
|
|
#ifdef __KERNEL__
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
|
|
#else /* CONFIG_PPC_BOOK3E */
|
|
static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
|
|
unsigned long address)
|
|
{
|
|
}
|
|
#endif /* !CONFIG_PPC_BOOK3E */
|
|
|
|
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
|
|
{
|
|
free_page((unsigned long)pte);
|
|
}
|
|
|
|
static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
|
|
{
|
|
pgtable_page_dtor(ptepage);
|
|
__free_page(ptepage);
|
|
}
|
|
|
|
typedef struct pgtable_free {
|
|
unsigned long val;
|
|
} pgtable_free_t;
|
|
|
|
#define PGF_CACHENUM_MASK 0x7
|
|
|
|
static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum,
|
|
unsigned long mask)
|
|
{
|
|
BUG_ON(cachenum > PGF_CACHENUM_MASK);
|
|
|
|
return (pgtable_free_t){.val = ((unsigned long) p & ~mask) | cachenum};
|
|
}
|
|
|
|
#ifdef CONFIG_PPC64
|
|
#include <asm/pgalloc-64.h>
|
|
#else
|
|
#include <asm/pgalloc-32.h>
|
|
#endif
|
|
|
|
#ifdef CONFIG_SMP
|
|
extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf);
|
|
extern void pte_free_finish(void);
|
|
#else /* CONFIG_SMP */
|
|
static inline void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf)
|
|
{
|
|
pgtable_free(pgf);
|
|
}
|
|
static inline void pte_free_finish(void) { }
|
|
#endif /* !CONFIG_SMP */
|
|
|
|
static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
|
|
unsigned long address)
|
|
{
|
|
pgtable_free_t pgf = pgtable_free_cache(page_address(ptepage),
|
|
PTE_NONCACHE_NUM,
|
|
PTE_TABLE_SIZE-1);
|
|
tlb_flush_pgtable(tlb, address);
|
|
pgtable_page_dtor(ptepage);
|
|
pgtable_free_tlb(tlb, pgf);
|
|
}
|
|
|
|
#endif /* __KERNEL__ */
|
|
#endif /* _ASM_POWERPC_PGALLOC_H */
|