init-common.c (7f36f5d11cda050b118f76d774151427a18d15ef) | init-common.c (ba9b399aee6fb70cbe988f0750d6dd9f6677293b) |
---|---|
1/* 2 * PowerPC version 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 4 * 5 * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au) 6 * and Cort Dougan (PReP) (cort@cs.nmt.edu) 7 * Copyright (C) 1996 Paul Mackerras 8 * --- 27 unchanged lines hidden (view full) --- 36} 37 38static void pmd_ctor(void *addr) 39{ 40 memset(addr, 0, PMD_TABLE_SIZE); 41} 42 43struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE]; | 1/* 2 * PowerPC version 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 4 * 5 * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au) 6 * and Cort Dougan (PReP) (cort@cs.nmt.edu) 7 * Copyright (C) 1996 Paul Mackerras 8 * --- 27 unchanged lines hidden (view full) --- 36} 37 38static void pmd_ctor(void *addr) 39{ 40 memset(addr, 0, PMD_TABLE_SIZE); 41} 42 43struct kmem_cache *pgtable_cache[MAX_PGTABLE_INDEX_SIZE]; |
44EXPORT_SYMBOL_GPL(pgtable_cache); /* used by kvm_hv module */ |
|
44 45/* 46 * Create a kmem_cache() for pagetables. This is not used for PTE 47 * pages - they're linked to struct page, come from the normal free 48 * pages pool and have a different entry size (see real_pte_t) to 49 * everything else. Caches created by this function are used for all 50 * the higher level pagetables, and for hugepage pagetables. 51 */ --- 21 unchanged lines hidden (view full) --- 73 BUG_ON((shift < 1) || (shift > MAX_PGTABLE_INDEX_SIZE)); 74 75 if (PGT_CACHE(shift)) 76 return; /* Already have a cache of this size */ 77 78 align = max_t(unsigned long, align, minalign); 79 name = kasprintf(GFP_KERNEL, "pgtable-2^%d", shift); 80 new = kmem_cache_create(name, table_size, align, 0, ctor); | 45 46/* 47 * Create a kmem_cache() for pagetables. This is not used for PTE 48 * pages - they're linked to struct page, come from the normal free 49 * pages pool and have a different entry size (see real_pte_t) to 50 * everything else. Caches created by this function are used for all 51 * the higher level pagetables, and for hugepage pagetables. 52 */ --- 21 unchanged lines hidden (view full) --- 74 BUG_ON((shift < 1) || (shift > MAX_PGTABLE_INDEX_SIZE)); 75 76 if (PGT_CACHE(shift)) 77 return; /* Already have a cache of this size */ 78 79 align = max_t(unsigned long, align, minalign); 80 name = kasprintf(GFP_KERNEL, "pgtable-2^%d", shift); 81 new = kmem_cache_create(name, table_size, align, 0, ctor); |
81 if (!new) 82 panic("Could not allocate pgtable cache for order %d", shift); 83 | |
84 kfree(name); 85 pgtable_cache[shift - 1] = new; | 82 kfree(name); 83 pgtable_cache[shift - 1] = new; |
86 | |
87 pr_debug("Allocated pgtable cache for order %d\n", shift); 88} | 84 pr_debug("Allocated pgtable cache for order %d\n", shift); 85} |
86EXPORT_SYMBOL_GPL(pgtable_cache_add); /* used by kvm_hv module */ |
|
89 | 87 |
90 | |
91void pgtable_cache_init(void) 92{ 93 pgtable_cache_add(PGD_INDEX_SIZE, pgd_ctor); 94 | 88void pgtable_cache_init(void) 89{ 90 pgtable_cache_add(PGD_INDEX_SIZE, pgd_ctor); 91 |
95 if (PMD_CACHE_INDEX && !PGT_CACHE(PMD_CACHE_INDEX)) | 92 if (PMD_INDEX_SIZE && !PGT_CACHE(PMD_INDEX_SIZE)) |
96 pgtable_cache_add(PMD_CACHE_INDEX, pmd_ctor); 97 /* 98 * In all current configs, when the PUD index exists it's the 99 * same size as either the pgd or pmd index except with THP enabled 100 * on book3s 64 101 */ 102 if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) 103 pgtable_cache_add(PUD_INDEX_SIZE, pud_ctor); | 93 pgtable_cache_add(PMD_CACHE_INDEX, pmd_ctor); 94 /* 95 * In all current configs, when the PUD index exists it's the 96 * same size as either the pgd or pmd index except with THP enabled 97 * on book3s 64 98 */ 99 if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) 100 pgtable_cache_add(PUD_INDEX_SIZE, pud_ctor); |
101 102 if (!PGT_CACHE(PGD_INDEX_SIZE)) 103 panic("Couldn't allocate pgd cache"); 104 if (PMD_INDEX_SIZE && !PGT_CACHE(PMD_INDEX_SIZE)) 105 panic("Couldn't allocate pmd pgtable caches"); 106 if (PUD_INDEX_SIZE && !PGT_CACHE(PUD_INDEX_SIZE)) 107 panic("Couldn't allocate pud pgtable caches"); |
|
104} | 108} |