blob: 3ee2d406373b9fc03a671d2c28b49adbb91dd634 [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
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080046static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
47 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080049 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 Torvalds1da177e2005-04-16 15:20:36 -070058}
David S. Miller3c936462006-01-31 18:30:27 -080059
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080060static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
David S. Miller3c936462006-01-31 18:30:27 -080061{
David Miller3a2cba92007-05-06 14:49:51 -070062 quicklist_free(0, NULL, pte);
David S. Miller3c936462006-01-31 18:30:27 -080063}
64
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080065static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
David S. Miller3c936462006-01-31 18:30:27 -080066{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080067 pgtable_page_dtor(ptepage);
David Miller3a2cba92007-05-06 14:49:51 -070068 quicklist_free_page(0, NULL, ptepage);
David S. Miller3c936462006-01-31 18:30:27 -080069}
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
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 Schwidefsky2f569af2008-02-08 04:22:04 -080075#define pmd_pgtable(pmd) pmd_page(pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
David Miller3a2cba92007-05-06 14:49:51 -070077static inline void check_pgt_cache(void)
78{
79 quicklist_trim(0, NULL, 25, 16);
80}
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82#endif /* _SPARC64_PGALLOC_H */