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 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 23 | static inline void pgd_free(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 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 35 | static inline void pmd_free(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 | |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 46 | static inline struct page *pte_alloc_one(struct mm_struct *mm, |
| 47 | unsigned long address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 49 | void *pg = quicklist_alloc(0, GFP_KERNEL, NULL); |
| 50 | return pg ? virt_to_page(pg) : NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 52 | |
| 53 | static inline void pte_free_kernel(pte_t *pte) |
| 54 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 55 | quicklist_free(0, NULL, pte); |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | static inline void pte_free(struct page *ptepage) |
| 59 | { |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 60 | quicklist_free_page(0, NULL, ptepage); |
David S. Miller | 3c93646 | 2006-01-31 18:30:27 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) |
| 65 | #define pmd_populate(MM,PMD,PTE_PAGE) \ |
| 66 | pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) |
| 67 | |
David Miller | 3a2cba9 | 2007-05-06 14:49:51 -0700 | [diff] [blame] | 68 | static inline void check_pgt_cache(void) |
| 69 | { |
| 70 | quicklist_trim(0, NULL, 25, 16); |
| 71 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | #endif /* _SPARC64_PGALLOC_H */ |