summaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64/pgalloc.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-sparc64/pgalloc.h
downloadblackbird-op-linux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.gz
blackbird-op-linux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.zip
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-sparc64/pgalloc.h')
-rw-r--r--include/asm-sparc64/pgalloc.h188
1 files changed, 188 insertions, 0 deletions
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
new file mode 100644
index 000000000000..2c28e1f605b7
--- /dev/null
+++ b/include/asm-sparc64/pgalloc.h
@@ -0,0 +1,188 @@
+/* $Id: pgalloc.h,v 1.30 2001/12/21 04:56:17 davem Exp $ */
+#ifndef _SPARC64_PGALLOC_H
+#define _SPARC64_PGALLOC_H
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+
+#include <asm/spitfire.h>
+#include <asm/cpudata.h>
+#include <asm/cacheflush.h>
+
+/* Page table allocation/freeing. */
+#ifdef CONFIG_SMP
+/* Sliiiicck */
+#define pgt_quicklists local_cpu_data()
+#else
+extern struct pgtable_cache_struct {
+ unsigned long *pgd_cache;
+ unsigned long *pte_cache[2];
+ unsigned int pgcache_size;
+} pgt_quicklists;
+#endif
+#define pgd_quicklist (pgt_quicklists.pgd_cache)
+#define pmd_quicklist ((unsigned long *)0)
+#define pte_quicklist (pgt_quicklists.pte_cache)
+#define pgtable_cache_size (pgt_quicklists.pgcache_size)
+
+static __inline__ void free_pgd_fast(pgd_t *pgd)
+{
+ preempt_disable();
+ *(unsigned long *)pgd = (unsigned long) pgd_quicklist;
+ pgd_quicklist = (unsigned long *) pgd;
+ pgtable_cache_size++;
+ preempt_enable();
+}
+
+static __inline__ pgd_t *get_pgd_fast(void)
+{
+ unsigned long *ret;
+
+ preempt_disable();
+ if((ret = pgd_quicklist) != NULL) {
+ pgd_quicklist = (unsigned long *)(*ret);
+ ret[0] = 0;
+ pgtable_cache_size--;
+ preempt_enable();
+ } else {
+ preempt_enable();
+ ret = (unsigned long *) __get_free_page(GFP_KERNEL|__GFP_REPEAT);
+ if(ret)
+ memset(ret, 0, PAGE_SIZE);
+ }
+ return (pgd_t *)ret;
+}
+
+static __inline__ void free_pgd_slow(pgd_t *pgd)
+{
+ free_page((unsigned long)pgd);
+}
+
+#ifdef DCACHE_ALIASING_POSSIBLE
+#define VPTE_COLOR(address) (((address) >> (PAGE_SHIFT + 10)) & 1UL)
+#define DCACHE_COLOR(address) (((address) >> PAGE_SHIFT) & 1UL)
+#else
+#define VPTE_COLOR(address) 0
+#define DCACHE_COLOR(address) 0
+#endif
+
+#define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
+
+static __inline__ pmd_t *pmd_alloc_one_fast(struct mm_struct *mm, unsigned long address)
+{
+ unsigned long *ret;
+ int color = 0;
+
+ preempt_disable();
+ if (pte_quicklist[color] == NULL)
+ color = 1;
+
+ if((ret = (unsigned long *)pte_quicklist[color]) != NULL) {
+ pte_quicklist[color] = (unsigned long *)(*ret);
+ ret[0] = 0;
+ pgtable_cache_size--;
+ }
+ preempt_enable();
+
+ return (pmd_t *)ret;
+}
+
+static __inline__ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
+{
+ pmd_t *pmd;
+
+ pmd = pmd_alloc_one_fast(mm, address);
+ if (!pmd) {
+ pmd = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+ if (pmd)
+ memset(pmd, 0, PAGE_SIZE);
+ }
+ return pmd;
+}
+
+static __inline__ void free_pmd_fast(pmd_t *pmd)
+{
+ unsigned long color = DCACHE_COLOR((unsigned long)pmd);
+
+ preempt_disable();
+ *(unsigned long *)pmd = (unsigned long) pte_quicklist[color];
+ pte_quicklist[color] = (unsigned long *) pmd;
+ pgtable_cache_size++;
+ preempt_enable();
+}
+
+static __inline__ void free_pmd_slow(pmd_t *pmd)
+{
+ free_page((unsigned long)pmd);
+}
+
+#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE)
+#define pmd_populate(MM,PMD,PTE_PAGE) \
+ pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
+
+extern pte_t *__pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address);
+
+static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
+{
+ return __pte_alloc_one_kernel(mm, address);
+}
+
+static inline struct page *
+pte_alloc_one(struct mm_struct *mm, unsigned long addr)
+{
+ pte_t *pte = __pte_alloc_one_kernel(mm, addr);
+
+ if (pte)
+ return virt_to_page(pte);
+
+ return NULL;
+}
+
+static __inline__ pte_t *pte_alloc_one_fast(struct mm_struct *mm, unsigned long address)
+{
+ unsigned long color = VPTE_COLOR(address);
+ unsigned long *ret;
+
+ preempt_disable();
+ if((ret = (unsigned long *)pte_quicklist[color]) != NULL) {
+ pte_quicklist[color] = (unsigned long *)(*ret);
+ ret[0] = 0;
+ pgtable_cache_size--;
+ }
+ preempt_enable();
+ return (pte_t *)ret;
+}
+
+static __inline__ void free_pte_fast(pte_t *pte)
+{
+ unsigned long color = DCACHE_COLOR((unsigned long)pte);
+
+ preempt_disable();
+ *(unsigned long *)pte = (unsigned long) pte_quicklist[color];
+ pte_quicklist[color] = (unsigned long *) pte;
+ pgtable_cache_size++;
+ preempt_enable();
+}
+
+static __inline__ void free_pte_slow(pte_t *pte)
+{
+ free_page((unsigned long)pte);
+}
+
+static inline void pte_free_kernel(pte_t *pte)
+{
+ free_pte_fast(pte);
+}
+
+static inline void pte_free(struct page *ptepage)
+{
+ free_pte_fast(page_address(ptepage));
+}
+
+#define pmd_free(pmd) free_pmd_fast(pmd)
+#define pgd_free(pgd) free_pgd_fast(pgd)
+#define pgd_alloc(mm) get_pgd_fast()
+
+#endif /* _SPARC64_PGALLOC_H */
OpenPOWER on IntegriCloud