Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Replace mem_init_done with slab_is_available()

We have a powerpc specific global called mem_init_done which is "set on
boot once kmalloc can be called".

But that's not *quite* true. We set it at the bottom of mem_init(), and
rely on the fact that mm_init() calls kmem_cache_init() immediately
after that, and nothing is running in parallel.

So replace it with the generic and 100% correct slab_is_available().

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

+10 -15
-1
arch/powerpc/include/asm/setup.h
··· 7 7 extern void ppc_printk_progress(char *s, unsigned short hex); 8 8 9 9 extern unsigned int rtas_data; 10 - extern int mem_init_done; /* set on boot once kmalloc can be called */ 11 10 extern unsigned long long memory_limit; 12 11 extern unsigned long klimit; 13 12 extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
+1 -1
arch/powerpc/kernel/pci-common.c
··· 76 76 list_add_tail(&phb->list_node, &hose_list); 77 77 spin_unlock(&hose_spinlock); 78 78 phb->dn = dev; 79 - phb->is_dynamic = mem_init_done; 79 + phb->is_dynamic = slab_is_available(); 80 80 #ifdef CONFIG_PPC64 81 81 if (dev) { 82 82 int nid = of_node_to_nid(dev);
+2 -2
arch/powerpc/kernel/rtas.c
··· 401 401 buf = altbuf; 402 402 } else { 403 403 buf = rtas_err_buf; 404 - if (mem_init_done) 404 + if (slab_is_available()) 405 405 buf = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC); 406 406 } 407 407 if (buf) ··· 461 461 462 462 if (buff_copy) { 463 463 log_error(buff_copy, ERR_TYPE_RTAS_LOG, 0); 464 - if (mem_init_done) 464 + if (slab_is_available()) 465 465 kfree(buff_copy); 466 466 } 467 467 return ret;
+1 -1
arch/powerpc/lib/alloc.c
··· 10 10 { 11 11 void *p; 12 12 13 - if (mem_init_done) 13 + if (slab_is_available()) 14 14 p = kzalloc(size, mask); 15 15 else { 16 16 p = memblock_virt_alloc(size, 0);
-3
arch/powerpc/mm/mem.c
··· 61 61 #define CPU_FTR_NOEXECUTE 0 62 62 #endif 63 63 64 - int mem_init_done; 65 64 unsigned long long memory_limit; 66 65 67 66 #ifdef CONFIG_HIGHMEM ··· 376 377 pr_info(" * 0x%08lx..0x%08lx : vmalloc & ioremap\n", 377 378 VMALLOC_START, VMALLOC_END); 378 379 #endif /* CONFIG_PPC32 */ 379 - 380 - mem_init_done = 1; 381 380 } 382 381 383 382 void free_initmem(void)
+4 -5
arch/powerpc/mm/pgtable_32.c
··· 107 107 __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 108 108 { 109 109 pte_t *pte; 110 - extern int mem_init_done; 111 110 112 - if (mem_init_done) { 111 + if (slab_is_available()) { 113 112 pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); 114 113 } else { 115 114 pte = __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); ··· 215 216 * Don't allow anybody to remap normal RAM that we're using. 216 217 * mem_init() sets high_memory so only do the check after that. 217 218 */ 218 - if (mem_init_done && (p < virt_to_phys(high_memory)) && 219 + if (slab_is_available() && (p < virt_to_phys(high_memory)) && 219 220 !(__allow_ioremap_reserved && memblock_is_region_reserved(p, size))) { 220 221 printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n", 221 222 (unsigned long long)p, __builtin_return_address(0)); ··· 243 244 if ((v = p_mapped_by_tlbcam(p))) 244 245 goto out; 245 246 246 - if (mem_init_done) { 247 + if (slab_is_available()) { 247 248 struct vm_struct *area; 248 249 area = get_vm_area_caller(size, VM_IOREMAP, caller); 249 250 if (area == 0) ··· 262 263 for (i = 0; i < size && err == 0; i += PAGE_SIZE) 263 264 err = map_page(v+i, p+i, flags); 264 265 if (err) { 265 - if (mem_init_done) 266 + if (slab_is_available()) 266 267 vunmap((void *)v); 267 268 return NULL; 268 269 }
+2 -2
arch/powerpc/mm/pgtable_64.c
··· 231 231 if ((size == 0) || (paligned == 0)) 232 232 return NULL; 233 233 234 - if (mem_init_done) { 234 + if (slab_is_available()) { 235 235 struct vm_struct *area; 236 236 237 237 area = __get_vm_area_caller(size, VM_IOREMAP, ··· 315 315 { 316 316 void *addr; 317 317 318 - if (!mem_init_done) 318 + if (!slab_is_available()) 319 319 return; 320 320 321 321 addr = (void *) ((unsigned long __force)