blob: b48f73c2274ef7ee682204deffa9bcd09dad962f [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
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080023static inline void pgd_free(struct mm_struct *mm, 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
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080035static inline void pmd_free(struct mm_struct *mm, 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
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080053static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
David S. Miller3c936462006-01-31 18:30:27 -080054{
David Miller3a2cba92007-05-06 14:49:51 -070055 quicklist_free(0, NULL, pte);
David S. Miller3c936462006-01-31 18:30:27 -080056}
57
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080058static inline void pte_free(struct mm_struct *mm, struct page *ptepage)
David S. Miller3c936462006-01-31 18:30:27 -080059{
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 */