diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2008-03-17 19:36:55 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-24 17:57:30 -0400 |
commit | 4f76cd382213b29dd3658e3e1ea47c0c2be06f3c (patch) | |
tree | a4822f341a6896ace039760d1df963b5f159c665 /include/asm-x86 | |
parent | 79bf6d66abb5a20813a19dd365dfc49104f0bb88 (diff) |
x86: add common mm/pgtable.c
Add a common arch/x86/mm/pgtable.c file for common pagetable functions.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86')
-rw-r--r-- | include/asm-x86/pgalloc.h | 18 | ||||
-rw-r--r-- | include/asm-x86/pgalloc_32.h | 11 | ||||
-rw-r--r-- | include/asm-x86/pgalloc_64.h | 67 |
3 files changed, 18 insertions, 78 deletions
diff --git a/include/asm-x86/pgalloc.h b/include/asm-x86/pgalloc.h index 5886eed05886..ea9d27ad7f4e 100644 --- a/include/asm-x86/pgalloc.h +++ b/include/asm-x86/pgalloc.h | |||
@@ -1,5 +1,23 @@ | |||
1 | #ifndef _ASM_X86_PGALLOC_H | ||
2 | #define _ASM_X86_PGALLOC_H | ||
3 | |||
4 | #include <linux/threads.h> | ||
5 | #include <linux/mm.h> /* for struct page */ | ||
6 | #include <linux/pagemap.h> | ||
7 | |||
8 | /* | ||
9 | * Allocate and free page tables. | ||
10 | */ | ||
11 | extern pgd_t *pgd_alloc(struct mm_struct *); | ||
12 | extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); | ||
13 | |||
14 | extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); | ||
15 | extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); | ||
16 | |||
1 | #ifdef CONFIG_X86_32 | 17 | #ifdef CONFIG_X86_32 |
2 | # include "pgalloc_32.h" | 18 | # include "pgalloc_32.h" |
3 | #else | 19 | #else |
4 | # include "pgalloc_64.h" | 20 | # include "pgalloc_64.h" |
5 | #endif | 21 | #endif |
22 | |||
23 | #endif /* _ASM_X86_PGALLOC_H */ | ||
diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h index 6bea6e5b5ee5..d60edb14f85e 100644 --- a/include/asm-x86/pgalloc_32.h +++ b/include/asm-x86/pgalloc_32.h | |||
@@ -1,12 +1,6 @@ | |||
1 | #ifndef _I386_PGALLOC_H | 1 | #ifndef _I386_PGALLOC_H |
2 | #define _I386_PGALLOC_H | 2 | #define _I386_PGALLOC_H |
3 | 3 | ||
4 | #include <linux/threads.h> | ||
5 | #include <linux/mm.h> /* for struct page */ | ||
6 | #include <linux/pagemap.h> | ||
7 | #include <asm/tlb.h> | ||
8 | #include <asm-generic/tlb.h> | ||
9 | |||
10 | #ifdef CONFIG_PARAVIRT | 4 | #ifdef CONFIG_PARAVIRT |
11 | #include <asm/paravirt.h> | 5 | #include <asm/paravirt.h> |
12 | #else | 6 | #else |
@@ -36,11 +30,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *p | |||
36 | /* | 30 | /* |
37 | * Allocate and free page tables. | 31 | * Allocate and free page tables. |
38 | */ | 32 | */ |
39 | extern pgd_t *pgd_alloc(struct mm_struct *); | ||
40 | extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); | ||
41 | |||
42 | extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); | ||
43 | extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); | ||
44 | 33 | ||
45 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) | 34 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
46 | { | 35 | { |
diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h index bcf525f3fbd0..23f87501ac26 100644 --- a/include/asm-x86/pgalloc_64.h +++ b/include/asm-x86/pgalloc_64.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef _X86_64_PGALLOC_H | 1 | #ifndef _X86_64_PGALLOC_H |
2 | #define _X86_64_PGALLOC_H | 2 | #define _X86_64_PGALLOC_H |
3 | 3 | ||
4 | #include <linux/threads.h> | ||
5 | #include <linux/mm.h> | ||
6 | #include <asm/pda.h> | 4 | #include <asm/pda.h> |
7 | 5 | ||
8 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) | 6 | static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) |
@@ -49,71 +47,6 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud) | |||
49 | free_page((unsigned long)pud); | 47 | free_page((unsigned long)pud); |
50 | } | 48 | } |
51 | 49 | ||
52 | static inline void pgd_list_add(pgd_t *pgd) | ||
53 | { | ||
54 | struct page *page = virt_to_page(pgd); | ||
55 | unsigned long flags; | ||
56 | |||
57 | spin_lock_irqsave(&pgd_lock, flags); | ||
58 | list_add(&page->lru, &pgd_list); | ||
59 | spin_unlock_irqrestore(&pgd_lock, flags); | ||
60 | } | ||
61 | |||
62 | static inline void pgd_list_del(pgd_t *pgd) | ||
63 | { | ||
64 | struct page *page = virt_to_page(pgd); | ||
65 | unsigned long flags; | ||
66 | |||
67 | spin_lock_irqsave(&pgd_lock, flags); | ||
68 | list_del(&page->lru); | ||
69 | spin_unlock_irqrestore(&pgd_lock, flags); | ||
70 | } | ||
71 | |||
72 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) | ||
73 | { | ||
74 | unsigned boundary; | ||
75 | pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); | ||
76 | if (!pgd) | ||
77 | return NULL; | ||
78 | pgd_list_add(pgd); | ||
79 | /* | ||
80 | * Copy kernel pointers in from init. | ||
81 | * Could keep a freelist or slab cache of those because the kernel | ||
82 | * part never changes. | ||
83 | */ | ||
84 | boundary = pgd_index(__PAGE_OFFSET); | ||
85 | memset(pgd, 0, boundary * sizeof(pgd_t)); | ||
86 | memcpy(pgd + boundary, | ||
87 | init_level4_pgt + boundary, | ||
88 | (PTRS_PER_PGD - boundary) * sizeof(pgd_t)); | ||
89 | return pgd; | ||
90 | } | ||
91 | |||
92 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) | ||
93 | { | ||
94 | BUG_ON((unsigned long)pgd & (PAGE_SIZE-1)); | ||
95 | pgd_list_del(pgd); | ||
96 | free_page((unsigned long)pgd); | ||
97 | } | ||
98 | |||
99 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) | ||
100 | { | ||
101 | return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); | ||
102 | } | ||
103 | |||
104 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) | ||
105 | { | ||
106 | struct page *page; | ||
107 | void *p; | ||
108 | |||
109 | p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); | ||
110 | if (!p) | ||
111 | return NULL; | ||
112 | page = virt_to_page(p); | ||
113 | pgtable_page_ctor(page); | ||
114 | return page; | ||
115 | } | ||
116 | |||
117 | /* Should really implement gc for free page table pages. This could be | 50 | /* Should really implement gc for free page table pages. This could be |
118 | done with a reference count in struct page. */ | 51 | done with a reference count in struct page. */ |
119 | 52 | ||