Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: pgalloc.h,v 1.30 2001/12/21 04:56:17 davem Exp $ */ |
| 2 | #ifndef _SPARC64_PGALLOC_H |
| 3 | #define _SPARC64_PGALLOC_H |
| 4 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/kernel.h> |
| 6 | #include <linux/sched.h> |
| 7 | #include <linux/mm.h> |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 8 | #include <linux/slab.h> |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 9 | #include <linux/quicklist.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | #include <asm/spitfire.h> |
| 12 | #include <asm/cpudata.h> |
| 13 | #include <asm/cacheflush.h> |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 14 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | /* Page table allocation/freeing. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 18 | static inline pgd_t *pgd_alloc(struct mm_struct *mm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 20 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | } |
| 22 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 23 | static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 25 | quicklist_free(0, NULL, pgd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | } |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD) |
| 29 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 30 | static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 32 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 35 | static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 37 | quicklist_free(0, NULL, pmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | } |
| 39 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 40 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
| 41 | unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 43 | return quicklist_alloc(0, GFP_KERNEL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 46 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, |
| 47 | unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 49 | struct page *page; |
| 50 | void *pg; |
| 51 | |
| 52 | pg = quicklist_alloc(0, GFP_KERNEL, NULL); |
| 53 | if (!pg) |
| 54 | return NULL; |
| 55 | page = virt_to_page(pg); |
| 56 | pgtable_page_ctor(page); |
| 57 | return page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 59 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 60 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 61 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 62 | quicklist_free(0, NULL, pte); |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 63 | } |
| 64 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 65 | static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 66 | { |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 67 | pgtable_page_dtor(ptepage); |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 68 | quicklist_free_page(0, NULL, ptepage); |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 69 | } |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) |
| 73 | #define pmd_populate(MM,PMD,PTE_PAGE) \ |
| 74 | pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 75 | #define pmd_pgtable(pmd) pmd_page(pmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 77 | static inline void check_pgt_cache(void) |
| 78 | { |
| 79 | quicklist_trim(0, NULL, 25, 16); |
| 80 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | #endif /* _SPARC64_PGALLOC_H */ |