Commit a5a19c63 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Ingo Molnar

x86: demacro asm-x86/pgalloc_32.h

Convert macros into inline functions, for better type-checking.

This patch required a little bit of fiddling with headers in order to
make __(pte|pmd)_free_tlb inline rather than macros.
asm-generic/tlb.h includes asm/pgalloc.h, though it doesn't directly
use any pgalloc definitions.  I removed this include to avoid an
include cycle, but it may cause secondary compile failures by things
depending on the indirect inclusion; arch/x86/mm/hugetlbpage.c was one
such place; there may be others.
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 6c435456
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <asm/mman.h> #include <asm/mman.h>
#include <asm/tlb.h> #include <asm/tlb.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/pgalloc.h>
static unsigned long page_table_shareable(struct vm_area_struct *svma, static unsigned long page_table_shareable(struct vm_area_struct *svma,
struct vm_area_struct *vma, struct vm_area_struct *vma,
...@@ -88,7 +89,7 @@ static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud) ...@@ -88,7 +89,7 @@ static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
spin_lock(&mm->page_table_lock); spin_lock(&mm->page_table_lock);
if (pud_none(*pud)) if (pud_none(*pud))
pud_populate(mm, pud, (unsigned long) spte & PAGE_MASK); pud_populate(mm, pud, (pmd_t *)((unsigned long)spte & PAGE_MASK));
else else
put_page(virt_to_page(spte)); put_page(virt_to_page(spte));
spin_unlock(&mm->page_table_lock); spin_unlock(&mm->page_table_lock);
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/tlb.h> #include <asm/tlb.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/pgalloc.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/paravirt.h> #include <asm/paravirt.h>
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/swap.h> #include <linux/swap.h>
#include <linux/quicklist.h> #include <linux/quicklist.h>
#include <asm/pgalloc.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
/* /*
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <linux/threads.h> #include <linux/threads.h>
#include <linux/mm.h> /* for struct page */ #include <linux/mm.h> /* for struct page */
#include <asm/tlb.h>
#include <asm-generic/tlb.h>
#ifdef CONFIG_PARAVIRT #ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h> #include <asm/paravirt.h>
...@@ -14,19 +16,20 @@ ...@@ -14,19 +16,20 @@
#define paravirt_release_pd(pfn) do { } while (0) #define paravirt_release_pd(pfn) do { } while (0)
#endif #endif
#define pmd_populate_kernel(mm, pmd, pte) \ static inline void pmd_populate_kernel(struct mm_struct *mm,
do { \ pmd_t *pmd, pte_t *pte)
paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); \ {
set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); \ paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT);
} while (0) set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
}
#define pmd_populate(mm, pmd, pte) \ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
do { \ {
paravirt_alloc_pt(mm, page_to_pfn(pte)); \ unsigned long pfn = page_to_pfn(pte);
set_pmd(pmd, __pmd(_PAGE_TABLE + \
((unsigned long long)page_to_pfn(pte) << \ paravirt_alloc_pt(mm, pfn);
(unsigned long long) PAGE_SHIFT))); \ set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
} while (0) }
/* /*
* Allocate and free page tables. * Allocate and free page tables.
...@@ -48,20 +51,34 @@ static inline void pte_free(struct page *pte) ...@@ -48,20 +51,34 @@ static inline void pte_free(struct page *pte)
} }
#define __pte_free_tlb(tlb,pte) \ static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
do { \ {
paravirt_release_pt(page_to_pfn(pte)); \ paravirt_release_pt(page_to_pfn(pte));
tlb_remove_page((tlb),(pte)); \ tlb_remove_page(tlb, pte);
} while (0) }
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
/* /*
* In the PAE case we free the pmds as part of the pgd. * In the PAE case we free the pmds as part of the pgd.
*/ */
#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
#define pmd_free(x) do { } while (0) {
#define __pmd_free_tlb(tlb,x) do { } while (0) BUG();
#define pud_populate(mm, pmd, pte) BUG() return (pmd_t *)2;
#endif }
static inline void pmd_free(pmd_t *pmd)
{
}
static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
{
}
static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
{
BUG();
}
#endif /* CONFIG_X86_PAE */
#endif /* _I386_PGALLOC_H */ #endif /* _I386_PGALLOC_H */
...@@ -157,6 +157,4 @@ static inline unsigned long pte_pfn(pte_t pte) ...@@ -157,6 +157,4 @@ static inline unsigned long pte_pfn(pte_t pte)
#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high }) #define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high })
#define __swp_entry_to_pte(x) ((pte_t){ { .pte_high = (x).val } }) #define __swp_entry_to_pte(x) ((pte_t){ { .pte_high = (x).val } })
#define __pmd_free_tlb(tlb, x) do { } while (0)
#endif /* _I386_PGTABLE_3LEVEL_H */ #endif /* _I386_PGTABLE_3LEVEL_H */
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/mmzone.h> #include <linux/mmzone.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/pagemap.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#include <asm/page.h> #include <asm/page.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment