/* * Allocate a page table. Note that we place the MEMC * table before the page directory. This means we can * easily get to both tightly-associated data structures * with a single pointer. * * We actually only need 1152 bytes, 896 bytes is wasted. * We could try to fit 7 PTEs into that slot somehow. */ static inline void *alloc_pgd_table(int priority) { unsigned long pg2k; pg2k = get_page_2k(priority); if (pg2k) pg2k += MEMC_TABLE_SIZE; return (void *)pg2k; }
pte_t *get_pte_kernel_slow(pmd_t *pmd, unsigned long offset) { pte_t *pte; pte = (pte_t *)get_page_2k(GFP_KERNEL); if (pmd_none(*pmd)) { if (pte) { memzero(pte, 2 * PTRS_PER_PTE * BYTES_PER_PTR); clean_cache_area(pte, PTRS_PER_PTE * BYTES_PER_PTR); pte += PTRS_PER_PTE; set_pmd(pmd, mk_kernel_pmd(pte)); return pte + offset; } set_pmd(pmd, mk_kernel_pmd(BAD_PAGETABLE)); return NULL; } free_page_2k((unsigned long)pte); if (pmd_bad(*pmd)) { __bad_pmd_kernel(pmd); return NULL; } return (pte_t *) pmd_page(*pmd) + offset; }
/* * FIXME: the following over-allocates by 1600% */ static inline void *alloc_pte_table(int size, int prio) { if (size != 128) printk("invalid table size\n"); return (void *)get_page_2k(prio); }