blob: 326de104d0145fa2a40f6abdb3762ca35609ca65 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _SPARC64_PGALLOC_H
2#define _SPARC64_PGALLOC_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/kernel.h>
5#include <linux/sched.h>
6#include <linux/mm.h>
David S. Miller3c936462006-01-31 18:30:27 -08007#include <linux/slab.h>
David Miller3a2cba92007-05-06 14:49:51 -07008#include <linux/quicklist.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#include <asm/spitfire.h>
11#include <asm/cpudata.h>
12#include <asm/cacheflush.h>
David S. Miller6a9b4902005-09-19 20:11:57 -070013#include <asm/page.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15/* Page table allocation/freeing. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
David S. Miller3c936462006-01-31 18:30:27 -080017static inline pgd_t *pgd_alloc(struct mm_struct *mm)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018{
David Miller3a2cba92007-05-06 14:49:51 -070019 return quicklist_alloc(0, GFP_KERNEL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070020}
21
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080022static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
David Miller3a2cba92007-05-06 14:49:51 -070024 quicklist_free(0, NULL, pgd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025}
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
28
David S. Miller3c936462006-01-31 18:30:27 -080029static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030{
David Miller3a2cba92007-05-06 14:49:51 -070031 return quicklist_alloc(0, GFP_KERNEL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032}
33
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080034static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
David Miller3a2cba92007-05-06 14:49:51 -070036 quicklist_free(0, NULL, pmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
David S. Miller3c936462006-01-31 18:30:27 -080039static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
40 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070041{
David Miller3a2cba92007-05-06 14:49:51 -070042 return quicklist_alloc(0, GFP_KERNEL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043}
44
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080045static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
46 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080048 struct page *page;
49 void *pg;
50
51 pg = quicklist_alloc(0, GFP_KERNEL, NULL);
52 if (!pg)
53 return NULL;
54 page = virt_to_page(pg);
55 pgtable_page_ctor(page);
56 return page;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
David S. Miller3c936462006-01-31 18:30:27 -080058
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080059static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
David S. Miller3c936462006-01-31 18:30:27 -080060{
David Miller3a2cba92007-05-06 14:49:51 -070061 quicklist_free(0, NULL, pte);
David S. Miller3c936462006-01-31 18:30:27 -080062}
63
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080064static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
David S. Miller3c936462006-01-31 18:30:27 -080065{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080066 pgtable_page_dtor(ptepage);
David Miller3a2cba92007-05-06 14:49:51 -070067 quicklist_free_page(0, NULL, ptepage);
David S. Miller3c936462006-01-31 18:30:27 -080068}
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
72#define pmd_populate(MM,PMD,PTE_PAGE) \
73 pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080074#define pmd_pgtable(pmd) pmd_page(pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
David Miller3a2cba92007-05-06 14:49:51 -070076static inline void check_pgt_cache(void)
77{
78 quicklist_trim(0, NULL, 25, 16);
79}
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81#endif /* _SPARC64_PGALLOC_H */