blob: 5d66b858a965bdb42d4ccf30565d5c36cfd68fda [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $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 Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/kernel.h>
6#include <linux/sched.h>
7#include <linux/mm.h>
David S. Miller3c936462006-01-31 18:30:27 -08008#include <linux/slab.h>
David Miller3a2cba92007-05-06 14:49:51 -07009#include <linux/quicklist.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11#include <asm/spitfire.h>
12#include <asm/cpudata.h>
13#include <asm/cacheflush.h>
David S. Miller6a9b4902005-09-19 20:11:57 -070014#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16/* Page table allocation/freeing. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
David S. Miller3c936462006-01-31 18:30:27 -080018static inline pgd_t *pgd_alloc(struct mm_struct *mm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
David Miller3a2cba92007-05-06 14:49:51 -070020 return quicklist_alloc(0, GFP_KERNEL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021}
22
David S. Miller3c936462006-01-31 18:30:27 -080023static inline void pgd_free(pgd_t *pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
David Miller3a2cba92007-05-06 14:49:51 -070025 quicklist_free(0, NULL, pgd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026}
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
29
David S. Miller3c936462006-01-31 18:30:27 -080030static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
David Miller3a2cba92007-05-06 14:49:51 -070032 return quicklist_alloc(0, GFP_KERNEL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070033}
34
David S. Miller3c936462006-01-31 18:30:27 -080035static inline void pmd_free(pmd_t *pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
David Miller3a2cba92007-05-06 14:49:51 -070037 quicklist_free(0, NULL, pmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
39
David S. Miller3c936462006-01-31 18:30:27 -080040static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
41 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
David Miller3a2cba92007-05-06 14:49:51 -070043 return quicklist_alloc(0, GFP_KERNEL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
David S. Miller3c936462006-01-31 18:30:27 -080046static inline struct page *pte_alloc_one(struct mm_struct *mm,
47 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
David Miller3a2cba92007-05-06 14:49:51 -070049 void *pg = quicklist_alloc(0, GFP_KERNEL, NULL);
50 return pg ? virt_to_page(pg) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
David S. Miller3c936462006-01-31 18:30:27 -080052
53static inline void pte_free_kernel(pte_t *pte)
54{
David Miller3a2cba92007-05-06 14:49:51 -070055 quicklist_free(0, NULL, pte);
David S. Miller3c936462006-01-31 18:30:27 -080056}
57
58static inline void pte_free(struct page *ptepage)
59{
David Miller3a2cba92007-05-06 14:49:51 -070060 quicklist_free_page(0, NULL, ptepage);
David S. Miller3c936462006-01-31 18:30:27 -080061}
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
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 Miller3a2cba92007-05-06 14:49:51 -070068static inline void check_pgt_cache(void)
69{
70 quicklist_trim(0, NULL, 25, 16);
71}
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73#endif /* _SPARC64_PGALLOC_H */