Refine memblock API
Subsystems (41)
v2 cover Refine memblock API
Hi,
Current memblock API is quite extensive and, which is more annoying, duplicated. Except the low-level functions that allow searching for a free memory region and marking it as reserved, memblock provides three (well, two and a half) sets of functions to allocate memory. There are several overlapping functions that return a physical address and there are functions that return virtual address. Those that return the virtual address may also clear the allocated memory. And, on top of all that, some allocators panic and some return NULL in case of error.
This set tries to reduce the mess, and trim down the amount of memblock allocation methods.
Patches 1-10 consolidate the functions that return physical address of the allocated memory
Patches 11-13 are some trivial cleanups
Patches 14-19 add checks for the return value of memblock_alloc*() and panics in case of errors. The patches 14-18 include some minor refactoring to have better readability of the resulting code and patch 19 is a mechanical addition of
if (!ptr) panic();
after memblock_alloc*() calls.
And, finally, patches 20 and 21 remove panic() calls memblock and _nopanic variants from memblock.
v2 changes:
* replace some more %lu with %zu
* remove panics where they are not needed in s390 and in printk
* collect Acked-by and Reviewed-by.
Christophe Leroy (1):
powerpc: use memblock functions returning virtual address
Mike Rapoport (20):
openrisc: prefer memblock APIs returning virtual address
memblock: replace memblock_alloc_base(ANYWHERE) with memblock_phys_alloc
memblock: drop memblock_alloc_base_nid()
memblock: emphasize that memblock_alloc_range() returns a physical address
memblock: memblock_phys_alloc_try_nid(): don't panic
memblock: memblock_phys_alloc(): don't panic
memblock: drop __memblock_alloc_base()
memblock: drop memblock_alloc_base()
memblock: refactor internal allocation functions
memblock: make memblock_find_in_range_node() and choose_memblock_flags() static
arch: use memblock_alloc() instead of memblock_alloc_from(size, align, 0)
arch: don't memset(0) memory returned by memblock_alloc()
ia64: add checks for the return value of memblock_alloc*()
sparc: add checks for the return value of memblock_alloc*() mm/percpu: add checks for the return value of memblock_alloc*() init/main: add checks for the return value of memblock_alloc*()
swiotlb: add checks for the return value of memblock_alloc*()
treewide: add checks for the return value of memblock_alloc*()
memblock: memblock_alloc_try_nid: don't panic
memblock: drop memblock_alloc_*_nopanic() variants
arch/alpha/kernel/core_cia.c | 5 +- arch/alpha/kernel/core_marvel.c | 6 + arch/alpha/kernel/pci-noop.c | 13 +- arch/alpha/kernel/pci.c | 11 +- arch/alpha/kernel/pci_iommu.c | 16 +- arch/alpha/kernel/setup.c | 2 +- arch/arc/kernel/unwind.c | 3 +- arch/arc/mm/highmem.c | 4 + arch/arm/kernel/setup.c | 6 + arch/arm/mm/init.c | 6 +- arch/arm/mm/mmu.c | 14 +- arch/arm64/kernel/setup.c | 8 +- arch/arm64/mm/kasan_init.c | 10 ++ arch/arm64/mm/mmu.c | 2 + arch/arm64/mm/numa.c | 4 + arch/c6x/mm/dma-coherent.c | 4 + arch/c6x/mm/init.c | 4 +- arch/csky/mm/highmem.c | 5 + arch/h8300/mm/init.c | 4 +- arch/ia64/kernel/mca.c | 25 +-- arch/ia64/mm/contig.c | 8 +- arch/ia64/mm/discontig.c | 4 + arch/ia64/mm/init.c | 38 ++++- arch/ia64/mm/tlb.c | 6 + arch/ia64/sn/kernel/io_common.c | 3 + arch/ia64/sn/kernel/setup.c | 12 +- arch/m68k/atari/stram.c | 4 + arch/m68k/mm/init.c | 3 + arch/m68k/mm/mcfmmu.c | 7 +- arch/m68k/mm/motorola.c | 9 ++ arch/m68k/mm/sun3mmu.c | 6 + arch/m68k/sun3/sun3dvma.c | 3 + arch/microblaze/mm/init.c | 10 +- arch/mips/cavium-octeon/dma-octeon.c | 3 + arch/mips/kernel/setup.c | 3 + arch/mips/kernel/traps.c | 5 +- arch/mips/mm/init.c | 5 + arch/nds32/mm/init.c | 12 ++ arch/openrisc/mm/init.c | 5 +- arch/openrisc/mm/ioremap.c | 8 +- arch/powerpc/kernel/dt_cpu_ftrs.c | 8 +- arch/powerpc/kernel/irq.c | 5 - arch/powerpc/kernel/paca.c | 6 +- arch/powerpc/kernel/pci_32.c | 3 + arch/powerpc/kernel/prom.c | 5 +- arch/powerpc/kernel/rtas.c | 6 +- arch/powerpc/kernel/setup-common.c | 3 + arch/powerpc/kernel/setup_32.c | 26 ++-- arch/powerpc/kernel/setup_64.c | 4 + arch/powerpc/lib/alloc.c | 3 + arch/powerpc/mm/hash_utils_64.c | 11 +- arch/powerpc/mm/mmu_context_nohash.c | 9 ++ arch/powerpc/mm/numa.c | 4 + arch/powerpc/mm/pgtable-book3e.c | 12 +- arch/powerpc/mm/pgtable-book3s64.c | 3 + arch/powerpc/mm/pgtable-radix.c | 9 +- arch/powerpc/mm/ppc_mmu_32.c | 3 + arch/powerpc/platforms/pasemi/iommu.c | 3 + arch/powerpc/platforms/powermac/nvram.c | 3 + arch/powerpc/platforms/powernv/opal.c | 3 + arch/powerpc/platforms/powernv/pci-ioda.c | 8 + arch/powerpc/platforms/ps3/setup.c | 3 + arch/powerpc/sysdev/dart_iommu.c | 3 + arch/powerpc/sysdev/msi_bitmap.c | 3 + arch/s390/kernel/crash_dump.c | 3 + arch/s390/kernel/setup.c | 16 ++ arch/s390/kernel/smp.c | 9 +- arch/s390/kernel/topology.c | 6 + arch/s390/numa/mode_emu.c | 3 + arch/s390/numa/numa.c | 6 +- arch/sh/boards/mach-ap325rxa/setup.c | 5 +- arch/sh/boards/mach-ecovec24/setup.c | 10 +- arch/sh/boards/mach-kfr2r09/setup.c | 5 +- arch/sh/boards/mach-migor/setup.c | 5 +- arch/sh/boards/mach-se/7724/setup.c | 10 +- arch/sh/kernel/machine_kexec.c | 3 +- arch/sh/mm/init.c | 8 +- arch/sh/mm/numa.c | 4 + arch/sparc/kernel/prom_32.c | 6 +- arch/sparc/kernel/setup_64.c | 6 + arch/sparc/kernel/smp_64.c | 12 ++ arch/sparc/mm/init_32.c | 2 +- arch/sparc/mm/init_64.c | 11 ++ arch/sparc/mm/srmmu.c | 18 ++- arch/um/drivers/net_kern.c | 3 + arch/um/drivers/vector_kern.c | 3 + arch/um/kernel/initrd.c | 2 + arch/um/kernel/mem.c | 16 ++ arch/unicore32/kernel/setup.c | 4 + arch/unicore32/mm/mmu.c | 15 +- arch/x86/kernel/acpi/boot.c | 3 + arch/x86/kernel/apic/io_apic.c | 5 + arch/x86/kernel/e820.c | 5 +- arch/x86/kernel/setup_percpu.c | 10 +- arch/x86/mm/kasan_init_64.c | 14 +- arch/x86/mm/numa.c | 12 +- arch/x86/platform/olpc/olpc_dt.c | 3 + arch/x86/xen/p2m.c | 11 +- arch/xtensa/mm/kasan_init.c | 10 +- arch/xtensa/mm/mmu.c | 3 + drivers/clk/ti/clk.c | 3 + drivers/firmware/memmap.c | 2 +- drivers/macintosh/smu.c | 5 +- drivers/of/fdt.c | 8 +- drivers/of/of_reserved_mem.c | 7 +- drivers/of/unittest.c | 8 +- drivers/usb/early/xhci-dbc.c | 2 +- drivers/xen/swiotlb-xen.c | 7 +- include/linux/memblock.h | 59 +------ init/main.c | 26 +++- kernel/dma/swiotlb.c | 21 ++- kernel/power/snapshot.c | 3 + kernel/printk/printk.c | 9 +- lib/cpumask.c | 3 + mm/cma.c | 10 +- mm/kasan/init.c | 10 +- mm/memblock.c | 249 ++++++++++-------------------- mm/page_alloc.c | 10 +- mm/page_ext.c | 2 +- mm/percpu.c | 84 +++++++--- mm/sparse.c | 25 ++- 121 files changed, 860 insertions(+), 412 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/21 openrisc: prefer memblock APIs returning virtual address
The allocation of the page tables memory in openrics uses memblock_phys_alloc() and then converts the returned physical address to virtual one. Use memblock_alloc_raw() and add a panic() if the allocation fails.
--- arch/openrisc/mm/init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/openrisc/mm/init.c +4 -1
@@ -105,7 +105,10 @@ static void __init map_ram(void) }/* Alloc one page for holding PTE's... */ - pte = (pte_t *)__va (memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE )); + pte =memblock_alloc_raw (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate page for PTEs\n" , + __func__);set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */
Signature · 1 line
2.7.4
Re: [PATCH v2 01/21] openrisc: prefer memblock APIs returning virtual address
Quoted 16 lines · Mike Rapoport
The allocation of the page tables memory in openrics uses
memblock_phys_alloc()and then converts the returned physical address to virtual one. Usememblock_alloc_raw()and add apanic()if the allocation fails.Signed-off-by Mike Rapoport <[email protected]>--- arch/openrisc/mm/init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/openrisc/mm/init.c +0
-0@@ -105,7 +105,10 @@ static void __init map_ram(void) }
arch/openrisc/mm/init.c static void __init map_ram(void) · line 114
Quoted 10 lines
arch/openrisc/mm/init.c +4
-1/* Alloc one page for holding PTE's... */ - pte = (pte_t *)__va (memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE )); + pte =memblock_alloc_raw (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate page for PTEs\n" , + __func__);set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */
This seems reasonable to me.
Re: [PATCH v2 01/21] openrisc: prefer memblock APIs returning virtual address
In reply to Mike RapoportQuoted 16 lines · Mike Rapoport
The allocation of the page tables memory in openrics uses
memblock_phys_alloc()and then converts the returned physical address to virtual one. Usememblock_alloc_raw()and add apanic()if the allocation fails.Signed-off-by Mike Rapoport <[email protected]>--- arch/openrisc/mm/init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/openrisc/mm/init.c +0
-0@@ -105,7 +105,10 @@ static void __init map_ram(void) }
arch/openrisc/mm/init.c static void __init map_ram(void) · line 114
Quoted 10 lines
arch/openrisc/mm/init.c +4
-1/* Alloc one page for holding PTE's... */ - pte = (pte_t *)__va (memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE )); + pte =memblock_alloc_raw (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate page for PTEs\n" , + __func__);set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */
This seems reasonable to me.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/21 openrisc: prefer memblock APIs returning virtual address
In reply to Mike RapoportThe allocation of the page tables memory in openrics uses memblock_phys_alloc() and then converts the returned physical address to virtual one. Use memblock_alloc_raw() and add a panic() if the allocation fails.
--- arch/openrisc/mm/init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/openrisc/mm/init.c +4 -1
@@ -105,7 +105,10 @@ static void __init map_ram(void) }/* Alloc one page for holding PTE's... */ - pte = (pte_t *)__va (memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE )); + pte =memblock_alloc_raw (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate page for PTEs\n" , + __func__);set_pmd (pme,__pmd (_KERNPG_TABLE +__pa (pte)));/* Fill the newly allocated page with PTE'S */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/21 powerpc: use memblock functions returning virtual address
In reply to Mike RapoportFrom: Christophe Leroy <[email protected]>
Since only the virtual address of allocated blocks is used, lets use functions returning directly virtual address.
Those functions have the advantage of also zeroing the block.
[ MR:
- updated error message in alloc_stack() to be more verbose
- convereted several additional call sites ]
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 3 +-- arch/powerpc/kernel/irq.c | 5 ----- arch/powerpc/kernel/paca.c | 6 +++++- arch/powerpc/kernel/prom.c | 5 ++++- arch/powerpc/kernel/setup_32.c | 26 ++++++++++++++++---------- 5 files changed, 26 insertions(+), 19 deletions(-)
arch/powerpc/kernel/dt_cpu_ftrs.c +1 -2
@@ -813,7 +813,6 @@ static int __init process_cpufeatures_node(unsigned long node,int len; f = &dt_cpu_features[i]; -memset (f,0 ,sizeof (struct dt_cpu_feature )); f->node = node;
@@ -1008,7 +1007,7 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char/* Count and allocate space for cpu features */ of_scan_flat_dt_subnodes (node, count_cpufeatures_subnodes, &nr_dt_cpu_features); - dt_cpu_features =__va (memblock_phys_alloc (sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features,PAGE_SIZE )); + dt_cpu_features =memblock_alloc (sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features,PAGE_SIZE );cpufeatures_setup_start (isa);
arch/powerpc/kernel/irq.c +0 -5
@@ -725,18 +725,15 @@ void exc_lvl_ctx_init(void)#endif #endif -memset ((void *)critirq_ctx[cpu_nr],0 ,THREAD_SIZE ); tp = critirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count =0 ;#ifdef CONFIG_BOOKE -memset ((void *)dbgirq_ctx[cpu_nr],0 ,THREAD_SIZE ); tp = dbgirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count =0 ; -memset ((void *)mcheckirq_ctx[cpu_nr],0 ,THREAD_SIZE ); tp = mcheckirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count =HARDIRQ_OFFSET ;
@@ -754,12 +751,10 @@ void irq_ctx_init(void)int i;for_each_possible_cpu (i) { -memset ((void *)softirq_ctx[i],0 ,THREAD_SIZE ); tp = softirq_ctx[i]; tp->cpu = i;klp_init_thread_info (tp); -memset ((void *)hardirq_ctx[i],0 ,THREAD_SIZE ); tp = hardirq_ctx[i]; tp->cpu = i;klp_init_thread_info (tp);
arch/powerpc/kernel/paca.c +5 -1
@@ -196,7 +196,11 @@ void __init allocate_paca_ptrs(void) paca_nr_cpu_ids = nr_cpu_ids; paca_ptrs_size =sizeof (struct paca_struct *) * nr_cpu_ids; - paca_ptrs =__va (memblock_phys_alloc (paca_ptrs_size,SMP_CACHE_BYTES )); + paca_ptrs =memblock_alloc_raw (paca_ptrs_size,SMP_CACHE_BYTES ); +if (!paca_ptrs) +panic ("Failed to allocate %d bytes for paca pointers\n" , + paca_ptrs_size); +memset (paca_ptrs,0x88 , paca_ptrs_size); }
arch/powerpc/kernel/prom.c +4 -1
@@ -127,7 +127,10 @@ static void __init move_device_tree(void)if ((memory_limit && (start + size) >PHYSICAL_START + memory_limit) || !memblock_is_memory (start + size -1 ) ||overlaps_crashkernel (start, size) ||overlaps_initrd (start, size)) { - p =__va (memblock_phys_alloc (size,PAGE_SIZE )); + p =memblock_alloc_raw (size,PAGE_SIZE ); +if (!p) +panic ("Failed to allocate %lu bytes to move device tree\n" , + size);memcpy (p, initial_boot_params, size); initial_boot_params = p;DBG ("Moved device tree to 0x%px\n" , p);
arch/powerpc/kernel/setup_32.c +16 -10
@@ -196,6 +196,17 @@ static int __init ppc_init(void) }arch_initcall (ppc_init); +static void *__init alloc_stack (void ) +{ +void *ptr =memblock_alloc (THREAD_SIZE ,THREAD_SIZE ); + +if (!ptr) +panic ("cannot allocate %d bytes for stack at %pS\n" , +THREAD_SIZE , (void *)_RET_IP_); + +return ptr; +} +void __init irqstack_early_init (void ) {unsigned int i;
@@ -203,10 +214,8 @@ void __init irqstack_early_init(void)/* interrupt stacks must be in lowmem, we get that for free on ppc32 * as the memblock is limited to lowmem by default */ for_each_possible_cpu (i) { - softirq_ctx[i] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); - hardirq_ctx[i] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); + softirq_ctx[i] =alloc_stack (); + hardirq_ctx[i] =alloc_stack (); } }
@@ -224,13 +233,10 @@ void __init exc_lvl_early_init(void) hw_cpu =0 ;#endif - critirq_ctx[hw_cpu] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); + critirq_ctx[hw_cpu] =alloc_stack ();#ifdef CONFIG_BOOKE - dbgirq_ctx[hw_cpu] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); - mcheckirq_ctx[hw_cpu] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); + dbgirq_ctx[hw_cpu] =alloc_stack (); + mcheckirq_ctx[hw_cpu] =alloc_stack ();#endif } }
Signature · 1 line
2.7.4
Re: [PATCH v2 02/21] powerpc: use memblock functions returning virtual address
Quoted 13 lines · Mike Rapoport
From: Christophe Leroy <[email protected]>
Since only the virtual address of allocated blocks is used, lets use functions returning directly virtual address.
Those functions have the advantage of also zeroing the block.
[ MR:
- updated error message inalloc_stack()to be more verbose
- convereted several additional call sites ]Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Mike Rapoport <[email protected]>
Quoted 7 lines
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 3 +-- arch/powerpc/kernel/irq.c | 5 ----- arch/powerpc/kernel/paca.c | 6 +++++- arch/powerpc/kernel/prom.c | 5 ++++- arch/powerpc/kernel/setup_32.c | 26 ++++++++++++++++---------- 5 files changed, 26 insertions(+), 19 deletions(-)
LGTM.
cheers
Re: [PATCH v2 02/21] powerpc: use memblock functions returning virtual address
In reply to Mike RapoportQuoted 13 lines · Mike Rapoport
From: Christophe Leroy <[email protected]>
Since only the virtual address of allocated blocks is used, lets use functions returning directly virtual address.
Those functions have the advantage of also zeroing the block.
[ MR:
- updated error message inalloc_stack()to be more verbose
- convereted several additional call sites ]Signed-off-by Christophe Leroy <[email protected]>Signed-off-by Mike Rapoport <[email protected]>
Quoted 7 lines
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 3 +-- arch/powerpc/kernel/irq.c | 5 ----- arch/powerpc/kernel/paca.c | 6 +++++- arch/powerpc/kernel/prom.c | 5 ++++- arch/powerpc/kernel/setup_32.c | 26 ++++++++++++++++---------- 5 files changed, 26 insertions(+), 19 deletions(-)
LGTM.
cheers
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/21 powerpc: use memblock functions returning virtual address
In reply to Mike RapoportFrom: Christophe Leroy <[email protected]>
Since only the virtual address of allocated blocks is used, lets use functions returning directly virtual address.
Those functions have the advantage of also zeroing the block.
[ MR:
- updated error message in alloc_stack() to be more verbose
- convereted several additional call sites ]
--- arch/powerpc/kernel/dt_cpu_ftrs.c | 3 +-- arch/powerpc/kernel/irq.c | 5 ----- arch/powerpc/kernel/paca.c | 6 +++++- arch/powerpc/kernel/prom.c | 5 ++++- arch/powerpc/kernel/setup_32.c | 26 ++++++++++++++++---------- 5 files changed, 26 insertions(+), 19 deletions(-)
arch/powerpc/kernel/dt_cpu_ftrs.c +1 -2
@@ -813,7 +813,6 @@ static int __init process_cpufeatures_node(unsigned long node,int len; f = &dt_cpu_features[i]; -memset (f,0 ,sizeof (struct dt_cpu_feature )); f->node = node;
@@ -1008,7 +1007,7 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char/* Count and allocate space for cpu features */ of_scan_flat_dt_subnodes (node, count_cpufeatures_subnodes, &nr_dt_cpu_features); - dt_cpu_features =__va (memblock_phys_alloc (sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features,PAGE_SIZE )); + dt_cpu_features =memblock_alloc (sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features,PAGE_SIZE );cpufeatures_setup_start (isa);
arch/powerpc/kernel/irq.c +0 -5
@@ -725,18 +725,15 @@ void exc_lvl_ctx_init(void)#endif #endif -memset ((void *)critirq_ctx[cpu_nr],0 ,THREAD_SIZE ); tp = critirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count =0 ;#ifdef CONFIG_BOOKE -memset ((void *)dbgirq_ctx[cpu_nr],0 ,THREAD_SIZE ); tp = dbgirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count =0 ; -memset ((void *)mcheckirq_ctx[cpu_nr],0 ,THREAD_SIZE ); tp = mcheckirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count =HARDIRQ_OFFSET ;
@@ -754,12 +751,10 @@ void irq_ctx_init(void)int i;for_each_possible_cpu (i) { -memset ((void *)softirq_ctx[i],0 ,THREAD_SIZE ); tp = softirq_ctx[i]; tp->cpu = i;klp_init_thread_info (tp); -memset ((void *)hardirq_ctx[i],0 ,THREAD_SIZE ); tp = hardirq_ctx[i]; tp->cpu = i;klp_init_thread_info (tp);
arch/powerpc/kernel/paca.c +5 -1
@@ -196,7 +196,11 @@ void __init allocate_paca_ptrs(void) paca_nr_cpu_ids = nr_cpu_ids; paca_ptrs_size =sizeof (struct paca_struct *) * nr_cpu_ids; - paca_ptrs =__va (memblock_phys_alloc (paca_ptrs_size,SMP_CACHE_BYTES )); + paca_ptrs =memblock_alloc_raw (paca_ptrs_size,SMP_CACHE_BYTES ); +if (!paca_ptrs) +panic ("Failed to allocate %d bytes for paca pointers\n" , + paca_ptrs_size); +memset (paca_ptrs,0x88 , paca_ptrs_size); }
arch/powerpc/kernel/prom.c +4 -1
@@ -127,7 +127,10 @@ static void __init move_device_tree(void)if ((memory_limit && (start + size) >PHYSICAL_START + memory_limit) || !memblock_is_memory (start + size -1 ) ||overlaps_crashkernel (start, size) ||overlaps_initrd (start, size)) { - p =__va (memblock_phys_alloc (size,PAGE_SIZE )); + p =memblock_alloc_raw (size,PAGE_SIZE ); +if (!p) +panic ("Failed to allocate %lu bytes to move device tree\n" , + size);memcpy (p, initial_boot_params, size); initial_boot_params = p;DBG ("Moved device tree to 0x%px\n" , p);
arch/powerpc/kernel/setup_32.c +16 -10
@@ -196,6 +196,17 @@ static int __init ppc_init(void) }arch_initcall (ppc_init); +static void *__init alloc_stack (void ) +{ +void *ptr =memblock_alloc (THREAD_SIZE ,THREAD_SIZE ); + +if (!ptr) +panic ("cannot allocate %d bytes for stack at %pS\n" , +THREAD_SIZE , (void *)_RET_IP_); + +return ptr; +} +void __init irqstack_early_init (void ) {unsigned int i;
@@ -203,10 +214,8 @@ void __init irqstack_early_init(void)/* interrupt stacks must be in lowmem, we get that for free on ppc32 * as the memblock is limited to lowmem by default */ for_each_possible_cpu (i) { - softirq_ctx[i] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); - hardirq_ctx[i] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); + softirq_ctx[i] =alloc_stack (); + hardirq_ctx[i] =alloc_stack (); } }
@@ -224,13 +233,10 @@ void __init exc_lvl_early_init(void) hw_cpu =0 ;#endif - critirq_ctx[hw_cpu] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); + critirq_ctx[hw_cpu] =alloc_stack ();#ifdef CONFIG_BOOKE - dbgirq_ctx[hw_cpu] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); - mcheckirq_ctx[hw_cpu] = (struct thread_info *) -__va (memblock_phys_alloc (THREAD_SIZE ,THREAD_SIZE )); + dbgirq_ctx[hw_cpu] =alloc_stack (); + mcheckirq_ctx[hw_cpu] =alloc_stack ();#endif } }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 3/21 memblock: replace memblock_alloc_base(ANYWHERE) with memblock_phys_alloc
In reply to Mike RapoportThe calls to memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE) and memblock_phys_alloc(size, align) are equivalent as both try to allocate 'size' bytes with 'align' alignment anywhere in the memory and panic if hte allocation fails.
The conversion is done using the following semantic patch:
@@
expression size, align;
@@
- memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE)
+ memblock_phys_alloc(size, align)
--- arch/arm/mm/init.c | 2 +- arch/sh/boards/mach-ap325rxa/setup.c | 2 +- arch/sh/boards/mach-ecovec24/setup.c | 4 ++-- arch/sh/boards/mach-kfr2r09/setup.c | 2 +- arch/sh/boards/mach-migor/setup.c | 2 +- arch/sh/boards/mach-se/7724/setup.c | 4 ++-- arch/xtensa/mm/kasan_init.c | 3 +-- 7 files changed, 9 insertions(+), 10 deletions(-)
arch/arm/mm/init.c +1 -1
@@ -205,7 +205,7 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)BUG_ON (!arm_memblock_steal_permitted); - phys =memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size, align);memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-ap325rxa/setup.c +1 -1
@@ -557,7 +557,7 @@ static void __init ap325rxa_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-ecovec24/setup.c +2 -2
@@ -1480,12 +1480,12 @@ static void __init ecovec_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/sh/boards/mach-kfr2r09/setup.c +1 -1
@@ -631,7 +631,7 @@ static void __init kfr2r09_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-migor/setup.c +1 -1
@@ -630,7 +630,7 @@ static void __init migor_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-se/7724/setup.c +2 -2
@@ -965,12 +965,12 @@ static void __init ms7724se_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/xtensa/mm/kasan_init.c +1 -2
@@ -52,8 +52,7 @@ static void __init populate(void *start, void *end)for (k =0 ; k <PTRS_PER_PTE ; ++k, ++j) {phys_addr_t phys = -memblock_alloc_base (PAGE_SIZE ,PAGE_SIZE , -MEMBLOCK_ALLOC_ANYWHERE ); +memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE );set_pte (pte + j,pfn_pte (PHYS_PFN (phys),PAGE_KERNEL )); }
Signature · 1 line
2.7.4
PATCH v2 3/21 memblock: replace memblock_alloc_base(ANYWHERE) with memblock_phys_alloc
In reply to Mike RapoportThe calls to memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE) and memblock_phys_alloc(size, align) are equivalent as both try to allocate 'size' bytes with 'align' alignment anywhere in the memory and panic if hte allocation fails.
The conversion is done using the following semantic patch:
@@
expression size, align;
@@
- memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE)
+ memblock_phys_alloc(size, align)
--- arch/arm/mm/init.c | 2 +- arch/sh/boards/mach-ap325rxa/setup.c | 2 +- arch/sh/boards/mach-ecovec24/setup.c | 4 ++-- arch/sh/boards/mach-kfr2r09/setup.c | 2 +- arch/sh/boards/mach-migor/setup.c | 2 +- arch/sh/boards/mach-se/7724/setup.c | 4 ++-- arch/xtensa/mm/kasan_init.c | 3 +-- 7 files changed, 9 insertions(+), 10 deletions(-)
arch/arm/mm/init.c +1 -1
@@ -205,7 +205,7 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)BUG_ON (!arm_memblock_steal_permitted); - phys =memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size, align);memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-ap325rxa/setup.c +1 -1
@@ -557,7 +557,7 @@ static void __init ap325rxa_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-ecovec24/setup.c +2 -2
@@ -1480,12 +1480,12 @@ static void __init ecovec_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/sh/boards/mach-kfr2r09/setup.c +1 -1
@@ -631,7 +631,7 @@ static void __init kfr2r09_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-migor/setup.c +1 -1
@@ -630,7 +630,7 @@ static void __init migor_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-se/7724/setup.c +2 -2
@@ -965,12 +965,12 @@ static void __init ms7724se_mv_mem_reserve(void)phys_addr_t phys;phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; - phys =memblock_alloc_base (size,PAGE_SIZE ,MEMBLOCK_ALLOC_ANYWHERE ); + phys =memblock_phys_alloc (size,PAGE_SIZE );memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/xtensa/mm/kasan_init.c +1 -2
@@ -52,8 +52,7 @@ static void __init populate(void *start, void *end)for (k =0 ; k <PTRS_PER_PTE ; ++k, ++j) {phys_addr_t phys = -memblock_alloc_base (PAGE_SIZE ,PAGE_SIZE , -MEMBLOCK_ALLOC_ANYWHERE ); +memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE );set_pte (pte + j,pfn_pte (PHYS_PFN (phys),PAGE_KERNEL )); }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 4/21 memblock: drop memblock_alloc_base_nid()
In reply to Mike RapoportThe memblock_alloc_base_nid() is a oneliner wrapper for memblock_alloc_range_nid() without any side effect. Replace it's usage by the direct calls to memblock_alloc_range_nid().
--- include/linux/memblock.h | 3 --- mm/memblock.c | 15 ++++----------- 2 files changed, 4 insertions(+), 14 deletions(-)
include/linux/memblock.h +0 -3
@@ -490,9 +490,6 @@ static inline bool memblock_bottom_up(void)phys_addr_t __init memblock_alloc_range (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end,enum memblock_flags flags); -phys_addr_t memblock_alloc_base_nid (phys_addr_t size, -phys_addr_t align,phys_addr_t max_addr, -int nid,enum memblock_flags flags);phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr); phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align,
mm/memblock.c +4 -11
@@ -1346,21 +1346,14 @@ phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align, flags); } -phys_addr_t __init memblock_alloc_base_nid (phys_addr_t size, -phys_addr_t align,phys_addr_t max_addr, -int nid,enum memblock_flags flags) -{ -return memblock_alloc_range_nid (size, align,0 , max_addr, nid, flags); -} -phys_addr_t __init memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid) {enum memblock_flags flags =choose_memblock_flags ();phys_addr_t ret; again: - ret =memblock_alloc_base_nid (size, align,MEMBLOCK_ALLOC_ACCESSIBLE , - nid, flags); + ret =memblock_alloc_range_nid (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE , nid, flags);if (!ret && (flags &MEMBLOCK_MIRROR )) { flags &= ~MEMBLOCK_MIRROR ;
@@ -1371,8 +1364,8 @@ phys_addr_t __init memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align,phys_addr_t __init __memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) { -return memblock_alloc_base_nid (size, align, max_addr,NUMA_NO_NODE , -MEMBLOCK_NONE ); +return memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , +MEMBLOCK_NONE ); }phys_addr_t __init memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 5/21 memblock: emphasize that memblock_alloc_range() returns a physical address
In reply to Mike RapoportRename memblock_alloc_range() to memblock_phys_alloc_range() to emphasize that it returns a physical address.
While on it, remove the 'enum memblock_flags' parameter from this function as its only user anyway sets it to MEMBLOCK_NONE, which is the default for the most of memblock allocations.
--- include/linux/memblock.h | 5 ++--- mm/cma.c | 10 ++++------ mm/memblock.c | 9 +++++---- 3 files changed, 11 insertions(+), 13 deletions(-)
include/linux/memblock.h +2 -3
@@ -369,6 +369,8 @@ static inline int memblock_get_region_node(const struct memblock_region *r)#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL#endif +phys_addr_t memblock_phys_alloc_range (phys_addr_t size,phys_addr_t align, +phys_addr_t start,phys_addr_t end);phys_addr_t memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid);
@@ -487,9 +489,6 @@ static inline bool memblock_bottom_up(void)return memblock.bottom_up; } -phys_addr_t __init memblock_alloc_range (phys_addr_t size,phys_addr_t align, -phys_addr_t start,phys_addr_t end, -enum memblock_flags flags);phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr); phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align,
mm/cma.c +4 -6
@@ -327,16 +327,14 @@ int __init cma_declare_contiguous(phys_addr_t base,* memory in case of failure. */ if (base < highmem_start && limit > highmem_start) { - addr =memblock_alloc_range (size, alignment, - highmem_start, limit, -MEMBLOCK_NONE ); + addr =memblock_phys_alloc_range (size, alignment, + highmem_start, limit); limit = highmem_start; }if (!addr) { - addr =memblock_alloc_range (size, alignment, base, - limit, -MEMBLOCK_NONE ); + addr =memblock_phys_alloc_range (size, alignment, base, + limit);if (!addr) { ret = -ENOMEM ; goto err;
mm/memblock.c +5 -4
@@ -1338,12 +1338,13 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,return 0 ; } -phys_addr_t __init memblock_alloc_range (phys_addr_t size,phys_addr_t align, -phys_addr_t start,phys_addr_t end, -enum memblock_flags flags) +phys_addr_t __init memblock_phys_alloc_range (phys_addr_t size, +phys_addr_t align, +phys_addr_t start, +phys_addr_t end) {return memblock_alloc_range_nid (size, align, start, end,NUMA_NO_NODE , - flags); +MEMBLOCK_NONE ); }phys_addr_t __init memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid)
Signature · 1 line
2.7.4
PATCH v2 5/21 memblock: emphasize that memblock_alloc_range() returns a physical address
In reply to Mike RapoportRename memblock_alloc_range() to memblock_phys_alloc_range() to emphasize that it returns a physical address.
While on it, remove the 'enum memblock_flags' parameter from this function as its only user anyway sets it to MEMBLOCK_NONE, which is the default for the most of memblock allocations.
--- include/linux/memblock.h | 5 ++--- mm/cma.c | 10 ++++------ mm/memblock.c | 9 +++++---- 3 files changed, 11 insertions(+), 13 deletions(-)
include/linux/memblock.h +2 -3
@@ -369,6 +369,8 @@ static inline int memblock_get_region_node(const struct memblock_region *r)#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL#endif +phys_addr_t memblock_phys_alloc_range (phys_addr_t size,phys_addr_t align, +phys_addr_t start,phys_addr_t end);phys_addr_t memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid);
@@ -487,9 +489,6 @@ static inline bool memblock_bottom_up(void)return memblock.bottom_up; } -phys_addr_t __init memblock_alloc_range (phys_addr_t size,phys_addr_t align, -phys_addr_t start,phys_addr_t end, -enum memblock_flags flags);phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr); phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align,
mm/cma.c +4 -6
@@ -327,16 +327,14 @@ int __init cma_declare_contiguous(phys_addr_t base,* memory in case of failure. */ if (base < highmem_start && limit > highmem_start) { - addr =memblock_alloc_range (size, alignment, - highmem_start, limit, -MEMBLOCK_NONE ); + addr =memblock_phys_alloc_range (size, alignment, + highmem_start, limit); limit = highmem_start; }if (!addr) { - addr =memblock_alloc_range (size, alignment, base, - limit, -MEMBLOCK_NONE ); + addr =memblock_phys_alloc_range (size, alignment, base, + limit);if (!addr) { ret = -ENOMEM ; goto err;
mm/memblock.c +5 -4
@@ -1338,12 +1338,13 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,return 0 ; } -phys_addr_t __init memblock_alloc_range (phys_addr_t size,phys_addr_t align, -phys_addr_t start,phys_addr_t end, -enum memblock_flags flags) +phys_addr_t __init memblock_phys_alloc_range (phys_addr_t size, +phys_addr_t align, +phys_addr_t start, +phys_addr_t end) {return memblock_alloc_range_nid (size, align, start, end,NUMA_NO_NODE , - flags); +MEMBLOCK_NONE ); }phys_addr_t __init memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 6/21 memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Mike RapoportThe memblock_phys_alloc_try_nid() function tries to allocate memory from the requested node and then falls back to allocation from any node in the system. The memblock_alloc_base() fallback used by this function panics if the allocation fails.
Replace the memblock_alloc_base() fallback with the direct call to memblock_alloc_range_nid() and update the memblock_phys_alloc_try_nid() callers to check the returned value and panic in case of error.
--- arch/arm64/mm/numa.c | 4 ++++ arch/powerpc/mm/numa.c | 4 ++++ mm/memblock.c | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-)
arch/arm64/mm/numa.c +4 -0
@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);/* report and initialize */
arch/powerpc/mm/numa.c +4 -0
@@ -788,6 +788,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)int tnid; nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);/* report and initialize */
mm/memblock.c +3 -1
@@ -1393,7 +1393,9 @@ phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t aliif (res)return res; -return memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ACCESSIBLE ); +return memblock_alloc_range_nid (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE , +NUMA_NO_NODE ,MEMBLOCK_NONE ); }/**
Signature · 1 line
2.7.4
Catalin Marinas
maintainerRe: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
Quoted 5 lines · Mike Rapoport
arch/arm64/mm/numa.c +0
-0
arch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 246
Quoted 10 lines
arch/arm64/mm/numa.c +4
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);/* report and initialize */
Does it mean that memblock_phys_alloc_try_nid() never returns valid physical memory starting at 0?
Signature · 1 line
Catalin
Re: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
Quoted 15 lines · Catalin Marinas
Quoted 14 lines · Mike Rapoport
arch/arm64/mm/numa.c +4
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);
Quoted 4 lines
arch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 246
Quoted 1 line
arch/arm64/mm/numa.c +0
-0/* report and initialize */ Does it mean that
memblock_phys_alloc_try_nid()never returns valid physical memory starting at 0?
Yes, it does.memblock_find_in_range_node() that is used by all allocation methods skips the first page [1].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/memblock.c#n257
Quoted 3 lines
Signature · 1 line
Catalin
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Catalin MarinasQuoted 15 lines · Catalin Marinas
Quoted 14 lines · Mike Rapoport
arch/arm64/mm/numa.c +4
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);
Quoted 4 lines
arch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 246
Quoted 1 line
arch/arm64/mm/numa.c +0
-0/* report and initialize */ Does it mean that
memblock_phys_alloc_try_nid()never returns valid physical memory starting at 0?
Yes, it does.memblock_find_in_range_node() that is used by all allocation methods skips the first page [1].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/memblock.c#n257
Quoted 3 lines
Signature · 1 line
Catalin
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Catalin Marinas
maintainerRe: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Mike RapoportQuoted 5 lines · Mike Rapoport
arch/arm64/mm/numa.c +0
-0
arch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 246
Quoted 10 lines
arch/arm64/mm/numa.c +4
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);/* report and initialize */
Does it mean that memblock_phys_alloc_try_nid() never returns valid physical memory starting at 0?
Signature · 6 lines
Catalin _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Mike Rapoportarch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 244
Quoted 13 lines · Mike Rapoport
arch/arm64/mm/numa.c +4
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);
cheers
Michael Ellerman
reviewerRe: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
Quoted 9 lines · Michael Ellerman
Quoted 7 lines · Mike Rapoport
arch/arm64/mm/numa.c +0
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid);
Quoted 6 lines
arch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 244
Quoted 6 lines
arch/arm64/mm/numa.c +4
-0nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);
Wrong hunk, O_o
Quoted 1 line
You know what I mean though :)
cheers
Michael Ellerman
reviewerRe: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Michael EllermanQuoted 9 lines · Michael Ellerman
Quoted 7 lines · Mike Rapoport
arch/arm64/mm/numa.c +0
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid);
Quoted 6 lines
arch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 244
Quoted 6 lines
arch/arm64/mm/numa.c +4
-0nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);
Wrong hunk, O_o
Quoted 1 line
You know what I mean though :)
cheers
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Mike Rapoportarch/arm64/mm/numa.c static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) · line 244
Quoted 13 lines · Mike Rapoport
arch/arm64/mm/numa.c +4
-0@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);
cheers
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 6/21 memblock: memblock_phys_alloc_try_nid(): don't panic
In reply to Mike RapoportThe memblock_phys_alloc_try_nid() function tries to allocate memory from the requested node and then falls back to allocation from any node in the system. The memblock_alloc_base() fallback used by this function panics if the allocation fails.
Replace the memblock_alloc_base() fallback with the direct call to memblock_alloc_range_nid() and update the memblock_phys_alloc_try_nid() callers to check the returned value and panic in case of error.
--- arch/arm64/mm/numa.c | 4 ++++ arch/powerpc/mm/numa.c | 4 ++++ mm/memblock.c | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-)
arch/arm64/mm/numa.c +4 -0
@@ -237,6 +237,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)pr_info ("Initmem setup node %d [<memory-less node>]\n" , nid); nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);/* report and initialize */
arch/powerpc/mm/numa.c +4 -0
@@ -788,6 +788,10 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)int tnid; nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid); +if (!nd_pa) +panic ("Cannot allocate %zu bytes for node %d data\n" , + nd_size, nid); + nd =__va (nd_pa);/* report and initialize */
mm/memblock.c +3 -1
@@ -1393,7 +1393,9 @@ phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t aliif (res)return res; -return memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ACCESSIBLE ); +return memblock_alloc_range_nid (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE , +NUMA_NO_NODE ,MEMBLOCK_NONE ); }/**
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 7/21 memblock: memblock_phys_alloc(): don't panic
In reply to Mike RapoportMake the memblock_phys_alloc() function an inline wrapper for memblock_phys_alloc_range() and update the memblock_phys_alloc() callers to check the returned value and panic in case of error.
--- arch/arm/mm/init.c | 4 ++++ arch/arm64/mm/mmu.c | 2 ++ arch/powerpc/sysdev/dart_iommu.c | 3 +++ arch/s390/kernel/crash_dump.c | 3 +++ arch/s390/kernel/setup.c | 3 +++ arch/sh/boards/mach-ap325rxa/setup.c | 3 +++ arch/sh/boards/mach-ecovec24/setup.c | 6 ++++++ arch/sh/boards/mach-kfr2r09/setup.c | 3 +++ arch/sh/boards/mach-migor/setup.c | 3 +++ arch/sh/boards/mach-se/7724/setup.c | 6 ++++++ arch/xtensa/mm/kasan_init.c | 3 +++ include/linux/memblock.h | 7 ++++++- mm/memblock.c | 5 ----- 13 files changed, 45 insertions(+), 6 deletions(-)
arch/arm/mm/init.c +4 -0
@@ -206,6 +206,10 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)BUG_ON (!arm_memblock_steal_permitted); phys =memblock_phys_alloc (size, align); +if (!phys) +panic ("Failed to steal %pa bytes at %pS\n" , + &size, (void *)_RET_IP_); +memblock_free (phys, size);memblock_remove (phys, size);
arch/arm64/mm/mmu.c +2 -0
@@ -104,6 +104,8 @@ static phys_addr_t __init early_pgtable_alloc(void)void *ptr; phys =memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate page table page\n" );/* * The FIX_{PGD,PUD,PMD} slots may be in active use, but the FIX_PTE
arch/powerpc/sysdev/dart_iommu.c +3 -0
@@ -265,6 +265,9 @@ static void allocate_dart(void)* prefetching into invalid pages and corrupting data */ tmp =memblock_phys_alloc (DART_PAGE_SIZE ,DART_PAGE_SIZE ); +if (!tmp) +panic ("DART: table allocation failed\n" ); + dart_emptyval =DARTMAP_VALID | ((tmp >>DART_PAGE_SHIFT ) &DARTMAP_RPNMASK );
arch/s390/kernel/crash_dump.c +3 -0
@@ -61,6 +61,9 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu)struct save_area *sa; sa = (void *)memblock_phys_alloc (sizeof (*sa),8 ); +if (!sa) +panic ("Failed to allocate save area\n" ); +if (is_boot_cpu)list_add (&sa->list, &dump_save_areas);else
arch/s390/kernel/setup.c +3 -0
@@ -968,6 +968,9 @@ static void __init setup_randomness(void) vmms = (struct sysinfo_3_2_2 *)memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!vmms) +panic ("Failed to allocate memory for sysinfo structure\n" ); +if (stsi (vmms,3 ,2 ,2 ) ==0 && vmms->count)add_device_randomness (&vmms->vm,sizeof (vmms->vm[0 ]) * vmms->count);memblock_free ((unsigned long ) vmms,PAGE_SIZE );
arch/sh/boards/mach-ap325rxa/setup.c +3 -0
@@ -558,6 +558,9 @@ static void __init ap325rxa_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-ecovec24/setup.c +6 -0
@@ -1481,11 +1481,17 @@ static void __init ecovec_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU0 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU1 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/sh/boards/mach-kfr2r09/setup.c +3 -0
@@ -632,6 +632,9 @@ static void __init kfr2r09_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-migor/setup.c +3 -0
@@ -631,6 +631,9 @@ static void __init migor_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-se/7724/setup.c +6 -0
@@ -966,11 +966,17 @@ static void __init ms7724se_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU0 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU1 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/xtensa/mm/kasan_init.c +3 -0
@@ -54,6 +54,9 @@ static void __init populate(void *start, void *end)phys_addr_t phys =memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate page table page\n" ); +set_pte (pte + j,pfn_pte (PHYS_PFN (phys),PAGE_KERNEL )); } }
include/linux/memblock.h +6 -1
@@ -374,7 +374,12 @@ phys_addr_t memblock_phys_alloc_range(phys_addr_t size, phys_addr_t align,phys_addr_t memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); -phys_addr_t memblock_phys_alloc (phys_addr_t size,phys_addr_t align); +static inline phys_addr_t memblock_phys_alloc (phys_addr_t size, +phys_addr_t align) +{ +return memblock_phys_alloc_range (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE ); +} void *memblock_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr,
mm/memblock.c +0 -5
@@ -1382,11 +1382,6 @@ phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, physreturn alloc; } -phys_addr_t __init memblock_phys_alloc (phys_addr_t size,phys_addr_t align) -{ -return memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ACCESSIBLE ); -} -phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) {phys_addr_t res =memblock_phys_alloc_nid (size, align, nid);
Signature · 1 line
2.7.4
PATCH v2 7/21 memblock: memblock_phys_alloc(): don't panic
In reply to Mike RapoportMake the memblock_phys_alloc() function an inline wrapper for memblock_phys_alloc_range() and update the memblock_phys_alloc() callers to check the returned value and panic in case of error.
--- arch/arm/mm/init.c | 4 ++++ arch/arm64/mm/mmu.c | 2 ++ arch/powerpc/sysdev/dart_iommu.c | 3 +++ arch/s390/kernel/crash_dump.c | 3 +++ arch/s390/kernel/setup.c | 3 +++ arch/sh/boards/mach-ap325rxa/setup.c | 3 +++ arch/sh/boards/mach-ecovec24/setup.c | 6 ++++++ arch/sh/boards/mach-kfr2r09/setup.c | 3 +++ arch/sh/boards/mach-migor/setup.c | 3 +++ arch/sh/boards/mach-se/7724/setup.c | 6 ++++++ arch/xtensa/mm/kasan_init.c | 3 +++ include/linux/memblock.h | 7 ++++++- mm/memblock.c | 5 ----- 13 files changed, 45 insertions(+), 6 deletions(-)
arch/arm/mm/init.c +4 -0
@@ -206,6 +206,10 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)BUG_ON (!arm_memblock_steal_permitted); phys =memblock_phys_alloc (size, align); +if (!phys) +panic ("Failed to steal %pa bytes at %pS\n" , + &size, (void *)_RET_IP_); +memblock_free (phys, size);memblock_remove (phys, size);
arch/arm64/mm/mmu.c +2 -0
@@ -104,6 +104,8 @@ static phys_addr_t __init early_pgtable_alloc(void)void *ptr; phys =memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate page table page\n" );/* * The FIX_{PGD,PUD,PMD} slots may be in active use, but the FIX_PTE
arch/powerpc/sysdev/dart_iommu.c +3 -0
@@ -265,6 +265,9 @@ static void allocate_dart(void)* prefetching into invalid pages and corrupting data */ tmp =memblock_phys_alloc (DART_PAGE_SIZE ,DART_PAGE_SIZE ); +if (!tmp) +panic ("DART: table allocation failed\n" ); + dart_emptyval =DARTMAP_VALID | ((tmp >>DART_PAGE_SHIFT ) &DARTMAP_RPNMASK );
arch/s390/kernel/crash_dump.c +3 -0
@@ -61,6 +61,9 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu)struct save_area *sa; sa = (void *)memblock_phys_alloc (sizeof (*sa),8 ); +if (!sa) +panic ("Failed to allocate save area\n" ); +if (is_boot_cpu)list_add (&sa->list, &dump_save_areas);else
arch/s390/kernel/setup.c +3 -0
@@ -968,6 +968,9 @@ static void __init setup_randomness(void) vmms = (struct sysinfo_3_2_2 *)memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!vmms) +panic ("Failed to allocate memory for sysinfo structure\n" ); +if (stsi (vmms,3 ,2 ,2 ) ==0 && vmms->count)add_device_randomness (&vmms->vm,sizeof (vmms->vm[0 ]) * vmms->count);memblock_free ((unsigned long ) vmms,PAGE_SIZE );
arch/sh/boards/mach-ap325rxa/setup.c +3 -0
@@ -558,6 +558,9 @@ static void __init ap325rxa_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-ecovec24/setup.c +6 -0
@@ -1481,11 +1481,17 @@ static void __init ecovec_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU0 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU1 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/sh/boards/mach-kfr2r09/setup.c +3 -0
@@ -632,6 +632,9 @@ static void __init kfr2r09_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-migor/setup.c +3 -0
@@ -631,6 +631,9 @@ static void __init migor_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size);
arch/sh/boards/mach-se/7724/setup.c +6 -0
@@ -966,11 +966,17 @@ static void __init ms7724se_mv_mem_reserve(void)phys_addr_t size =CEU_BUFFER_MEMORY_SIZE ; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU0 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu0_dma_membase = phys; phys =memblock_phys_alloc (size,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate CEU1 memory\n" ); +memblock_free (phys, size);memblock_remove (phys, size); ceu1_dma_membase = phys;
arch/xtensa/mm/kasan_init.c +3 -0
@@ -54,6 +54,9 @@ static void __init populate(void *start, void *end)phys_addr_t phys =memblock_phys_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!phys) +panic ("Failed to allocate page table page\n" ); +set_pte (pte + j,pfn_pte (PHYS_PFN (phys),PAGE_KERNEL )); } }
include/linux/memblock.h +6 -1
@@ -374,7 +374,12 @@ phys_addr_t memblock_phys_alloc_range(phys_addr_t size, phys_addr_t align,phys_addr_t memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); -phys_addr_t memblock_phys_alloc (phys_addr_t size,phys_addr_t align); +static inline phys_addr_t memblock_phys_alloc (phys_addr_t size, +phys_addr_t align) +{ +return memblock_phys_alloc_range (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE ); +} void *memblock_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr,
mm/memblock.c +0 -5
@@ -1382,11 +1382,6 @@ phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, physreturn alloc; } -phys_addr_t __init memblock_phys_alloc (phys_addr_t size,phys_addr_t align) -{ -return memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ACCESSIBLE ); -} -phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) {phys_addr_t res =memblock_phys_alloc_nid (size, align, nid);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 8/21 memblock: drop __memblock_alloc_base()
In reply to Mike RapoportThe __memblock_alloc_base() function tries to allocate a memory up to the limit specified by its max_addr parameter. Depending on the value of this parameter, the __memblock_alloc_base() can is replaced with the appropriate memblock_phys_alloc*() variant.
--- arch/sh/kernel/machine_kexec.c | 3 ++- arch/x86/kernel/e820.c | 2 +- arch/x86/mm/numa.c | 12 ++++-------- drivers/of/of_reserved_mem.c | 7 ++----- include/linux/memblock.h | 2 -- mm/memblock.c | 9 ++------- 6 files changed, 11 insertions(+), 24 deletions(-)
arch/sh/kernel/machine_kexec.c +2 -1
@@ -168,7 +168,8 @@ void __init reserve_crashkernel(void) crash_size =PAGE_ALIGN (resource_size (&crashk_res));if (!crashk_res.start) {unsigned long max =memblock_end_of_DRAM () - memory_limit; - crashk_res.start =__memblock_alloc_base (crash_size,PAGE_SIZE , max); + crashk_res.start =memblock_phys_alloc_range (crash_size, +PAGE_SIZE ,0 , max);if (!crashk_res.start) {pr_err ("crashkernel allocation failed\n" ); goto disable;
arch/x86/kernel/e820.c +1 -1
@@ -778,7 +778,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align) {u64 addr; - addr =__memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ACCESSIBLE ); + addr =memblock_phys_alloc (size, align);if (addr) {e820__range_update_kexec (addr, size,E820_TYPE_RAM ,E820_TYPE_RESERVED );pr_info ("update e820_table_kexec for e820__memblock_alloc_reserved()\n" );
arch/x86/mm/numa.c +4 -8
@@ -195,15 +195,11 @@ static void __init alloc_node_data(int nid)* Allocate node data. Try node-local memory and then any node. * Never allocate in DMA zone. */ - nd_pa =memblock_phys_alloc_nid (nd_size,SMP_CACHE_BYTES , nid); + nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid);if (!nd_pa) { - nd_pa =__memblock_alloc_base (nd_size,SMP_CACHE_BYTES , -MEMBLOCK_ALLOC_ACCESSIBLE ); -if (!nd_pa) { -pr_err ("Cannot find %zu bytes in any node (initial node: %d)\n" , - nd_size, nid); -return ; - } +pr_err ("Cannot find %zu bytes in any node (initial node: %d)\n" , + nd_size, nid); +return ; } nd =__va (nd_pa);
drivers/of/of_reserved_mem.c +2 -5
@@ -31,13 +31,10 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, phys_addr_t *res_base) {phys_addr_t base; -/* -* We use __memblock_alloc_base() because memblock_alloc_base() -* panic()s on allocation failure. -*/ + end = !end ?MEMBLOCK_ALLOC_ANYWHERE : end; align = !align ?SMP_CACHE_BYTES : align; - base =__memblock_alloc_base (size, align, end); + base =memblock_phys_alloc_range (size, align,0 , end);if (!base)return -ENOMEM ;
include/linux/memblock.h +0 -2
@@ -496,8 +496,6 @@ static inline bool memblock_bottom_up(void)phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr); -phys_addr_t __memblock_alloc_base (phys_addr_t size,phys_addr_t align, -phys_addr_t max_addr);phys_addr_t memblock_phys_mem_size (void );phys_addr_t memblock_reserved_size (void );phys_addr_t memblock_mem_size (unsigned long limit_pfn);
mm/memblock.c +2 -7
@@ -1363,17 +1363,12 @@ phys_addr_t __init memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align,return ret; } -phys_addr_t __init __memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) -{ -return memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , -MEMBLOCK_NONE ); -} -phys_addr_t __init memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) {phys_addr_t alloc; - alloc =__memblock_alloc_base (size, align, max_addr); + alloc =memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , +MEMBLOCK_NONE );if (alloc ==0 ) panic("ERROR: Failed to allocate %pa bytes below %pa.\n",
Signature · 1 line
2.7.4
PATCH v2 8/21 memblock: drop __memblock_alloc_base()
In reply to Mike RapoportThe __memblock_alloc_base() function tries to allocate a memory up to the limit specified by its max_addr parameter. Depending on the value of this parameter, the __memblock_alloc_base() can is replaced with the appropriate memblock_phys_alloc*() variant.
--- arch/sh/kernel/machine_kexec.c | 3 ++- arch/x86/kernel/e820.c | 2 +- arch/x86/mm/numa.c | 12 ++++-------- drivers/of/of_reserved_mem.c | 7 ++----- include/linux/memblock.h | 2 -- mm/memblock.c | 9 ++------- 6 files changed, 11 insertions(+), 24 deletions(-)
arch/sh/kernel/machine_kexec.c +2 -1
@@ -168,7 +168,8 @@ void __init reserve_crashkernel(void) crash_size =PAGE_ALIGN (resource_size (&crashk_res));if (!crashk_res.start) {unsigned long max =memblock_end_of_DRAM () - memory_limit; - crashk_res.start =__memblock_alloc_base (crash_size,PAGE_SIZE , max); + crashk_res.start =memblock_phys_alloc_range (crash_size, +PAGE_SIZE ,0 , max);if (!crashk_res.start) {pr_err ("crashkernel allocation failed\n" ); goto disable;
arch/x86/kernel/e820.c +1 -1
@@ -778,7 +778,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align) {u64 addr; - addr =__memblock_alloc_base (size, align,MEMBLOCK_ALLOC_ACCESSIBLE ); + addr =memblock_phys_alloc (size, align);if (addr) {e820__range_update_kexec (addr, size,E820_TYPE_RAM ,E820_TYPE_RESERVED );pr_info ("update e820_table_kexec for e820__memblock_alloc_reserved()\n" );
arch/x86/mm/numa.c +4 -8
@@ -195,15 +195,11 @@ static void __init alloc_node_data(int nid)* Allocate node data. Try node-local memory and then any node. * Never allocate in DMA zone. */ - nd_pa =memblock_phys_alloc_nid (nd_size,SMP_CACHE_BYTES , nid); + nd_pa =memblock_phys_alloc_try_nid (nd_size,SMP_CACHE_BYTES , nid);if (!nd_pa) { - nd_pa =__memblock_alloc_base (nd_size,SMP_CACHE_BYTES , -MEMBLOCK_ALLOC_ACCESSIBLE ); -if (!nd_pa) { -pr_err ("Cannot find %zu bytes in any node (initial node: %d)\n" , - nd_size, nid); -return ; - } +pr_err ("Cannot find %zu bytes in any node (initial node: %d)\n" , + nd_size, nid); +return ; } nd =__va (nd_pa);
drivers/of/of_reserved_mem.c +2 -5
@@ -31,13 +31,10 @@ int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, phys_addr_t *res_base) {phys_addr_t base; -/* -* We use __memblock_alloc_base() because memblock_alloc_base() -* panic()s on allocation failure. -*/ + end = !end ?MEMBLOCK_ALLOC_ANYWHERE : end; align = !align ?SMP_CACHE_BYTES : align; - base =__memblock_alloc_base (size, align, end); + base =memblock_phys_alloc_range (size, align,0 , end);if (!base)return -ENOMEM ;
include/linux/memblock.h +0 -2
@@ -496,8 +496,6 @@ static inline bool memblock_bottom_up(void)phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr); -phys_addr_t __memblock_alloc_base (phys_addr_t size,phys_addr_t align, -phys_addr_t max_addr);phys_addr_t memblock_phys_mem_size (void );phys_addr_t memblock_reserved_size (void );phys_addr_t memblock_mem_size (unsigned long limit_pfn);
mm/memblock.c +2 -7
@@ -1363,17 +1363,12 @@ phys_addr_t __init memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align,return ret; } -phys_addr_t __init __memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) -{ -return memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , -MEMBLOCK_NONE ); -} -phys_addr_t __init memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) {phys_addr_t alloc; - alloc =__memblock_alloc_base (size, align, max_addr); + alloc =memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , +MEMBLOCK_NONE );if (alloc ==0 ) panic("ERROR: Failed to allocate %pa bytes below %pa.\n",
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 9/21 memblock: drop memblock_alloc_base()
In reply to Mike RapoportThe memblock_alloc_base() function tries to allocate a memory up to the limit specified by its max_addr parameter and panics if the allocation fails. Replace its usage with memblock_phys_alloc_range() and make the callers check the return value and panic in case of error.
--- arch/powerpc/kernel/rtas.c | 6 +++++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++-- arch/s390/kernel/smp.c | 6 +++++- drivers/macintosh/smu.c | 2 +- include/linux/memblock.h | 2 -- mm/memblock.c | 14 -------------- 6 files changed, 17 insertions(+), 21 deletions(-)
arch/powerpc/kernel/rtas.c +5 -1
@@ -1187,7 +1187,11 @@ void __init rtas_initialize(void) ibm_suspend_me_token = rtas_token("ibm,suspend-me"); }#endif - rtas_rmo_buf =memblock_alloc_base (RTAS_RMOBUF_MAX ,PAGE_SIZE , rtas_region); + rtas_rmo_buf =memblock_phys_alloc_range (RTAS_RMOBUF_MAX ,PAGE_SIZE , +0 , rtas_region); +if (!rtas_rmo_buf) +panic ("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n" , +PAGE_SIZE , &rtas_region);#ifdef CONFIG_RTAS_ERROR_LOGGING rtas_last_error_token =rtas_token ("rtas-last-error" );
arch/powerpc/mm/hash_utils_64.c +6 -2
@@ -882,8 +882,12 @@ static void __init htab_initialize(void) }#endif /* CONFIG_PPC_CELL */ - table =memblock_alloc_base (htab_size_bytes, htab_size_bytes, - limit); + table =memblock_phys_alloc_range (htab_size_bytes, + htab_size_bytes, +0 , limit); +if (!table) +panic ("ERROR: Failed to allocate %pa bytes below %pa\n" , + &htab_size_bytes, &limit);DBG ("Hash table allocated at %lx, size: %lx\n" , table, htab_size_bytes);
arch/s390/kernel/smp.c +5 -1
@@ -651,7 +651,11 @@ void __init smp_save_dump_cpus(void)/* No previous system present, normal boot. */ return ;/* Allocate a page as dumping area for the store status sigps */ - page =memblock_alloc_base (PAGE_SIZE ,PAGE_SIZE ,1UL <<31 ); + page =memblock_phys_alloc_range (PAGE_SIZE ,PAGE_SIZE ,0 ,1UL <<31 ); +if (!page) +panic ("ERROR: Failed to allocate %x bytes below %lx\n" , +PAGE_SIZE ,1UL <<31 ); +/* Set multi-threading state to the previous system. */ pcpu_set_smt (sclp.mtid_prev); boot_cpu_addr =stap ();
drivers/macintosh/smu.c +1 -1
@@ -485,7 +485,7 @@ int __init smu_init (void)* SMU based G5s need some memory below 2Gb. Thankfully this is * called at a time where memblock is still available. */ - smu_cmdbuf_abs =memblock_alloc_base (4096 ,4096 ,0x80000000UL ); + smu_cmdbuf_abs =memblock_phys_alloc_range (4096 ,4096 ,0 ,0x80000000UL );if (smu_cmdbuf_abs ==0 ) {printk (KERN_ERR "SMU: Command buffer allocation failed !\n" ); ret = -EINVAL ;
include/linux/memblock.h +0 -2
@@ -494,8 +494,6 @@ static inline bool memblock_bottom_up(void)return memblock.bottom_up; } -phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align, -phys_addr_t max_addr);phys_addr_t memblock_phys_mem_size (void );phys_addr_t memblock_reserved_size (void );phys_addr_t memblock_mem_size (unsigned long limit_pfn);
mm/memblock.c +0 -14
@@ -1363,20 +1363,6 @@ phys_addr_t __init memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align,return ret; } -phys_addr_t __init memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) -{ -phys_addr_t alloc; - - alloc =memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , -MEMBLOCK_NONE ); - -if (alloc ==0 ) -panic ("ERROR: Failed to allocate %pa bytes below %pa.\n" , - &size, &max_addr); - -return alloc; -} -phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) {phys_addr_t res =memblock_phys_alloc_nid (size, align, nid);
Signature · 1 line
2.7.4
Re: [PATCH v2 09/21] memblock: drop memblock_alloc_base()
Quoted 6 lines · Mike Rapoport
The
memblock_alloc_base()function tries to allocate a memory up to the limit specified by itsmax_addrparameter and panics if the allocation fails. Replace its usage withmemblock_phys_alloc_range()and make the callers check the return value and panic in case of error.Signed-off-by Mike Rapoport <[email protected]>
Quoted 8 lines
--- arch/powerpc/kernel/rtas.c | 6 +++++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++-- arch/s390/kernel/smp.c | 6 +++++- drivers/macintosh/smu.c | 2 +- include/linux/memblock.h | 2 -- mm/memblock.c | 14 -------------- 6 files changed, 17 insertions(+), 21 deletions(-)
cheers
Re: [PATCH v2 09/21] memblock: drop memblock_alloc_base()
In reply to Mike RapoportQuoted 6 lines · Mike Rapoport
The
memblock_alloc_base()function tries to allocate a memory up to the limit specified by itsmax_addrparameter and panics if the allocation fails. Replace its usage withmemblock_phys_alloc_range()and make the callers check the return value and panic in case of error.Signed-off-by Mike Rapoport <[email protected]>
Quoted 8 lines
--- arch/powerpc/kernel/rtas.c | 6 +++++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++-- arch/s390/kernel/smp.c | 6 +++++- drivers/macintosh/smu.c | 2 +- include/linux/memblock.h | 2 -- mm/memblock.c | 14 -------------- 6 files changed, 17 insertions(+), 21 deletions(-)
cheers
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 9/21 memblock: drop memblock_alloc_base()
In reply to Mike RapoportThe memblock_alloc_base() function tries to allocate a memory up to the limit specified by its max_addr parameter and panics if the allocation fails. Replace its usage with memblock_phys_alloc_range() and make the callers check the return value and panic in case of error.
--- arch/powerpc/kernel/rtas.c | 6 +++++- arch/powerpc/mm/hash_utils_64.c | 8 ++++++-- arch/s390/kernel/smp.c | 6 +++++- drivers/macintosh/smu.c | 2 +- include/linux/memblock.h | 2 -- mm/memblock.c | 14 -------------- 6 files changed, 17 insertions(+), 21 deletions(-)
arch/powerpc/kernel/rtas.c +5 -1
@@ -1187,7 +1187,11 @@ void __init rtas_initialize(void) ibm_suspend_me_token = rtas_token("ibm,suspend-me"); }#endif - rtas_rmo_buf =memblock_alloc_base (RTAS_RMOBUF_MAX ,PAGE_SIZE , rtas_region); + rtas_rmo_buf =memblock_phys_alloc_range (RTAS_RMOBUF_MAX ,PAGE_SIZE , +0 , rtas_region); +if (!rtas_rmo_buf) +panic ("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n" , +PAGE_SIZE , &rtas_region);#ifdef CONFIG_RTAS_ERROR_LOGGING rtas_last_error_token =rtas_token ("rtas-last-error" );
arch/powerpc/mm/hash_utils_64.c +6 -2
@@ -882,8 +882,12 @@ static void __init htab_initialize(void) }#endif /* CONFIG_PPC_CELL */ - table =memblock_alloc_base (htab_size_bytes, htab_size_bytes, - limit); + table =memblock_phys_alloc_range (htab_size_bytes, + htab_size_bytes, +0 , limit); +if (!table) +panic ("ERROR: Failed to allocate %pa bytes below %pa\n" , + &htab_size_bytes, &limit);DBG ("Hash table allocated at %lx, size: %lx\n" , table, htab_size_bytes);
arch/s390/kernel/smp.c +5 -1
@@ -651,7 +651,11 @@ void __init smp_save_dump_cpus(void)/* No previous system present, normal boot. */ return ;/* Allocate a page as dumping area for the store status sigps */ - page =memblock_alloc_base (PAGE_SIZE ,PAGE_SIZE ,1UL <<31 ); + page =memblock_phys_alloc_range (PAGE_SIZE ,PAGE_SIZE ,0 ,1UL <<31 ); +if (!page) +panic ("ERROR: Failed to allocate %x bytes below %lx\n" , +PAGE_SIZE ,1UL <<31 ); +/* Set multi-threading state to the previous system. */ pcpu_set_smt (sclp.mtid_prev); boot_cpu_addr =stap ();
drivers/macintosh/smu.c +1 -1
@@ -485,7 +485,7 @@ int __init smu_init (void)* SMU based G5s need some memory below 2Gb. Thankfully this is * called at a time where memblock is still available. */ - smu_cmdbuf_abs =memblock_alloc_base (4096 ,4096 ,0x80000000UL ); + smu_cmdbuf_abs =memblock_phys_alloc_range (4096 ,4096 ,0 ,0x80000000UL );if (smu_cmdbuf_abs ==0 ) {printk (KERN_ERR "SMU: Command buffer allocation failed !\n" ); ret = -EINVAL ;
include/linux/memblock.h +0 -2
@@ -494,8 +494,6 @@ static inline bool memblock_bottom_up(void)return memblock.bottom_up; } -phys_addr_t memblock_alloc_base (phys_addr_t size,phys_addr_t align, -phys_addr_t max_addr);phys_addr_t memblock_phys_mem_size (void );phys_addr_t memblock_reserved_size (void );phys_addr_t memblock_mem_size (unsigned long limit_pfn);
mm/memblock.c +0 -14
@@ -1363,20 +1363,6 @@ phys_addr_t __init memblock_phys_alloc_nid(phys_addr_t size, phys_addr_t align,return ret; } -phys_addr_t __init memblock_alloc_base (phys_addr_t size,phys_addr_t align,phys_addr_t max_addr) -{ -phys_addr_t alloc; - - alloc =memblock_alloc_range_nid (size, align,0 , max_addr,NUMA_NO_NODE , -MEMBLOCK_NONE ); - -if (alloc ==0 ) -panic ("ERROR: Failed to allocate %pa bytes below %pa.\n" , - &size, &max_addr); - -return alloc; -} -phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) {phys_addr_t res =memblock_phys_alloc_nid (size, align, nid);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 10/21 memblock: refactor internal allocation functions
In reply to Mike RapoportCurrently, memblock has several internal functions with overlapping functionality. They all call memblock_find_in_range_node() to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.
The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to memblock_alloc_range_nid() and it now handles node and mirror fallbacks.
The memblock_alloc_internal() uses memblock_alloc_range_nid() to get a physical address of the allocated range and converts it to virtual address.
The fallback for allocation below the specified minimal address remains in memblock_alloc_internal() because memblock_alloc_range_nid() is used by CMA with exact requirement for lower bounds.
The memblock_phys_alloc_nid() function is completely dropped as it is not used anywhere outside memblock and its only usage can be replaced by a call to memblock_alloc_range_nid().
--- include/linux/memblock.h | 1 - mm/memblock.c | 173 +++++++++++++++++++++-------------------------- 2 files changed, 78 insertions(+), 96 deletions(-)
include/linux/memblock.h +0 -1
@@ -371,7 +371,6 @@ static inline int memblock_get_region_node(const struct memblock_region *r)phys_addr_t memblock_phys_alloc_range (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end); -phys_addr_t memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,
mm/memblock.c +78 -95
227 lines not on this page · raw message
Signature · 1 line
2.7.4
Michael Ellerman
reviewerRe: [PATCH v2 10/21] memblock: refactor internal allocation functions
Quoted 22 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to
memblock_alloc_range_nid()and it now handles node and mirror fallbacks.
Quoted 6 lines
The
memblock_alloc_internal()usesmemblock_alloc_range_nid()to get a physical address of the allocated range and converts it to virtual address.The fallback for allocation below the specified minimal address remains in
memblock_alloc_internal()becausememblock_alloc_range_nid()is used by CMA with exact requirement for lower bounds.
This is causing problems on some of my machines.
I see NODE_DATA allocations falling back to node 0 when they shouldn't, or didn't previously.
eg, before:
57990190: (116011251): numa: NODE_DATA [mem 0xfffe4980-0xfffebfff]
58152042: (116373087): numa: NODE_DATA [mem 0x8fff90980-0x8fff97fff]
after:
16356872061562: (6296877055): numa: NODE_DATA [mem 0xfffe4980-0xfffebfff]
16356872079279: (6296894772): numa: NODE_DATA [mem 0xfffcd300-0xfffd497f]
16356872096376: (6296911869): numa: NODE_DATA(1) on node 0
On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
cheers
Re: [PATCH v2 10/21] memblock: refactor internal allocation functions
Quoted 66 lines · Michael Ellerman
Quoted 22 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to
memblock_alloc_range_nid()and it now handles node and mirror fallbacks.Quoted 6 lines
The
memblock_alloc_internal()usesmemblock_alloc_range_nid()to get a physical address of the allocated range and converts it to virtual address.The fallback for allocation below the specified minimal address remains in
memblock_alloc_internal()becausememblock_alloc_range_nid()is used by CMA with exact requirement for lower bounds.This is causing problems on some of my machines.
I see
NODE_DATAallocations falling back to node 0 when they shouldn't, or didn't previously.eg, before:
57990190: (116011251): numa:
NODE_DATA[mem 0xfffe4980-0xfffebfff]
58152042: (116373087): numa:NODE_DATA[mem 0x8fff90980-0x8fff97fff]after:
16356872061562: (6296877055): numa:
NODE_DATA[mem 0xfffe4980-0xfffebfff]
16356872079279: (6296894772): numa:NODE_DATA[mem 0xfffcd300-0xfffd497f]
16356872096376: (6296911869): numa:NODE_DATA(1)on node 0On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..
Quoted 2 lines
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
I'll try to see if I can reproduce it with qemu.
Quoted 2 lines
cheers
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 10/21] memblock: refactor internal allocation functions
In reply to Michael EllermanQuoted 66 lines · Michael Ellerman
Quoted 22 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to
memblock_alloc_range_nid()and it now handles node and mirror fallbacks.Quoted 6 lines
The
memblock_alloc_internal()usesmemblock_alloc_range_nid()to get a physical address of the allocated range and converts it to virtual address.The fallback for allocation below the specified minimal address remains in
memblock_alloc_internal()becausememblock_alloc_range_nid()is used by CMA with exact requirement for lower bounds.This is causing problems on some of my machines.
I see
NODE_DATAallocations falling back to node 0 when they shouldn't, or didn't previously.eg, before:
57990190: (116011251): numa:
NODE_DATA[mem 0xfffe4980-0xfffebfff]
58152042: (116373087): numa:NODE_DATA[mem 0x8fff90980-0x8fff97fff]after:
16356872061562: (6296877055): numa:
NODE_DATA[mem 0xfffe4980-0xfffebfff]
16356872079279: (6296894772): numa:NODE_DATA[mem 0xfffcd300-0xfffd497f]
16356872096376: (6296911869): numa:NODE_DATA(1)on node 0On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..
Quoted 2 lines
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
I'll try to see if I can reproduce it with qemu.
Quoted 2 lines
cheers
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 10/21] memblock: refactor internal allocation functions
In reply to Michael Ellerman(dropped most of 'CC)
Quoted 66 lines · Michael Ellerman
Quoted 22 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to
memblock_alloc_range_nid()and it now handles node and mirror fallbacks.Quoted 6 lines
The
memblock_alloc_internal()usesmemblock_alloc_range_nid()to get a physical address of the allocated range and converts it to virtual address.The fallback for allocation below the specified minimal address remains in
memblock_alloc_internal()becausememblock_alloc_range_nid()is used by CMA with exact requirement for lower bounds.This is causing problems on some of my machines.
I see
NODE_DATAallocations falling back to node 0 when they shouldn't, or didn't previously.eg, before:
57990190: (116011251): numa:
NODE_DATA[mem 0xfffe4980-0xfffebfff]
58152042: (116373087): numa:NODE_DATA[mem 0x8fff90980-0x8fff97fff]after:
16356872061562: (6296877055): numa:
NODE_DATA[mem 0xfffe4980-0xfffebfff]
16356872079279: (6296894772): numa:NODE_DATA[mem 0xfffcd300-0xfffd497f]
16356872096376: (6296911869): numa:NODE_DATA(1)on node 0On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..
Quoted 2 lines
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
Yeah, I've misplaced 'nid' and 'MEMBLOCK_ALLOC_ACCESSIBLE' in memblock_phys_alloc_try_nid() :(
Can you please check if the below patch fixes the issue on your systems?
Quoted 2 lines
cheers
From 5875b7440e985ce551e6da3cb28aa8e9af697e10 Mon Sep 17 00:00:00 2001
From: Mike Rapoport <[email protected]>
Date: Sun, 3 Feb 2019 13:35:42 +0200
Subject: [PATCH] memblock: fix parameter order in
memblock_phys_alloc_try_nid()
The refactoring of internal memblock allocation functions used wrong order of parameters in memblock_alloc_range_nid() call from memblock_phys_alloc_try_nid().
Fix it.
--- mm/memblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memblock.c +2 -2
@@ -1402,8 +1402,8 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) { -return memblock_alloc_range_nid (size, align,0 , nid, -MEMBLOCK_ALLOC_ACCESSIBLE ); +return memblock_alloc_range_nid (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE , nid); }/**
Signature · 6 lines
2.7.4 -- Sincerely yours, Mike.
Re: [PATCH v2 10/21] memblock: refactor internal allocation functions
Quoted 7 lines · Mike Rapoport
Quoted 6 lines · Michael Ellerman
Quoted 5 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.
...
Quoted 2 lines
Quoted 2 lines
This is causing problems on some of my machines.
...
Quoted 19 lines
Quoted 19 lines
On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..
Quoted 7 lines
Quoted 2 lines
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
Yeah, I've misplaced 'nid' and '
MEMBLOCK_ALLOC_ACCESSIBLE' inmemblock_phys_alloc_try_nid():(Can you please check if the below patch fixes the issue on your systems?
Yes it does, thanks.
cheers
Quoted 38 lines
From
5875b7440e985ce551e6da3cb28aa8e9af697e10Mon Sep 17 00:00:00 2001
From: Mike Rapoport <[email protected]>
Date: Sun, 3 Feb 2019 13:35:42 +0200
Subject: [PATCH] memblock: fix parameter order in
memblock_phys_alloc_try_nid()The refactoring of internal memblock allocation functions used wrong order of parameters in
memblock_alloc_range_nid()call frommemblock_phys_alloc_try_nid().
Fix it.Signed-off-by Mike Rapoport <[email protected]>--- mm/memblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/memblock.c +2
-2@@ -1402,8 +1402,8 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) { -return memblock_alloc_range_nid (size, align,0 , nid, -MEMBLOCK_ALLOC_ACCESSIBLE ); +return memblock_alloc_range_nid (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE , nid); }/** Signature · 6 lines
2.7.4 -- Sincerely yours, Mike.
Re: [PATCH v2 10/21] memblock: refactor internal allocation functions
Hi all,
Quoted 77 lines · On Mon, 04 Feb 2019 19:45:17 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 7 lines · Mike Rapoport
Quoted 6 lines · Michael Ellerman
Quoted 5 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies....
Quoted 2 lines
Quoted 2 lines
This is causing problems on some of my machines.
...
Quoted 19 lines
Quoted 19 lines
On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..Quoted 7 lines
Quoted 2 lines
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
Yeah, I've misplaced 'nid' and '
MEMBLOCK_ALLOC_ACCESSIBLE' inmemblock_phys_alloc_try_nid():(Can you please check if the below patch fixes the issue on your systems?
Yes it does, thanks.
Tested-by Michael Ellerman <[email protected]>cheers
Quoted 30 lines
From
5875b7440e985ce551e6da3cb28aa8e9af697e10Mon Sep 17 00:00:00 2001
From: Mike Rapoport <[email protected]>
Date: Sun, 3 Feb 2019 13:35:42 +0200
Subject: [PATCH] memblock: fix parameter order in
memblock_phys_alloc_try_nid()The refactoring of internal memblock allocation functions used wrong order of parameters in
memblock_alloc_range_nid()call frommemblock_phys_alloc_try_nid().
Fix it.Signed-off-by Mike Rapoport <[email protected]>--- mm/memblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)mm/memblock.c +2
-2@@ -1402,8 +1402,8 @@ phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,phys_addr_t __init memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid) { -return memblock_alloc_range_nid (size, align,0 , nid, -MEMBLOCK_ALLOC_ACCESSIBLE ); +return memblock_alloc_range_nid (size, align,0 , +MEMBLOCK_ALLOC_ACCESSIBLE , nid); }
Quoted 3 lines
Quoted 3 lines
mm/memblock.c +0
-0/** Signature · 1 line
2.7.4
I have applied that patch to the akpm tree in linux-next from today.
Signature · 2 lines
Cheers, Stephen Rothwell
Michael Ellerman
reviewerRe: [PATCH v2 10/21] memblock: refactor internal allocation functions
In reply to Mike RapoportQuoted 22 lines · Mike Rapoport
Currently, memblock has several internal functions with overlapping functionality. They all call
memblock_find_in_range_node()to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to
memblock_alloc_range_nid()and it now handles node and mirror fallbacks.
Quoted 6 lines
The
memblock_alloc_internal()usesmemblock_alloc_range_nid()to get a physical address of the allocated range and converts it to virtual address.The fallback for allocation below the specified minimal address remains in
memblock_alloc_internal()becausememblock_alloc_range_nid()is used by CMA with exact requirement for lower bounds.
This is causing problems on some of my machines.
I see NODE_DATA allocations falling back to node 0 when they shouldn't, or didn't previously.
eg, before:
57990190: (116011251): numa: NODE_DATA [mem 0xfffe4980-0xfffebfff]
58152042: (116373087): numa: NODE_DATA [mem 0x8fff90980-0x8fff97fff]
after:
16356872061562: (6296877055): numa: NODE_DATA [mem 0xfffe4980-0xfffebfff]
16356872079279: (6296894772): numa: NODE_DATA [mem 0xfffcd300-0xfffd497f]
16356872096376: (6296911869): numa: NODE_DATA(1) on node 0
On some of my other systems it does that, and then panics because it can't allocate anything at all:
[ 0.000000] numa: NODE_DATA [mem 0x7ffcaee80-0x7ffcb3fff] [ 0.000000] numa: NODE_DATA [mem 0x7ffc99d00-0x7ffc9ee7f] [ 0.000000] numa: NODE_DATA(1) on node 0 [ 0.000000] Kernel panic - not syncing: Cannot allocate 20864 bytes for node 16 data [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc4-gccN-next-20190201-gdc4c899 #1 [ 0.000000] Call Trace: [ 0.000000] [c0000000011cfca0] [c000000000c11044] dump_stack+0xe8/0x164 (unreliable) [ 0.000000] [c0000000011cfcf0] [c0000000000fdd6c] panic+0x17c/0x3e0 [ 0.000000] [c0000000011cfd90] [c000000000f61bc8] initmem_init+0x128/0x260 [ 0.000000] [c0000000011cfe60] [c000000000f57940] setup_arch+0x398/0x418 [ 0.000000] [c0000000011cfee0] [c000000000f50a94] start_kernel+0xa0/0x684 [ 0.000000] [c0000000011cff90] [c00000000000af70] start_here_common+0x1c/0x52c [ 0.000000] Rebooting in 180 seconds..
So there's something going wrong there, I haven't had time to dig into it though (Sunday night here).
cheers
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 10/21 memblock: refactor internal allocation functions
In reply to Mike RapoportCurrently, memblock has several internal functions with overlapping functionality. They all call memblock_find_in_range_node() to find free memory and then reserve the allocated range and mark it with kmemleak. However, there is difference in the allocation constraints and in fallback strategies.
The allocations returning physical address first attempt to find free memory on the specified node within mirrored memory regions, then retry on the same node without the requirement for memory mirroring and finally fall back to all available memory.
The allocations returning virtual address start with clamping the allowed range to memblock.current_limit, attempt to allocate from the specified node from regions with mirroring and with user defined minimal address. If such allocation fails, next attempt is done with node restriction lifted. Next, the allocation is retried with minimal address reset to zero and at last without the requirement for mirrored regions.
Let's consolidate various fallbacks handling and make them more consistent for physical and virtual variants. Most of the fallback handling is moved to memblock_alloc_range_nid() and it now handles node and mirror fallbacks.
The memblock_alloc_internal() uses memblock_alloc_range_nid() to get a physical address of the allocated range and converts it to virtual address.
The fallback for allocation below the specified minimal address remains in memblock_alloc_internal() because memblock_alloc_range_nid() is used by CMA with exact requirement for lower bounds.
The memblock_phys_alloc_nid() function is completely dropped as it is not used anywhere outside memblock and its only usage can be replaced by a call to memblock_alloc_range_nid().
--- include/linux/memblock.h | 1 - mm/memblock.c | 173 +++++++++++++++++++++-------------------------- 2 files changed, 78 insertions(+), 96 deletions(-)
include/linux/memblock.h +0 -1
@@ -371,7 +371,6 @@ static inline int memblock_get_region_node(const struct memblock_region *r)phys_addr_t memblock_phys_alloc_range (phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end); -phys_addr_t memblock_phys_alloc_nid (phys_addr_t size,phys_addr_t align,int nid);phys_addr_t memblock_phys_alloc_try_nid (phys_addr_t size,phys_addr_t align,int nid); static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,
mm/memblock.c +78 -95
227 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 11/21 memblock: make memblock_find_in_range_node() and choose_memblock_flags() static
In reply to Mike RapoportThese functions are not used outside memblock. Make them static.
--- include/linux/memblock.h | 4 ---- mm/memblock.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-)
include/linux/memblock.h +0 -4
@@ -111,9 +111,6 @@ void memblock_discard(void);#define memblock_dbg (fmt, ...) \ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -phys_addr_t memblock_find_in_range_node (phys_addr_t size,phys_addr_t align, -phys_addr_t start,phys_addr_t end, -int nid,enum memblock_flags flags);phys_addr_t memblock_find_in_range (phys_addr_t start,phys_addr_t end,phys_addr_t size,phys_addr_t align);void memblock_allow_resize (void );
@@ -130,7 +127,6 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);int memblock_mark_mirror (phys_addr_t base,phys_addr_t size);int memblock_mark_nomap (phys_addr_t base,phys_addr_t size);int memblock_clear_nomap (phys_addr_t base,phys_addr_t size); -enum memblock_flags choose_memblock_flags (void );unsigned long memblock_free_all (void );void reset_node_managed_pages (pg_data_t *pgdat);
mm/memblock.c +2 -2
@@ -125,7 +125,7 @@ static int memblock_can_resize __initdata_memblock; static int memblock_memory_in_slab __initdata_memblock = 0; static int memblock_reserved_in_slab __initdata_memblock = 0; -enum memblock_flags __init_memblock choose_memblock_flags(void) +static enum memblock_flags __init_memblock choose_memblock_flags(void) {return system_has_some_mirror ?MEMBLOCK_MIRROR :MEMBLOCK_NONE ; }
@@ -254,7 +254,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,* Return: * Found address on success, 0 on failure. */ -phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size, +static phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end,int nid,enum memblock_flags flags)
Signature · 1 line
2.7.4
PATCH v2 11/21 memblock: make memblock_find_in_range_node() and choose_memblock_flags() static
In reply to Mike RapoportThese functions are not used outside memblock. Make them static.
--- include/linux/memblock.h | 4 ---- mm/memblock.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-)
include/linux/memblock.h +0 -4
@@ -111,9 +111,6 @@ void memblock_discard(void);#define memblock_dbg (fmt, ...) \ if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) -phys_addr_t memblock_find_in_range_node (phys_addr_t size,phys_addr_t align, -phys_addr_t start,phys_addr_t end, -int nid,enum memblock_flags flags);phys_addr_t memblock_find_in_range (phys_addr_t start,phys_addr_t end,phys_addr_t size,phys_addr_t align);void memblock_allow_resize (void );
@@ -130,7 +127,6 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);int memblock_mark_mirror (phys_addr_t base,phys_addr_t size);int memblock_mark_nomap (phys_addr_t base,phys_addr_t size);int memblock_clear_nomap (phys_addr_t base,phys_addr_t size); -enum memblock_flags choose_memblock_flags (void );unsigned long memblock_free_all (void );void reset_node_managed_pages (pg_data_t *pgdat);
mm/memblock.c +2 -2
@@ -125,7 +125,7 @@ static int memblock_can_resize __initdata_memblock; static int memblock_memory_in_slab __initdata_memblock = 0; static int memblock_reserved_in_slab __initdata_memblock = 0; -enum memblock_flags __init_memblock choose_memblock_flags(void) +static enum memblock_flags __init_memblock choose_memblock_flags(void) {return system_has_some_mirror ?MEMBLOCK_MIRROR :MEMBLOCK_NONE ; }
@@ -254,7 +254,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,* Return: * Found address on success, 0 on failure. */ -phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size, +static phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,phys_addr_t align,phys_addr_t start,phys_addr_t end,int nid,enum memblock_flags flags)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 12/21 arch: use memblock_alloc() instead of memblock_alloc_from(size, align, 0)
In reply to Mike RapoportThe last parameter of memblock_alloc_from() is the lower limit for the memory allocation. When it is 0, the call is equivalent to memblock_alloc().
--- arch/alpha/kernel/core_cia.c | 2 +- arch/alpha/kernel/pci_iommu.c | 4 ++-- arch/alpha/kernel/setup.c | 2 +- arch/ia64/kernel/mca.c | 3 +-- arch/mips/kernel/traps.c | 2 +- arch/sparc/kernel/prom_32.c | 2 +- arch/sparc/mm/init_32.c | 2 +- arch/sparc/mm/srmmu.c | 10 +++++----- 8 files changed, 13 insertions(+), 14 deletions(-)
arch/alpha/kernel/core_cia.c +1 -1
@@ -331,7 +331,7 @@ cia_prepare_tbia_workaround(int window)long i;/* Use minimal 1K map. */ - ppte =memblock_alloc_from (CIA_BROKEN_TBIA_SIZE ,32768 ,0 ); + ppte =memblock_alloc (CIA_BROKEN_TBIA_SIZE ,32768 ); pte = (virt_to_phys (ppte) >> (PAGE_SHIFT -1 )) |1 ;for (i =0 ; i <CIA_BROKEN_TBIA_SIZE /sizeof (unsigned long ); ++i)
arch/alpha/kernel/pci_iommu.c +2 -2
@@ -87,13 +87,13 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,printk ("%s: couldn't allocate arena ptes from node %d\n" " falling back to system-wide allocation\n" , __func__, nid); - arena->ptes = memblock_alloc_from(mem_size, align, 0); + arena->ptes = memblock_alloc(mem_size, align); }#else /* CONFIG_DISCONTIGMEM */ arena =memblock_alloc (sizeof (*arena),SMP_CACHE_BYTES ); - arena->ptes =memblock_alloc_from (mem_size, align,0 ); + arena->ptes =memblock_alloc (mem_size, align);#endif /* CONFIG_DISCONTIGMEM */
arch/alpha/kernel/setup.c +1 -1
@@ -293,7 +293,7 @@ move_initrd(unsigned long mem_limit)unsigned long size; size = initrd_end - initrd_start; - start =memblock_alloc_from (PAGE_ALIGN (size),PAGE_SIZE ,0 ); + start =memblock_alloc (PAGE_ALIGN (size),PAGE_SIZE );if (!start ||__pa (start) + size > mem_limit) { initrd_start = initrd_end =0 ;return NULL ;
arch/ia64/kernel/mca.c +1 -2
@@ -1835,8 +1835,7 @@ format_mca_init_stack(void *mca_data, unsigned long offset,/* Caller prevents this from being called after init */ static void *__ref mca_bootmem (void ) { -return memblock_alloc_from (sizeof (struct ia64_mca_cpu ), -KERNEL_STACK_SIZE ,0 ); +return memblock_alloc (sizeof (struct ia64_mca_cpu ),KERNEL_STACK_SIZE ); }/* Do per-CPU MCA-related initialization. */
arch/mips/kernel/traps.c +1 -1
@@ -2291,7 +2291,7 @@ void __init trap_init(void)phys_addr_t ebase_pa; ebase = (unsigned long ) -memblock_alloc_from (size,1 <<fls (size),0 ); +memblock_alloc (size,1 <<fls (size));/* * Try to ensure ebase resides in KSeg0 if possible.
arch/sparc/kernel/prom_32.c +1 -1
@@ -32,7 +32,7 @@ void * __init prom_early_alloc(unsigned long size) {void *ret; - ret =memblock_alloc_from (size,SMP_CACHE_BYTES ,0UL ); + ret =memblock_alloc (size,SMP_CACHE_BYTES );if (ret !=NULL )memset (ret,0 , size);
arch/sparc/mm/init_32.c +1 -1
@@ -264,7 +264,7 @@ void __init mem_init(void) i = last_valid_pfn >> ((20 -PAGE_SHIFT ) +5 ); i +=1 ; sparc_valid_addr_bitmap = (unsigned long *) -memblock_alloc_from (i <<2 ,SMP_CACHE_BYTES ,0UL ); +memblock_alloc (i <<2 ,SMP_CACHE_BYTES );if (sparc_valid_addr_bitmap ==NULL ) {prom_printf ("mem_init: Cannot alloc valid_addr_bitmap.\n" );
arch/sparc/mm/srmmu.c +5 -5
@@ -303,13 +303,13 @@ static void __init srmmu_nocache_init(void) bitmap_bits = srmmu_nocache_size >>SRMMU_NOCACHE_BITMAP_SHIFT ; - srmmu_nocache_pool =memblock_alloc_from (srmmu_nocache_size, -SRMMU_NOCACHE_ALIGN_MAX ,0UL ); + srmmu_nocache_pool =memblock_alloc (srmmu_nocache_size, +SRMMU_NOCACHE_ALIGN_MAX );memset (srmmu_nocache_pool,0 , srmmu_nocache_size); srmmu_nocache_bitmap = -memblock_alloc_from (BITS_TO_LONGS (bitmap_bits) *sizeof (long ), -SMP_CACHE_BYTES ,0UL ); +memblock_alloc (BITS_TO_LONGS (bitmap_bits) *sizeof (long ), +SMP_CACHE_BYTES );bit_map_init (&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); srmmu_swapper_pg_dir =__srmmu_get_nocache (SRMMU_PGD_TABLE_SIZE ,SRMMU_PGD_TABLE_SIZE );
@@ -467,7 +467,7 @@ static void __init sparc_context_init(int numctx)unsigned long size; size = numctx *sizeof (struct ctx_list ); - ctx_list_pool =memblock_alloc_from (size,SMP_CACHE_BYTES ,0UL ); + ctx_list_pool =memblock_alloc (size,SMP_CACHE_BYTES );for (ctx =0 ; ctx < numctx; ctx++) {struct ctx_list *clist;
Signature · 1 line
2.7.4
PATCH v2 12/21 arch: use memblock_alloc() instead of memblock_alloc_from(size, align, 0)
In reply to Mike RapoportThe last parameter of memblock_alloc_from() is the lower limit for the memory allocation. When it is 0, the call is equivalent to memblock_alloc().
--- arch/alpha/kernel/core_cia.c | 2 +- arch/alpha/kernel/pci_iommu.c | 4 ++-- arch/alpha/kernel/setup.c | 2 +- arch/ia64/kernel/mca.c | 3 +-- arch/mips/kernel/traps.c | 2 +- arch/sparc/kernel/prom_32.c | 2 +- arch/sparc/mm/init_32.c | 2 +- arch/sparc/mm/srmmu.c | 10 +++++----- 8 files changed, 13 insertions(+), 14 deletions(-)
arch/alpha/kernel/core_cia.c +1 -1
@@ -331,7 +331,7 @@ cia_prepare_tbia_workaround(int window)long i;/* Use minimal 1K map. */ - ppte =memblock_alloc_from (CIA_BROKEN_TBIA_SIZE ,32768 ,0 ); + ppte =memblock_alloc (CIA_BROKEN_TBIA_SIZE ,32768 ); pte = (virt_to_phys (ppte) >> (PAGE_SHIFT -1 )) |1 ;for (i =0 ; i <CIA_BROKEN_TBIA_SIZE /sizeof (unsigned long ); ++i)
arch/alpha/kernel/pci_iommu.c +2 -2
@@ -87,13 +87,13 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,printk ("%s: couldn't allocate arena ptes from node %d\n" " falling back to system-wide allocation\n" , __func__, nid); - arena->ptes = memblock_alloc_from(mem_size, align, 0); + arena->ptes = memblock_alloc(mem_size, align); }#else /* CONFIG_DISCONTIGMEM */ arena =memblock_alloc (sizeof (*arena),SMP_CACHE_BYTES ); - arena->ptes =memblock_alloc_from (mem_size, align,0 ); + arena->ptes =memblock_alloc (mem_size, align);#endif /* CONFIG_DISCONTIGMEM */
arch/alpha/kernel/setup.c +1 -1
@@ -293,7 +293,7 @@ move_initrd(unsigned long mem_limit)unsigned long size; size = initrd_end - initrd_start; - start =memblock_alloc_from (PAGE_ALIGN (size),PAGE_SIZE ,0 ); + start =memblock_alloc (PAGE_ALIGN (size),PAGE_SIZE );if (!start ||__pa (start) + size > mem_limit) { initrd_start = initrd_end =0 ;return NULL ;
arch/ia64/kernel/mca.c +1 -2
@@ -1835,8 +1835,7 @@ format_mca_init_stack(void *mca_data, unsigned long offset,/* Caller prevents this from being called after init */ static void *__ref mca_bootmem (void ) { -return memblock_alloc_from (sizeof (struct ia64_mca_cpu ), -KERNEL_STACK_SIZE ,0 ); +return memblock_alloc (sizeof (struct ia64_mca_cpu ),KERNEL_STACK_SIZE ); }/* Do per-CPU MCA-related initialization. */
arch/mips/kernel/traps.c +1 -1
@@ -2291,7 +2291,7 @@ void __init trap_init(void)phys_addr_t ebase_pa; ebase = (unsigned long ) -memblock_alloc_from (size,1 <<fls (size),0 ); +memblock_alloc (size,1 <<fls (size));/* * Try to ensure ebase resides in KSeg0 if possible.
arch/sparc/kernel/prom_32.c +1 -1
@@ -32,7 +32,7 @@ void * __init prom_early_alloc(unsigned long size) {void *ret; - ret =memblock_alloc_from (size,SMP_CACHE_BYTES ,0UL ); + ret =memblock_alloc (size,SMP_CACHE_BYTES );if (ret !=NULL )memset (ret,0 , size);
arch/sparc/mm/init_32.c +1 -1
@@ -264,7 +264,7 @@ void __init mem_init(void) i = last_valid_pfn >> ((20 -PAGE_SHIFT ) +5 ); i +=1 ; sparc_valid_addr_bitmap = (unsigned long *) -memblock_alloc_from (i <<2 ,SMP_CACHE_BYTES ,0UL ); +memblock_alloc (i <<2 ,SMP_CACHE_BYTES );if (sparc_valid_addr_bitmap ==NULL ) {prom_printf ("mem_init: Cannot alloc valid_addr_bitmap.\n" );
arch/sparc/mm/srmmu.c +5 -5
@@ -303,13 +303,13 @@ static void __init srmmu_nocache_init(void) bitmap_bits = srmmu_nocache_size >>SRMMU_NOCACHE_BITMAP_SHIFT ; - srmmu_nocache_pool =memblock_alloc_from (srmmu_nocache_size, -SRMMU_NOCACHE_ALIGN_MAX ,0UL ); + srmmu_nocache_pool =memblock_alloc (srmmu_nocache_size, +SRMMU_NOCACHE_ALIGN_MAX );memset (srmmu_nocache_pool,0 , srmmu_nocache_size); srmmu_nocache_bitmap = -memblock_alloc_from (BITS_TO_LONGS (bitmap_bits) *sizeof (long ), -SMP_CACHE_BYTES ,0UL ); +memblock_alloc (BITS_TO_LONGS (bitmap_bits) *sizeof (long ), +SMP_CACHE_BYTES );bit_map_init (&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); srmmu_swapper_pg_dir =__srmmu_get_nocache (SRMMU_PGD_TABLE_SIZE ,SRMMU_PGD_TABLE_SIZE );
@@ -467,7 +467,7 @@ static void __init sparc_context_init(int numctx)unsigned long size; size = numctx *sizeof (struct ctx_list ); - ctx_list_pool =memblock_alloc_from (size,SMP_CACHE_BYTES ,0UL ); + ctx_list_pool =memblock_alloc (size,SMP_CACHE_BYTES );for (ctx =0 ; ctx < numctx; ctx++) {struct ctx_list *clist;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 13/21 arch: don't memset(0) memory returned by memblock_alloc()
In reply to Mike Rapoportmemblock_alloc() already clears the allocated memory, no point in doing it twice.
--- arch/c6x/mm/init.c | 1 - arch/h8300/mm/init.c | 1 - arch/ia64/kernel/mca.c | 2 -- arch/m68k/mm/mcfmmu.c | 1 - arch/microblaze/mm/init.c | 6 ++---- arch/sparc/kernel/prom_32.c | 2 -- 6 files changed, 2 insertions(+), 11 deletions(-)
arch/c6x/mm/init.c +0 -1
@@ -40,7 +40,6 @@ void __init paging_init(void) empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); -memset ((void *)empty_zero_page,0 ,PAGE_SIZE );/* * Set up user data space
arch/h8300/mm/init.c +0 -1
@@ -68,7 +68,6 @@ void __init paging_init(void)* to a couple of allocated pages. */ empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); -memset ((void *)empty_zero_page,0 ,PAGE_SIZE );/* * Set up SFC/DFC registers (user data space).
arch/ia64/kernel/mca.c +0 -2
@@ -400,8 +400,6 @@ ia64_log_init(int sal_info_type)// set up OS data structures to hold error info IA64_LOG_ALLOCATE (sal_info_type, max_size); -memset (IA64_LOG_CURR_BUFFER (sal_info_type),0 , max_size); -memset (IA64_LOG_NEXT_BUFFER (sal_info_type),0 , max_size); }/*
arch/m68k/mm/mcfmmu.c +0 -1
@@ -44,7 +44,6 @@ void __init paging_init(void)int i; empty_zero_page = (void *)memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); -memset ((void *) empty_zero_page,0 ,PAGE_SIZE ); pg_dir = swapper_pg_dir;memset (swapper_pg_dir,0 ,sizeof (swapper_pg_dir));
arch/microblaze/mm/init.c +2 -4
@@ -376,10 +376,8 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)if (mem_init_done) p =kzalloc (size, mask); -else { +else p =memblock_alloc (size,SMP_CACHE_BYTES ); -if (p) -memset (p,0 , size); - } +return p; }
arch/sparc/kernel/prom_32.c +0 -2
@@ -33,8 +33,6 @@ void * __init prom_early_alloc(unsigned long size)void *ret; ret =memblock_alloc (size,SMP_CACHE_BYTES ); -if (ret !=NULL ) -memset (ret,0 , size); prom_early_allocated += size;
Signature · 1 line
2.7.4
PATCH v2 13/21 arch: don't memset(0) memory returned by memblock_alloc()
In reply to Mike Rapoportmemblock_alloc() already clears the allocated memory, no point in doing it twice.
--- arch/c6x/mm/init.c | 1 - arch/h8300/mm/init.c | 1 - arch/ia64/kernel/mca.c | 2 -- arch/m68k/mm/mcfmmu.c | 1 - arch/microblaze/mm/init.c | 6 ++---- arch/sparc/kernel/prom_32.c | 2 -- 6 files changed, 2 insertions(+), 11 deletions(-)
arch/c6x/mm/init.c +0 -1
@@ -40,7 +40,6 @@ void __init paging_init(void) empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); -memset ((void *)empty_zero_page,0 ,PAGE_SIZE );/* * Set up user data space
arch/h8300/mm/init.c +0 -1
@@ -68,7 +68,6 @@ void __init paging_init(void)* to a couple of allocated pages. */ empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); -memset ((void *)empty_zero_page,0 ,PAGE_SIZE );/* * Set up SFC/DFC registers (user data space).
arch/ia64/kernel/mca.c +0 -2
@@ -400,8 +400,6 @@ ia64_log_init(int sal_info_type)// set up OS data structures to hold error info IA64_LOG_ALLOCATE (sal_info_type, max_size); -memset (IA64_LOG_CURR_BUFFER (sal_info_type),0 , max_size); -memset (IA64_LOG_NEXT_BUFFER (sal_info_type),0 , max_size); }/*
arch/m68k/mm/mcfmmu.c +0 -1
@@ -44,7 +44,6 @@ void __init paging_init(void)int i; empty_zero_page = (void *)memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); -memset ((void *) empty_zero_page,0 ,PAGE_SIZE ); pg_dir = swapper_pg_dir;memset (swapper_pg_dir,0 ,sizeof (swapper_pg_dir));
arch/microblaze/mm/init.c +2 -4
@@ -376,10 +376,8 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)if (mem_init_done) p =kzalloc (size, mask); -else { +else p =memblock_alloc (size,SMP_CACHE_BYTES ); -if (p) -memset (p,0 , size); - } +return p; }
arch/sparc/kernel/prom_32.c +0 -2
@@ -33,8 +33,6 @@ void * __init prom_early_alloc(unsigned long size)void *ret; ret =memblock_alloc (size,SMP_CACHE_BYTES ); -if (ret !=NULL ) -memset (ret,0 , size); prom_early_allocated += size;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 14/21 ia64: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc*() returns NULL.
Most of the changes are simply addition of
if(!ptr) panic();
statements after the calls to memblock_alloc*() variants.
Exceptions are create_mem_map_page_table() and ia64_log_init() that were slightly refactored to accommodate the change.
--- arch/ia64/kernel/mca.c | 20 ++++++++++++++------ arch/ia64/mm/contig.c | 8 ++++++-- arch/ia64/mm/discontig.c | 4 ++++ arch/ia64/mm/init.c | 38 ++++++++++++++++++++++++++++++-------- arch/ia64/mm/tlb.c | 6 ++++++ arch/ia64/sn/kernel/io_common.c | 3 +++ arch/ia64/sn/kernel/setup.c | 12 +++++++++++- 7 files changed, 74 insertions(+), 17 deletions(-)
arch/ia64/kernel/mca.c +14 -6
@@ -359,11 +359,6 @@ typedef struct ia64_state_log_sstatic ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES ]; -#define IA64_LOG_ALLOCATE (it, size) \ - {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \ - (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES); \ - ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \ - (ia64_err_rec_t *)memblock_alloc(size, SMP_CACHE_BYTES);}#define IA64_LOG_LOCK_INIT (it) spin_lock_init(&ia64_state_log[it].isl_lock)#define IA64_LOG_LOCK (it) spin_lock_irqsave(&ia64_state_log[it].isl_lock, s)#define IA64_LOG_UNLOCK (it) spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s)
@@ -378,6 +373,19 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];#define IA64_LOG_CURR_BUFFER (it) (void *)((ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)]))#define IA64_LOG_COUNT (it) ia64_state_log[it].isl_count +static inline void ia64_log_allocate (int it,u64 size) +{ + ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX (it)] = + (ia64_err_rec_t *)memblock_alloc (size,SMP_CACHE_BYTES ); +if (!ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX (it)]) +panic ("%s: Failed to allocate %llu bytes\n" , __func__, size); + + ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX (it)] = + (ia64_err_rec_t *)memblock_alloc (size,SMP_CACHE_BYTES ); +if (!ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX (it)]) +panic ("%s: Failed to allocate %llu bytes\n" , __func__, size); +} +/* * ia64_log_init * Reset the OS ia64 log buffer
@@ -399,7 +407,7 @@ ia64_log_init(int sal_info_type)return ;// set up OS data structures to hold error info -IA64_LOG_ALLOCATE (sal_info_type, max_size); +ia64_log_allocate (sal_info_type, max_size); }/*
arch/ia64/mm/contig.c +6 -2
@@ -84,9 +84,13 @@ void *per_cpu_init(void)static inline void alloc_per_cpu_data (void ) { - cpu_data =memblock_alloc_from (PERCPU_PAGE_SIZE *num_possible_cpus (), -PERCPU_PAGE_SIZE , +size_t size =PERCPU_PAGE_SIZE *num_possible_cpus (); + + cpu_data =memblock_alloc_from (size,PERCPU_PAGE_SIZE ,__pa (MAX_DMA_ADDRESS )); +if (!cpu_data) +panic ("%s: Failed to allocate %lu bytes align=%lx from=%lx\n" , + __func__, size,PERCPU_PAGE_SIZE ,__pa (MAX_DMA_ADDRESS )); }/**
arch/ia64/mm/discontig.c +4 -0
@@ -454,6 +454,10 @@ static void __init *memory_less_node_alloc(int nid, unsigned long pernodesize)__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , bestnode); +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, pernodesize,PERCPU_PAGE_SIZE , bestnode, +__pa (MAX_DMA_ADDRESS ));return ptr; }
arch/ia64/mm/init.c +30 -8
@@ -444,23 +444,45 @@ int __init create_mem_map_page_table(u64 start, u64 end, void *arg)for (address = start_page; address < end_page; address +=PAGE_SIZE ) { pgd =pgd_offset_k (address); -if (pgd_none (*pgd)) -pgd_populate (&init_mm, pgd,memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node)); +if (pgd_none (*pgd)) { + pud =memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node); +if (!pud) + goto err_alloc; +pgd_populate (&init_mm, pgd, pud); + } pud =pud_offset (pgd, address); -if (pud_none (*pud)) -pud_populate (&init_mm, pud,memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node)); +if (pud_none (*pud)) { + pmd =memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node); +if (!pmd) + goto err_alloc; +pud_populate (&init_mm, pud, pmd); + } pmd =pmd_offset (pud, address); -if (pmd_none (*pmd)) -pmd_populate_kernel (&init_mm, pmd,memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node)); +if (pmd_none (*pmd)) { + pte =memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node); +if (!pte) + goto err_alloc; +pmd_populate_kernel (&init_mm, pmd, pte); + } pte =pte_offset_kernel (pmd, address); -if (pte_none (*pte)) -set_pte (pte,pfn_pte (__pa (memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , node)) >>PAGE_SHIFT , +if (pte_none (*pte)) { +void *page =memblock_alloc_node (PAGE_SIZE ,PAGE_SIZE , + node); +if (!page) + goto err_alloc; +set_pte (pte,pfn_pte (__pa (page) >>PAGE_SHIFT ,PAGE_KERNEL )); + } }return 0 ; + +err_alloc: +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d\n" , + __func__,PAGE_SIZE ,PAGE_SIZE , node); +return -ENOMEM ; }struct memmap_init_callback_data {
arch/ia64/mm/tlb.c +6 -0
@@ -61,8 +61,14 @@ mmu_context_init (void) { ia64_ctx.bitmap =memblock_alloc ((ia64_ctx.max_ctx +1 ) >>3 ,SMP_CACHE_BYTES ); +if (!ia64_ctx.bitmap) +panic ("%s: Failed to allocate %u bytes\n" , __func__, + (ia64_ctx.max_ctx +1 ) >>3 ); ia64_ctx.flushmap =memblock_alloc ((ia64_ctx.max_ctx +1 ) >>3 ,SMP_CACHE_BYTES ); +if (!ia64_ctx.flushmap) +panic ("%s: Failed to allocate %u bytes\n" , __func__, + (ia64_ctx.max_ctx +1 ) >>3 ); }/*
arch/ia64/sn/kernel/io_common.c +3 -0
@@ -394,6 +394,9 @@ void __init hubdev_init_node(nodepda_t * npda, cnodeid_t node) hubdev_info = (struct hubdev_info *)memblock_alloc_node (size,SMP_CACHE_BYTES , node); +if (!hubdev_info) +panic ("%s: Failed to allocate %d bytes align=0x%x nid=%d\n" , + __func__, size,SMP_CACHE_BYTES , node); npda->pdinfo = (void *)hubdev_info; }
arch/ia64/sn/kernel/setup.c +11 -1
@@ -513,6 +513,10 @@ static void __init sn_init_pdas(char **cmdline_p) nodepdaindr[cnode] =memblock_alloc_node (sizeof (nodepda_t),SMP_CACHE_BYTES , cnode); +if (!nodepdaindr[cnode]) +panic ("%s: Failed to allocate %lu bytes align=0x%x nid=%d\n" , + __func__,sizeof (nodepda_t),SMP_CACHE_BYTES , + cnode);memset (nodepdaindr[cnode]->phys_cpuid,-1 ,sizeof (nodepdaindr[cnode]->phys_cpuid));spin_lock_init (&nodepdaindr[cnode]->ptc_lock);
@@ -521,9 +525,15 @@ static void __init sn_init_pdas(char **cmdline_p)/* * Allocate & initialize nodepda for TIOs. For now, put them on node 0. */ -for (cnode =num_online_nodes (); cnode < num_cnodes; cnode++) +for (cnode =num_online_nodes (); cnode < num_cnodes; cnode++) { nodepdaindr[cnode] =memblock_alloc_node (sizeof (nodepda_t),SMP_CACHE_BYTES ,0 ); +if (!nodepdaindr[cnode]) +panic ("%s: Failed to allocate %lu bytes align=0x%x nid=%d\n" , + __func__,sizeof (nodepda_t),SMP_CACHE_BYTES , + cnode); + } +/* * Now copy the array of nodepda pointers to each nodepda.
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 15/21 sparc: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc*() returns NULL.
Most of the changes are simply addition of
if(!ptr)
panic();statements after the calls to memblock_alloc*() variants.
Exceptions are pcpu_populate_pte() and kernel_map_range() that were slightly refactored to accommodate the change.
--- arch/sparc/kernel/prom_32.c | 2 ++ arch/sparc/kernel/setup_64.c | 6 ++++++ arch/sparc/kernel/smp_64.c | 12 ++++++++++++ arch/sparc/mm/init_64.c | 11 +++++++++++ arch/sparc/mm/srmmu.c | 8 ++++++++ 5 files changed, 39 insertions(+)
arch/sparc/kernel/prom_32.c +2 -0
@@ -33,6 +33,8 @@ void * __init prom_early_alloc(unsigned long size)void *ret; ret =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!ret) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, size); prom_early_allocated += size;
arch/sparc/kernel/setup_64.c +6 -0
@@ -624,8 +624,14 @@ void __init alloc_irqstack_bootmem(void) softirq_stack[i] =memblock_alloc_node (THREAD_SIZE ,THREAD_SIZE , node); +if (!softirq_stack[i]) +panic ("%s: Failed to allocate %lu bytes align=%lx nid=%d\n" , + __func__,THREAD_SIZE ,THREAD_SIZE , node); hardirq_stack[i] =memblock_alloc_node (THREAD_SIZE ,THREAD_SIZE , node); +if (!hardirq_stack[i]) +panic ("%s: Failed to allocate %lu bytes align=%lx nid=%d\n" , + __func__,THREAD_SIZE ,THREAD_SIZE , node); } }
arch/sparc/kernel/smp_64.c +12 -0
@@ -1628,6 +1628,8 @@ static void __init pcpu_populate_pte(unsigned long addr)pud_t *new; new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc;pgd_populate (&init_mm, pgd, new); }
@@ -1636,6 +1638,8 @@ static void __init pcpu_populate_pte(unsigned long addr)pmd_t *new; new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc;pud_populate (&init_mm, pud, new); }
@@ -1644,8 +1648,16 @@ static void __init pcpu_populate_pte(unsigned long addr)pte_t *new; new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc;pmd_populate_kernel (&init_mm, pmd, new); } + +return ; + +err_alloc: +panic ("%s: Failed to allocate %lu bytes align=%lx from=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); }void __init setup_per_cpu_areas (void )
arch/sparc/mm/init_64.c +11 -0
@@ -1809,6 +1809,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc; alloc_bytes +=PAGE_SIZE ;pgd_populate (&init_mm, pgd, new); }
@@ -1822,6 +1824,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, } new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc; alloc_bytes +=PAGE_SIZE ;pud_populate (&init_mm, pud, new); }
@@ -1836,6 +1840,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, } new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc; alloc_bytes +=PAGE_SIZE ;pmd_populate_kernel (&init_mm, pmd, new); }
@@ -1855,6 +1861,11 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, }return alloc_bytes; + +err_alloc: +panic ("%s: Failed to allocate %lu bytes align=%lx from=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +return -ENOMEM ; }static void __init flush_all_kernel_tsbs (void )
arch/sparc/mm/srmmu.c +8 -0
@@ -305,11 +305,17 @@ static void __init srmmu_nocache_init(void) srmmu_nocache_pool =memblock_alloc (srmmu_nocache_size,SRMMU_NOCACHE_ALIGN_MAX ); +if (!srmmu_nocache_pool) +panic ("%s: Failed to allocate %lu bytes align=0x%x\n" , + __func__, srmmu_nocache_size,SRMMU_NOCACHE_ALIGN_MAX );memset (srmmu_nocache_pool,0 , srmmu_nocache_size); srmmu_nocache_bitmap =memblock_alloc (BITS_TO_LONGS (bitmap_bits) *sizeof (long ),SMP_CACHE_BYTES ); +if (!srmmu_nocache_bitmap) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +BITS_TO_LONGS (bitmap_bits) *sizeof (long ));bit_map_init (&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); srmmu_swapper_pg_dir =__srmmu_get_nocache (SRMMU_PGD_TABLE_SIZE ,SRMMU_PGD_TABLE_SIZE );
@@ -468,6 +474,8 @@ static void __init sparc_context_init(int numctx) size = numctx *sizeof (struct ctx_list ); ctx_list_pool =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!ctx_list_pool) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, size);for (ctx =0 ; ctx < numctx; ctx++) {struct ctx_list *clist;
Signature · 1 line
2.7.4
PATCH v2 15/21 sparc: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc*() returns NULL.
Most of the changes are simply addition of
if(!ptr)
panic();statements after the calls to memblock_alloc*() variants.
Exceptions are pcpu_populate_pte() and kernel_map_range() that were slightly refactored to accommodate the change.
--- arch/sparc/kernel/prom_32.c | 2 ++ arch/sparc/kernel/setup_64.c | 6 ++++++ arch/sparc/kernel/smp_64.c | 12 ++++++++++++ arch/sparc/mm/init_64.c | 11 +++++++++++ arch/sparc/mm/srmmu.c | 8 ++++++++ 5 files changed, 39 insertions(+)
arch/sparc/kernel/prom_32.c +2 -0
@@ -33,6 +33,8 @@ void * __init prom_early_alloc(unsigned long size)void *ret; ret =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!ret) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, size); prom_early_allocated += size;
arch/sparc/kernel/setup_64.c +6 -0
@@ -624,8 +624,14 @@ void __init alloc_irqstack_bootmem(void) softirq_stack[i] =memblock_alloc_node (THREAD_SIZE ,THREAD_SIZE , node); +if (!softirq_stack[i]) +panic ("%s: Failed to allocate %lu bytes align=%lx nid=%d\n" , + __func__,THREAD_SIZE ,THREAD_SIZE , node); hardirq_stack[i] =memblock_alloc_node (THREAD_SIZE ,THREAD_SIZE , node); +if (!hardirq_stack[i]) +panic ("%s: Failed to allocate %lu bytes align=%lx nid=%d\n" , + __func__,THREAD_SIZE ,THREAD_SIZE , node); } }
arch/sparc/kernel/smp_64.c +12 -0
@@ -1628,6 +1628,8 @@ static void __init pcpu_populate_pte(unsigned long addr)pud_t *new; new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc;pgd_populate (&init_mm, pgd, new); }
@@ -1636,6 +1638,8 @@ static void __init pcpu_populate_pte(unsigned long addr)pmd_t *new; new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc;pud_populate (&init_mm, pud, new); }
@@ -1644,8 +1648,16 @@ static void __init pcpu_populate_pte(unsigned long addr)pte_t *new; new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc;pmd_populate_kernel (&init_mm, pmd, new); } + +return ; + +err_alloc: +panic ("%s: Failed to allocate %lu bytes align=%lx from=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); }void __init setup_per_cpu_areas (void )
arch/sparc/mm/init_64.c +11 -0
@@ -1809,6 +1809,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc; alloc_bytes +=PAGE_SIZE ;pgd_populate (&init_mm, pgd, new); }
@@ -1822,6 +1824,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, } new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc; alloc_bytes +=PAGE_SIZE ;pud_populate (&init_mm, pud, new); }
@@ -1836,6 +1840,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, } new =memblock_alloc_from (PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +if (!new) + goto err_alloc; alloc_bytes +=PAGE_SIZE ;pmd_populate_kernel (&init_mm, pmd, new); }
@@ -1855,6 +1861,11 @@ static unsigned long __ref kernel_map_range(unsigned long pstart, }return alloc_bytes; + +err_alloc: +panic ("%s: Failed to allocate %lu bytes align=%lx from=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ,PAGE_SIZE ); +return -ENOMEM ; }static void __init flush_all_kernel_tsbs (void )
arch/sparc/mm/srmmu.c +8 -0
@@ -305,11 +305,17 @@ static void __init srmmu_nocache_init(void) srmmu_nocache_pool =memblock_alloc (srmmu_nocache_size,SRMMU_NOCACHE_ALIGN_MAX ); +if (!srmmu_nocache_pool) +panic ("%s: Failed to allocate %lu bytes align=0x%x\n" , + __func__, srmmu_nocache_size,SRMMU_NOCACHE_ALIGN_MAX );memset (srmmu_nocache_pool,0 , srmmu_nocache_size); srmmu_nocache_bitmap =memblock_alloc (BITS_TO_LONGS (bitmap_bits) *sizeof (long ),SMP_CACHE_BYTES ); +if (!srmmu_nocache_bitmap) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +BITS_TO_LONGS (bitmap_bits) *sizeof (long ));bit_map_init (&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits); srmmu_swapper_pg_dir =__srmmu_get_nocache (SRMMU_PGD_TABLE_SIZE ,SRMMU_PGD_TABLE_SIZE );
@@ -468,6 +474,8 @@ static void __init sparc_context_init(int numctx) size = numctx *sizeof (struct ctx_list ); ctx_list_pool =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!ctx_list_pool) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, size);for (ctx =0 ; ctx < numctx; ctx++) {struct ctx_list *clist;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 16/21 mm/percpu: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc() returns NULL.
The panic() format duplicates the one used by memblock itself and in order to avoid explosion with long parameters list replace open coded allocation size calculations with a local variable.
--- mm/percpu.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 17 deletions(-)
mm/percpu.c +56 -17
@@ -1086,6 +1086,7 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr,struct pcpu_chunk *chunk;unsigned long aligned_addr, lcm_align;int start_offset, offset_bits, region_size, region_bits; +size_t alloc_size;/* region calculations */ aligned_addr = tmp_addr &PAGE_MASK ;
@@ -1101,9 +1102,12 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, region_size =ALIGN (start_offset + map_size, lcm_align);/* allocate chunk */ - chunk =memblock_alloc (sizeof (struct pcpu_chunk ) + -BITS_TO_LONGS (region_size >>PAGE_SHIFT ), -SMP_CACHE_BYTES ); + alloc_size =sizeof (struct pcpu_chunk ) + +BITS_TO_LONGS (region_size >>PAGE_SHIFT ); + chunk =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!chunk) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size);INIT_LIST_HEAD (&chunk->list);
@@ -1114,12 +1118,25 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, chunk->nr_pages = region_size >>PAGE_SHIFT ; region_bits =pcpu_chunk_map_bits (chunk); - chunk->alloc_map =memblock_alloc (BITS_TO_LONGS (region_bits) *sizeof (chunk->alloc_map[0 ]), -SMP_CACHE_BYTES ); - chunk->bound_map =memblock_alloc (BITS_TO_LONGS (region_bits +1 ) *sizeof (chunk->bound_map[0 ]), -SMP_CACHE_BYTES ); - chunk->md_blocks =memblock_alloc (pcpu_chunk_nr_blocks (chunk) *sizeof (chunk->md_blocks[0 ]), -SMP_CACHE_BYTES ); + alloc_size =BITS_TO_LONGS (region_bits) *sizeof (chunk->alloc_map[0 ]); + chunk->alloc_map =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!chunk->alloc_map) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size); + + alloc_size = +BITS_TO_LONGS (region_bits +1 ) *sizeof (chunk->bound_map[0 ]); + chunk->bound_map =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!chunk->bound_map) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size); + + alloc_size =pcpu_chunk_nr_blocks (chunk) *sizeof (chunk->md_blocks[0 ]); + chunk->md_blocks =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!chunk->md_blocks) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size); +pcpu_init_md_blocks (chunk);/* manage populated page bitmap */
@@ -2044,6 +2061,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,int group, unit, i;int map_size;unsigned long tmp_addr; +size_t alloc_size;#define PCPU_SETUP_BUG_ON (cond) do { \ if (unlikely(cond)) { \
@@ -2075,14 +2093,29 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,PCPU_SETUP_BUG_ON (pcpu_verify_alloc_info (ai) <0 );/* process group information and build config tables accordingly */ - group_offsets =memblock_alloc (ai->nr_groups *sizeof (group_offsets[0 ]), -SMP_CACHE_BYTES ); - group_sizes =memblock_alloc (ai->nr_groups *sizeof (group_sizes[0 ]), -SMP_CACHE_BYTES ); - unit_map =memblock_alloc (nr_cpu_ids *sizeof (unit_map[0 ]), -SMP_CACHE_BYTES ); - unit_off =memblock_alloc (nr_cpu_ids *sizeof (unit_off[0 ]), -SMP_CACHE_BYTES ); + alloc_size = ai->nr_groups *sizeof (group_offsets[0 ]); + group_offsets =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!group_offsets) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size); + + alloc_size = ai->nr_groups *sizeof (group_sizes[0 ]); + group_sizes =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!group_sizes) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size); + + alloc_size = nr_cpu_ids *sizeof (unit_map[0 ]); + unit_map =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!unit_map) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size); + + alloc_size = nr_cpu_ids *sizeof (unit_off[0 ]); + unit_off =memblock_alloc (alloc_size,SMP_CACHE_BYTES ); +if (!unit_off) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + alloc_size);for (cpu =0 ; cpu < nr_cpu_ids; cpu++) unit_map[cpu] =UINT_MAX ;
@@ -2148,6 +2181,9 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, pcpu_nr_slots =__pcpu_size_to_slot (pcpu_unit_size) +2 ; pcpu_slot =memblock_alloc (pcpu_nr_slots *sizeof (pcpu_slot[0 ]),SMP_CACHE_BYTES ); +if (!pcpu_slot) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + pcpu_nr_slots *sizeof (pcpu_slot[0 ]));for (i =0 ; i < pcpu_nr_slots; i++)INIT_LIST_HEAD (&pcpu_slot[i]);
@@ -2602,6 +2638,9 @@ int __init pcpu_page_first_chunk(size_t reserved_size, pages_size =PFN_ALIGN (unit_pages *num_possible_cpus () *sizeof (pages[0 ])); pages =memblock_alloc (pages_size,SMP_CACHE_BYTES ); +if (!pages) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + pages_size);/* allocate pages */ j =0 ;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 17/21 init/main: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc() returns NULL.
The panic() format duplicates the one used by memblock itself and in order to avoid explosion with long parameters list replace open coded allocation size calculations with a local variable.
--- init/main.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
init/main.c +20 -6
@@ -373,12 +373,20 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }*/ static void __init setup_command_line (char *command_line) { - saved_command_line = -memblock_alloc (strlen (boot_command_line) +1 ,SMP_CACHE_BYTES ); - initcall_command_line = -memblock_alloc (strlen (boot_command_line) +1 ,SMP_CACHE_BYTES ); - static_command_line =memblock_alloc (strlen (command_line) +1 , -SMP_CACHE_BYTES ); +size_t len =strlen (boot_command_line) +1 ; + + saved_command_line =memblock_alloc (len,SMP_CACHE_BYTES ); +if (!saved_command_line) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, len); + + initcall_command_line =memblock_alloc (len,SMP_CACHE_BYTES ); +if (!initcall_command_line) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, len); + + static_command_line =memblock_alloc (len,SMP_CACHE_BYTES ); +if (!static_command_line) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, len); +strcpy (saved_command_line, boot_command_line);strcpy (static_command_line, command_line); }
@@ -773,8 +781,14 @@ static int __init initcall_blacklist(char *str)pr_debug ("blacklisting initcall %s\n" , str_entry); entry =memblock_alloc (sizeof (*entry),SMP_CACHE_BYTES ); +if (!entry) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__,sizeof (*entry)); entry->buf =memblock_alloc (strlen (str_entry) +1 ,SMP_CACHE_BYTES ); +if (!entry->buf) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__,strlen (str_entry) +1 );strcpy (entry->buf, str_entry);list_add (&entry->next, &blacklisted_initcalls); }
Signature · 1 line
2.7.4
PATCH v2 17/21 init/main: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc() returns NULL.
The panic() format duplicates the one used by memblock itself and in order to avoid explosion with long parameters list replace open coded allocation size calculations with a local variable.
--- init/main.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
init/main.c +20 -6
@@ -373,12 +373,20 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }*/ static void __init setup_command_line (char *command_line) { - saved_command_line = -memblock_alloc (strlen (boot_command_line) +1 ,SMP_CACHE_BYTES ); - initcall_command_line = -memblock_alloc (strlen (boot_command_line) +1 ,SMP_CACHE_BYTES ); - static_command_line =memblock_alloc (strlen (command_line) +1 , -SMP_CACHE_BYTES ); +size_t len =strlen (boot_command_line) +1 ; + + saved_command_line =memblock_alloc (len,SMP_CACHE_BYTES ); +if (!saved_command_line) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, len); + + initcall_command_line =memblock_alloc (len,SMP_CACHE_BYTES ); +if (!initcall_command_line) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, len); + + static_command_line =memblock_alloc (len,SMP_CACHE_BYTES ); +if (!static_command_line) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, len); +strcpy (saved_command_line, boot_command_line);strcpy (static_command_line, command_line); }
@@ -773,8 +781,14 @@ static int __init initcall_blacklist(char *str)pr_debug ("blacklisting initcall %s\n" , str_entry); entry =memblock_alloc (sizeof (*entry),SMP_CACHE_BYTES ); +if (!entry) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__,sizeof (*entry)); entry->buf =memblock_alloc (strlen (str_entry) +1 ,SMP_CACHE_BYTES ); +if (!entry->buf) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__,strlen (str_entry) +1 );strcpy (entry->buf, str_entry);list_add (&entry->next, &blacklisted_initcalls); }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 18/21 swiotlb: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc() returns NULL.
The panic() format duplicates the one used by memblock itself and in order to avoid explosion with long parameters list replace open coded allocation size calculations with a local variable.
--- kernel/dma/swiotlb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
kernel/dma/swiotlb.c +13 -6
@@ -191,6 +191,7 @@ void __init swiotlb_update_mem_attributes(void)int __init swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose) {unsigned long i, bytes; +size_t alloc_size; bytes = nslabs <<IO_TLB_SHIFT ;
@@ -203,12 +204,18 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE * between io_tlb_start and io_tlb_end. */ - io_tlb_list =memblock_alloc ( -PAGE_ALIGN (io_tlb_nslabs *sizeof (int )), -PAGE_SIZE ); - io_tlb_orig_addr =memblock_alloc ( -PAGE_ALIGN (io_tlb_nslabs *sizeof (phys_addr_t)), -PAGE_SIZE ); + alloc_size =PAGE_ALIGN (io_tlb_nslabs *sizeof (int )); + io_tlb_list =memblock_alloc (alloc_size,PAGE_SIZE ); +if (!io_tlb_list) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, alloc_size,PAGE_SIZE ); + + alloc_size =PAGE_ALIGN (io_tlb_nslabs *sizeof (phys_addr_t)); + io_tlb_orig_addr =memblock_alloc (alloc_size,PAGE_SIZE ); +if (!io_tlb_orig_addr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, alloc_size,PAGE_SIZE ); +for (i =0 ; i < io_tlb_nslabs; i++) { io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ;
Signature · 1 line
2.7.4
PATCH v2 18/21 swiotlb: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd panic() calls if memblock_alloc() returns NULL.
The panic() format duplicates the one used by memblock itself and in order to avoid explosion with long parameters list replace open coded allocation size calculations with a local variable.
--- kernel/dma/swiotlb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
kernel/dma/swiotlb.c +13 -6
@@ -191,6 +191,7 @@ void __init swiotlb_update_mem_attributes(void)int __init swiotlb_init_with_tbl (char *tlb,unsigned long nslabs,int verbose) {unsigned long i, bytes; +size_t alloc_size; bytes = nslabs <<IO_TLB_SHIFT ;
@@ -203,12 +204,18 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE * between io_tlb_start and io_tlb_end. */ - io_tlb_list =memblock_alloc ( -PAGE_ALIGN (io_tlb_nslabs *sizeof (int )), -PAGE_SIZE ); - io_tlb_orig_addr =memblock_alloc ( -PAGE_ALIGN (io_tlb_nslabs *sizeof (phys_addr_t)), -PAGE_SIZE ); + alloc_size =PAGE_ALIGN (io_tlb_nslabs *sizeof (int )); + io_tlb_list =memblock_alloc (alloc_size,PAGE_SIZE ); +if (!io_tlb_list) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, alloc_size,PAGE_SIZE ); + + alloc_size =PAGE_ALIGN (io_tlb_nslabs *sizeof (phys_addr_t)); + io_tlb_orig_addr =memblock_alloc (alloc_size,PAGE_SIZE ); +if (!io_tlb_orig_addr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, alloc_size,PAGE_SIZE ); +for (i =0 ; i < io_tlb_nslabs; i++) { io_tlb_list[i] =IO_TLB_SEGSIZE -OFFSET (i,IO_TLB_SEGSIZE ); io_tlb_orig_addr[i] =INVALID_PHYS_ADDR ;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 19/21 treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd check for the return value of memblock_alloc*() functions and call panic() in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.
The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr = memblock_alloc(size, align);
+ if (!ptr)
+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,
size, align);
--- arch/alpha/kernel/core_cia.c | 3 +++ arch/alpha/kernel/core_marvel.c | 6 ++++++ arch/alpha/kernel/pci-noop.c | 13 +++++++++++-- arch/alpha/kernel/pci.c | 11 ++++++++++- arch/alpha/kernel/pci_iommu.c | 12 ++++++++++++ arch/arc/mm/highmem.c | 4 ++++ arch/arm/kernel/setup.c | 6 ++++++ arch/arm/mm/mmu.c | 14 +++++++++++++- arch/arm64/kernel/setup.c | 8 +++++--- arch/arm64/mm/kasan_init.c | 10 ++++++++++ arch/c6x/mm/dma-coherent.c | 4 ++++ arch/c6x/mm/init.c | 3 +++ arch/csky/mm/highmem.c | 5 +++++ arch/h8300/mm/init.c | 3 +++ arch/m68k/atari/stram.c | 4 ++++ arch/m68k/mm/init.c | 3 +++ arch/m68k/mm/mcfmmu.c | 6 ++++++ arch/m68k/mm/motorola.c | 9 +++++++++ arch/m68k/mm/sun3mmu.c | 6 ++++++ arch/m68k/sun3/sun3dvma.c | 3 +++ arch/microblaze/mm/init.c | 8 ++++++-- arch/mips/cavium-octeon/dma-octeon.c | 3 +++ arch/mips/kernel/setup.c | 3 +++ arch/mips/kernel/traps.c | 3 +++ arch/mips/mm/init.c | 5 +++++ arch/nds32/mm/init.c | 12 ++++++++++++ arch/openrisc/mm/ioremap.c | 8 ++++++-- arch/powerpc/kernel/dt_cpu_ftrs.c | 5 +++++ arch/powerpc/kernel/pci_32.c | 3 +++ arch/powerpc/kernel/setup-common.c | 3 +++ arch/powerpc/kernel/setup_64.c | 4 ++++ arch/powerpc/lib/alloc.c | 3 +++ arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/mmu_context_nohash.c | 9 +++++++++ arch/powerpc/mm/pgtable-book3e.c | 12 ++++++++++-- arch/powerpc/mm/pgtable-book3s64.c | 3 +++ arch/powerpc/mm/pgtable-radix.c | 9 ++++++++- arch/powerpc/mm/ppc_mmu_32.c | 3 +++ arch/powerpc/platforms/pasemi/iommu.c | 3 +++ arch/powerpc/platforms/powermac/nvram.c | 3 +++ arch/powerpc/platforms/powernv/opal.c | 3 +++ arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++++++ arch/powerpc/platforms/ps3/setup.c | 3 +++ arch/powerpc/sysdev/msi_bitmap.c | 3 +++ arch/s390/kernel/setup.c | 13 +++++++++++++ arch/s390/kernel/smp.c | 5 ++++- arch/s390/kernel/topology.c | 6 ++++++ arch/s390/numa/mode_emu.c | 3 +++ arch/s390/numa/numa.c | 6 +++++- arch/sh/mm/init.c | 6 ++++++ arch/sh/mm/numa.c | 4 ++++ arch/um/drivers/net_kern.c | 3 +++ arch/um/drivers/vector_kern.c | 3 +++ arch/um/kernel/initrd.c | 2 ++ arch/um/kernel/mem.c | 16 ++++++++++++++++ arch/unicore32/kernel/setup.c | 4 ++++ arch/unicore32/mm/mmu.c | 15 +++++++++++++-- arch/x86/kernel/acpi/boot.c | 3 +++ arch/x86/kernel/apic/io_apic.c | 5 +++++ arch/x86/kernel/e820.c | 3 +++ arch/x86/platform/olpc/olpc_dt.c | 3 +++ arch/x86/xen/p2m.c | 11 +++++++++-- arch/xtensa/mm/kasan_init.c | 4 ++++ arch/xtensa/mm/mmu.c | 3 +++ drivers/clk/ti/clk.c | 3 +++ drivers/macintosh/smu.c | 3 +++ drivers/of/fdt.c | 8 +++++++- drivers/of/unittest.c | 8 +++++++- drivers/xen/swiotlb-xen.c | 7 +++++-- kernel/power/snapshot.c | 3 +++ lib/cpumask.c | 3 +++ mm/kasan/init.c | 10 ++++++++-- mm/sparse.c | 19 +++++++++++++++++-- 73 files changed, 409 insertions(+), 28 deletions(-)
arch/alpha/kernel/core_cia.c +3 -0
@@ -332,6 +332,9 @@ cia_prepare_tbia_workaround(int window)/* Use minimal 1K map. */ ppte =memblock_alloc (CIA_BROKEN_TBIA_SIZE ,32768 ); +if (!ppte) +panic ("%s: Failed to allocate %u bytes align=0x%x\n" , + __func__,CIA_BROKEN_TBIA_SIZE ,32768 ); pte = (virt_to_phys (ppte) >> (PAGE_SHIFT -1 )) |1 ;for (i =0 ; i <CIA_BROKEN_TBIA_SIZE /sizeof (unsigned long ); ++i)
arch/alpha/kernel/core_marvel.c +6 -0
@@ -83,6 +83,9 @@ mk_resource_name(int pe, int port, char *str)sprintf (tmp,"PCI %s PE %d PORT %d" , str, pe, port); name =memblock_alloc (strlen (tmp) +1 ,SMP_CACHE_BYTES ); +if (!name) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +strlen (tmp) +1 );strcpy (name, tmp);return name;
@@ -118,6 +121,9 @@ alloc_io7(unsigned int pe) } io7 =memblock_alloc (sizeof (*io7),SMP_CACHE_BYTES ); +if (!io7) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*io7)); io7->pe = pe;raw_spin_lock_init (&io7->irq_lock);
arch/alpha/kernel/pci-noop.c +11 -2
@@ -34,6 +34,9 @@ alloc_pci_controller(void)struct pci_controller *hose; hose =memblock_alloc (sizeof (*hose),SMP_CACHE_BYTES ); +if (!hose) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*hose)); *hose_tail = hose; hose_tail = &hose->next;
@@ -44,7 +47,13 @@ alloc_pci_controller(void)struct resource *__init alloc_resource (void ) { -return memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); +void *ptr =memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); + +if (!ptr) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct resource )); + +return ptr; } SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
@@ -54,7 +63,7 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,/* from hose or from bus.devfn */ if (which &IOBASE_FROM_HOSE ) { -for (hose = hose_head; hose; hose = hose->next) +for (hose = hose_head; hose; hose = hose->next)if (hose->index == bus)break ;if (!hose)
arch/alpha/kernel/pci.c +10 -1
@@ -393,6 +393,9 @@ alloc_pci_controller(void)struct pci_controller *hose; hose =memblock_alloc (sizeof (*hose),SMP_CACHE_BYTES ); +if (!hose) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*hose)); *hose_tail = hose; hose_tail = &hose->next;
@@ -403,7 +406,13 @@ alloc_pci_controller(void)struct resource *__init alloc_resource (void ) { -return memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); +void *ptr =memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); + +if (!ptr) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct resource )); + +return ptr; }
arch/alpha/kernel/pci_iommu.c +12 -0
@@ -80,6 +80,9 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base," falling back to system-wide allocation\n" , __func__, nid); arena =memblock_alloc (sizeof (*arena),SMP_CACHE_BYTES ); +if (!arena) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*arena)); } arena->ptes =memblock_alloc_node (sizeof (*arena), align, nid);
@@ -88,12 +91,21 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base," falling back to system-wide allocation\n" , __func__, nid); arena->ptes =memblock_alloc (mem_size, align); +if (!arena->ptes) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, mem_size, align); }#else /* CONFIG_DISCONTIGMEM */ arena =memblock_alloc (sizeof (*arena),SMP_CACHE_BYTES ); +if (!arena) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*arena)); arena->ptes =memblock_alloc (mem_size, align); +if (!arena->ptes) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, mem_size, align);#endif /* CONFIG_DISCONTIGMEM */
arch/arc/mm/highmem.c +4 -0
@@ -124,6 +124,10 @@ static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr) pmd_k =pmd_offset (pud_k, kvaddr); pte_k = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte_k) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +pmd_populate_kernel (&init_mm, pmd_k, pte_k);return pte_k; }
arch/arm/kernel/setup.c +6 -0
@@ -867,6 +867,9 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) boot_alias_start =phys_to_idmap (start);if (arm_has_idmap_alias () && boot_alias_start !=IDMAP_INVALID_ADDR ) { res =memblock_alloc (sizeof (*res),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__,sizeof (*res)); res->name ="System RAM (boot alias)" ; res->start = boot_alias_start; res->end =phys_to_idmap (end);
@@ -875,6 +878,9 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) } res =memblock_alloc (sizeof (*res),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*res)); res->name ="System RAM" ; res->start = start; res->end = end;
arch/arm/mm/mmu.c +13 -1
@@ -721,7 +721,13 @@ EXPORT_SYMBOL(phys_mem_access_prot);static void __init *early_alloc (unsigned long sz) { -return memblock_alloc (sz, sz); +void *ptr =memblock_alloc (sz, sz); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, sz, sz); + +return ptr; }static void *__init late_alloc (unsigned long sz)
@@ -994,6 +1000,9 @@ void __init iotable_init(struct map_desc *io_desc, int nr)return ; svm = memblock_alloc(sizeof(*svm) * nr, __alignof__(*svm)); +if (!svm) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__, sizeof(*svm) * nr, __alignof__(*svm));for (md = io_desc; nr; md++, nr--) {create_mapping (md);
@@ -1016,6 +1025,9 @@ void __init vm_reserve_area_early(unsigned long addr, unsigned long size,struct static_vm *svm; svm = memblock_alloc(sizeof(*svm), __alignof__(*svm)); +if (!svm) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__, sizeof(*svm), __alignof__(*svm)); vm = &svm->vm; vm->addr = (void *)addr;
arch/arm64/kernel/setup.c +5 -3
@@ -209,6 +209,7 @@ static void __init request_standard_resources(void)struct memblock_region *region;struct resource *res;unsigned long i =0 ; +size_t res_size; kernel_code.start =__pa_symbol (_text); kernel_code.end =__pa_symbol (__init_begin -1 );
@@ -216,9 +217,10 @@ static void __init request_standard_resources(void) kernel_data.end =__pa_symbol (_end -1 ); num_standard_resources = memblock.memory.cnt; - standard_resources =memblock_alloc_low (num_standard_resources * -sizeof (*standard_resources), -SMP_CACHE_BYTES ); + res_size = num_standard_resources *sizeof (*standard_resources); + standard_resources =memblock_alloc_low (res_size,SMP_CACHE_BYTES ); +if (!standard_resources) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, res_size);for_each_memblock (memory, region) { res = &standard_resources[i++];
arch/arm64/mm/kasan_init.c +10 -0
@@ -40,6 +40,11 @@ static phys_addr_t __init kasan_alloc_zeroed_page(int node)void *p =memblock_alloc_try_nid (PAGE_SIZE ,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_KASAN , node); +if (!p) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%llx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE , node, +__pa (MAX_DMA_ADDRESS )); +return __pa (p); }
@@ -48,6 +53,11 @@ static phys_addr_t __init kasan_alloc_raw_page(int node)void *p =memblock_alloc_try_nid_raw (PAGE_SIZE ,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_KASAN , node); +if (!p) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%llx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE , node, +__pa (MAX_DMA_ADDRESS )); +return __pa (p); }
arch/c6x/mm/dma-coherent.c +4 -0
@@ -138,6 +138,10 @@ void __init coherent_mem_init(phys_addr_t start, u32 size) dma_bitmap =memblock_alloc (BITS_TO_LONGS (dma_pages) *sizeof (long ),sizeof (long )); +if (!dma_bitmap) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__,BITS_TO_LONGS (dma_pages) *sizeof (long ), +sizeof (long )); } static void c6x_dma_sync(struct device *dev, phys_addr_t paddr, size_t size,
arch/c6x/mm/init.c +3 -0
@@ -40,6 +40,9 @@ void __init paging_init(void) empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up user data space
arch/csky/mm/highmem.c +5 -0
@@ -141,6 +141,11 @@ static void __init fixrange_init(unsigned long start, unsigned long end,for (; (k <PTRS_PER_PMD ) && (vaddr != end); pmd++, k++) {if (pmd_none (*pmd)) { pte = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE , +PAGE_SIZE ); +set_pmd (pmd,__pmd (__pa (pte)));BUG_ON (pte !=pte_offset_kernel (pmd,0 )); }
arch/h8300/mm/init.c +3 -0
@@ -68,6 +68,9 @@ void __init paging_init(void)* to a couple of allocated pages. */ empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up SFC/DFC registers (user data space).
arch/m68k/atari/stram.c +4 -0
@@ -97,6 +97,10 @@ void __init atari_stram_reserve_pages(void *start_mem)pr_debug ("atari_stram pool: kernel in ST-RAM, using alloc_bootmem!\n" ); stram_pool.start = (resource_size_t )memblock_alloc_low (pool_size,PAGE_SIZE ); +if (!stram_pool.start) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__, pool_size,PAGE_SIZE ); + stram_pool.end = stram_pool.start + pool_size -1 ;request_resource (&iomem_resource, &stram_pool); stram_virt_offset =0 ;
arch/m68k/mm/init.c +3 -0
@@ -94,6 +94,9 @@ void __init paging_init(void) high_memory = (void *) end_mem; empty_zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up SFC/DFC registers (user data space).
arch/m68k/mm/mcfmmu.c +6 -0
@@ -44,6 +44,9 @@ void __init paging_init(void)int i; empty_zero_page = (void *)memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); pg_dir = swapper_pg_dir;memset (swapper_pg_dir,0 ,sizeof (swapper_pg_dir));
@@ -51,6 +54,9 @@ void __init paging_init(void) size = num_pages *sizeof (pte_t); size = (size +PAGE_SIZE ) & ~(PAGE_SIZE -1 ); next_pgtable = (unsigned long )memblock_alloc (size,PAGE_SIZE ); +if (!next_pgtable) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size,PAGE_SIZE ); bootmem_end = (next_pgtable + size +PAGE_SIZE ) &PAGE_MASK ; pg_dir +=PAGE_OFFSET >>PGDIR_SHIFT ;
arch/m68k/mm/motorola.c +9 -0
@@ -55,6 +55,9 @@ static pte_t * __init kernel_page_table(void)pte_t *ptablep; ptablep = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!ptablep) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );clear_page (ptablep);__flush_page_to_ram (ptablep);
@@ -96,6 +99,9 @@ static pmd_t * __init kernel_ptr_table(void)if (((unsigned long )last_pgtable & ~PAGE_MASK ) ==0 ) { last_pgtable = (pmd_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!last_pgtable) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );clear_page (last_pgtable);__flush_page_to_ram (last_pgtable);
@@ -278,6 +284,9 @@ void __init paging_init(void)* to a couple of allocated pages */ empty_zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up SFC/DFC registers
arch/m68k/mm/sun3mmu.c +6 -0
@@ -46,6 +46,9 @@ void __init paging_init(void)unsigned long size; empty_zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); address =PAGE_OFFSET ; pg_dir = swapper_pg_dir;
@@ -56,6 +59,9 @@ void __init paging_init(void) size = (size +PAGE_SIZE ) & ~(PAGE_SIZE -1 ); next_pgtable = (unsigned long )memblock_alloc (size,PAGE_SIZE ); +if (!next_pgtable) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size,PAGE_SIZE ); bootmem_end = (next_pgtable + size +PAGE_SIZE ) &PAGE_MASK ;/* Map whole memory from PAGE_OFFSET (0x0E000000) */
arch/m68k/sun3/sun3dvma.c +3 -0
@@ -269,6 +269,9 @@ void __init dvma_init(void) iommu_use =memblock_alloc (IOMMU_TOTAL_ENTRIES *sizeof (unsigned long ),SMP_CACHE_BYTES ); +if (!iommu_use) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +IOMMU_TOTAL_ENTRIES *sizeof (unsigned long ));dvma_unmap_iommu (DVMA_START ,DVMA_SIZE );
arch/microblaze/mm/init.c +6 -2
@@ -374,10 +374,14 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) {void *p; -if (mem_init_done) +if (mem_init_done) { p =kzalloc (size, mask); -else + }else { p =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!p) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__, size); + }return p; }
arch/mips/cavium-octeon/dma-octeon.c +3 -0
@@ -245,6 +245,9 @@ void __init plat_swiotlb_setup(void) swiotlbsize = swiotlb_nslabs <<IO_TLB_SHIFT ; octeon_swiotlb =memblock_alloc_low (swiotlbsize,PAGE_SIZE ); +if (!octeon_swiotlb) +panic ("%s: Failed to allocate %zu bytes align=%lx\n" , + __func__, swiotlbsize,PAGE_SIZE );if (swiotlb_init_with_tbl (octeon_swiotlb, swiotlb_nslabs,1 ) == -ENOMEM )panic ("Cannot allocate SWIOTLB buffer" );
arch/mips/kernel/setup.c +3 -0
@@ -918,6 +918,9 @@ static void __init resource_init(void) end =HIGHMEM_START -1 ; res =memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct resource )); res->start = start; res->end = end;
arch/mips/kernel/traps.c +3 -0
@@ -2292,6 +2292,9 @@ void __init trap_init(void) ebase = (unsigned long )memblock_alloc (size,1 <<fls (size)); +if (!ebase) +panic ("%s: Failed to allocate %lu bytes align=0x%x\n" , + __func__, size,1 <<fls (size));/* * Try to ensure ebase resides in KSeg0 if possible.
arch/mips/mm/init.c +5 -0
@@ -245,6 +245,11 @@ void __init fixrange_init(unsigned long start, unsigned long end,if (pmd_none (*pmd)) { pte = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE , +PAGE_SIZE ); +set_pmd (pmd,__pmd ((unsigned long )pte));BUG_ON (pte !=pte_offset_kernel (pmd,0 )); }
arch/nds32/mm/init.c +12 -0
@@ -79,6 +79,9 @@ static void __init map_ram(void)/* Alloc one page for holding PTE's... */ pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );set_pmd (pme,__pmd (__pa (pte) + _PAGE_KERNEL_TABLE));/* Fill the newly allocated page with PTE'S */
@@ -111,6 +114,9 @@ static void __init fixedrange_init(void) pud =pud_offset (pgd, vaddr); pmd =pmd_offset (pud, vaddr); fixmap_pmd_p =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!fixmap_pmd_p) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );set_pmd (pmd,__pmd (__pa (fixmap_pmd_p) + _PAGE_KERNEL_TABLE));#ifdef CONFIG_HIGHMEM
@@ -123,6 +129,9 @@ static void __init fixedrange_init(void) pud =pud_offset (pgd, vaddr); pmd =pmd_offset (pud, vaddr); pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );set_pmd (pmd,__pmd (__pa (pte) + _PAGE_KERNEL_TABLE)); pkmap_page_table = pte;#endif /* CONFIG_HIGHMEM */
@@ -148,6 +157,9 @@ void __init paging_init(void)/* allocate space for empty_zero_page */ zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );zone_sizes_init (); empty_zero_page =virt_to_page (zero_page);
arch/openrisc/mm/ioremap.c +6 -2
@@ -122,10 +122,14 @@ pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm) {pte_t *pte; -if (likely (mem_init_done)) +if (likely (mem_init_done)) { pte = (pte_t *)get_zeroed_page (GFP_KERNEL ); -else + }else { pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); + }return pte; }
arch/powerpc/kernel/dt_cpu_ftrs.c +5 -0
@@ -1008,6 +1008,11 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const charof_scan_flat_dt_subnodes (node, count_cpufeatures_subnodes, &nr_dt_cpu_features); dt_cpu_features =memblock_alloc (sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features,PAGE_SIZE ); +if (!dt_cpu_features) +panic ("%s: Failed to allocate %zu bytes align=0x%lx\n" , + __func__, +sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features, +PAGE_SIZE );cpufeatures_setup_start (isa);
arch/powerpc/kernel/pci_32.c +3 -0
@@ -205,6 +205,9 @@ pci_create_OF_bus_map(void) of_prop =memblock_alloc (sizeof (struct property ) +256 ,SMP_CACHE_BYTES ); +if (!of_prop) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct property ) +256 ); dn =of_find_node_by_path ("/" );if (dn) {memset (of_prop,-1 ,sizeof (struct property ) +256 );
arch/powerpc/kernel/setup-common.c +3 -0
@@ -461,6 +461,9 @@ void __init smp_setup_cpu_maps(void) cpu_to_phys_id =memblock_alloc (nr_cpu_ids *sizeof (u32), __alignof__(u32 )); +if (!cpu_to_phys_id) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__, nr_cpu_ids *sizeof (u32), __alignof__(u32 ));for_each_node_by_type (dn,"cpu" ) {const __be32 *intserv;
arch/powerpc/kernel/setup_64.c +4 -0
@@ -931,6 +931,10 @@ static void __ref init_fallback_flush(void) l1d_flush_fallback_area =memblock_alloc_try_nid (l1d_size *2 , l1d_size,MEMBLOCK_LOW_LIMIT , limit,NUMA_NO_NODE ); +if (!l1d_flush_fallback_area) +panic ("%s: Failed to allocate %llu bytes align=0x%llx max_addr=%pa\n" , + __func__, l1d_size *2 , l1d_size, &limit); +for_each_possible_cpu (cpu) {struct paca_struct *paca = paca_ptrs[cpu];
arch/powerpc/lib/alloc.c +3 -0
@@ -15,6 +15,9 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) p =kzalloc (size, mask); else { p =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!p) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + size); }return p; }
arch/powerpc/mm/hash_utils_64.c +3 -0
@@ -915,6 +915,9 @@ static void __init htab_initialize(void) linear_map_hash_slots =memblock_alloc_try_nid ( linear_map_hash_count,1 ,MEMBLOCK_LOW_LIMIT , ppc64_rma_size,NUMA_NO_NODE ); +if (!linear_map_hash_slots) +panic ("%s: Failed to allocate %lu bytes max_addr=%pa\n" , + __func__, linear_map_hash_count, &ppc64_rma_size); }#endif /* CONFIG_DEBUG_PAGEALLOC */
arch/powerpc/mm/mmu_context_nohash.c +9 -0
@@ -461,10 +461,19 @@ void __init mmu_context_init(void)* Allocate the maps used by context management */ context_map =memblock_alloc (CTX_MAP_SIZE ,SMP_CACHE_BYTES ); +if (!context_map) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +CTX_MAP_SIZE ); context_mm =memblock_alloc (sizeof (void *) * (LAST_CONTEXT +1 ),SMP_CACHE_BYTES ); +if (!context_mm) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (void *) * (LAST_CONTEXT +1 ));#ifdef CONFIG_SMP stale_map[boot_cpuid] =memblock_alloc (CTX_MAP_SIZE ,SMP_CACHE_BYTES ); +if (!stale_map[boot_cpuid]) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +CTX_MAP_SIZE ); cpuhp_setup_state_nocalls(CPUHP_POWERPC_MMU_CTX_PREPARE, "powerpc/mmu/ctx:prepare",
arch/powerpc/mm/pgtable-book3e.c +10 -2
@@ -57,8 +57,16 @@ void vmemmap_remove_mapping(unsigned long start,static __ref void *early_alloc_pgtable (unsigned long size) { -return memblock_alloc_try_nid (size, size,MEMBLOCK_LOW_LIMIT , -__pa (MAX_DMA_ADDRESS ),NUMA_NO_NODE ); +void *ptr; + + ptr =memblock_alloc_try_nid (size, size,MEMBLOCK_LOW_LIMIT , +__pa (MAX_DMA_ADDRESS ),NUMA_NO_NODE ); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx max_addr=%lx\n" , + __func__, size, size,__pa (MAX_DMA_ADDRESS )); + +return ptr; }/*
arch/powerpc/mm/pgtable-book3s64.c +3 -0
@@ -197,6 +197,9 @@ void __init mmu_partition_table_init(void)BUILD_BUG_ON_MSG ((PATB_SIZE_SHIFT >36 ),"Partition table size too large." );/* Initialize the Partition Table with no entries */ partition_tb =memblock_alloc (patb_size, patb_size); +if (!partition_tb) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, patb_size, patb_size);/* * update partition table control register,
arch/powerpc/mm/pgtable-radix.c +8 -1
@@ -53,13 +53,20 @@ static __ref void *early_alloc_pgtable(unsigned long size, int nid, {phys_addr_t min_addr =MEMBLOCK_LOW_LIMIT ;phys_addr_t max_addr =MEMBLOCK_ALLOC_ANYWHERE ; +void *ptr;if (region_start) min_addr = region_start;if (region_end) max_addr = region_end; -return memblock_alloc_try_nid (size, size, min_addr, max_addr, nid); + ptr =memblock_alloc_try_nid (size, size, min_addr, max_addr, nid); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%pa max_addr=%pa\n" , + __func__, size, size, nid, &min_addr, &max_addr); + +return ptr; } static int early_map_kernel_page(unsigned long ea, unsigned long pa,
arch/powerpc/mm/ppc_mmu_32.c +3 -0
@@ -212,6 +212,9 @@ void __init MMU_init_hw(void)*/ if ( ppc_md.progress ) ppc_md.progress ("hash:find piece" ,0x322 ); Hash =memblock_alloc (Hash_size, Hash_size); +if (!Hash) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, Hash_size, Hash_size); _SDR1 =__pa (Hash) |SDR1_LOW_BITS ; Hash_end = (struct hash_pte *) ((unsigned long )Hash + Hash_size);
arch/powerpc/platforms/pasemi/iommu.c +3 -0
@@ -211,6 +211,9 @@ static int __init iob_init(struct device_node *dn) iob_l2_base =memblock_alloc_try_nid_raw (1UL <<21 ,1UL <<21 ,MEMBLOCK_LOW_LIMIT ,0x80000000 ,NUMA_NO_NODE ); +if (!iob_l2_base) +panic ("%s: Failed to allocate %lu bytes align=0x%lx max_addr=%x\n" , + __func__,1UL <<21 ,1UL <<21 ,0x80000000 );pr_info ("IOBMAP L2 allocated at: %p\n" , iob_l2_base);
arch/powerpc/platforms/powermac/nvram.c +3 -0
@@ -514,6 +514,9 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)return -EINVAL ; } nvram_image =memblock_alloc (NVRAM_SIZE ,SMP_CACHE_BYTES ); +if (!nvram_image) +panic ("%s: Failed to allocate %u bytes\n" , __func__, +NVRAM_SIZE ); nvram_data =ioremap (addr,NVRAM_SIZE *2 ); nvram_naddrs =1 ;/* Make sure we get the correct case */
arch/powerpc/platforms/powernv/opal.c +3 -0
@@ -172,6 +172,9 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node,* Allocate a buffer to hold the MC recoverable ranges. */ mc_recoverable_range =memblock_alloc (size, __alignof__(u64 )); +if (!mc_recoverable_range) +panic ("%s: Failed to allocate %u bytes align=0x%lx\n" , + __func__, size, __alignof__(u64 ));for (i =0 ; i < mc_recoverable_range_len; i++) { mc_recoverable_range[i].start_addr =
arch/powerpc/platforms/powernv/pci-ioda.c +8 -0
@@ -3727,6 +3727,9 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,pr_debug (" PHB-ID : 0x%016llx\n" , phb_id); phb =memblock_alloc (sizeof (*phb),SMP_CACHE_BYTES ); +if (!phb) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*phb));/* Allocate PCI controller */ phb->hose = hose =pcibios_alloc_controller (np);
@@ -3773,6 +3776,9 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, phb->diag_data_size =PNV_PCI_DIAG_BUF_SIZE ; phb->diag_data =memblock_alloc (phb->diag_data_size,SMP_CACHE_BYTES ); +if (!phb->diag_data) +panic ("%s: Failed to allocate %u bytes\n" , __func__, + phb->diag_data_size);/* Parse 32-bit and IO ranges (if any) */ pci_process_bridge_OF_ranges (hose, np, !hose->global_number);
@@ -3832,6 +3838,8 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, pemap_off = size; size += phb->ioda.total_pe_num *sizeof (struct pnv_ioda_pe ); aux =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!aux) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, size); phb->ioda.pe_alloc = aux; phb->ioda.m64_segmap = aux + m64map_off; phb->ioda.m32_segmap = aux + m32map_off;
arch/powerpc/platforms/ps3/setup.c +3 -0
@@ -127,6 +127,9 @@ static void __init prealloc(struct ps3_prealloc *p)return ; p->address =memblock_alloc (p->size, p->align); +if (!p->address) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, p->size, p->align);printk (KERN_INFO "%s: %lu bytes at %p\n" , p->name, p->size, p->address);
arch/powerpc/sysdev/msi_bitmap.c +3 -0
@@ -129,6 +129,9 @@ int __ref msi_bitmap_alloc(struct msi_bitmap *bmp, unsigned int irq_count, bmp->bitmap =kzalloc (size,GFP_KERNEL ); else { bmp->bitmap =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!bmp->bitmap) +panic ("%s: Failed to allocate %u bytes\n" , __func__, + size);/* the bitmap won't be freed from memblock allocator */ kmemleak_not_leak (bmp->bitmap); }
arch/s390/kernel/setup.c +13 -0
@@ -378,6 +378,10 @@ static void __init setup_lowcore(void)*/ BUILD_BUG_ON (sizeof (struct lowcore ) !=LC_PAGES *PAGE_SIZE ); lc =memblock_alloc_low (sizeof (*lc),sizeof (*lc)); +if (!lc) +panic ("%s: Failed to allocate %zu bytes align=%zx\n" , + __func__,sizeof (*lc),sizeof (*lc)); + lc->restart_psw.mask =PSW_KERNEL_BITS ; lc->restart_psw.addr = (unsigned long ) restart_int_handler; lc->external_new_psw.mask = PSW_KERNEL_BITS |
@@ -422,6 +426,9 @@ static void __init setup_lowcore(void)* all CPUs in cast *one* of them does a PSW restart. */ restart_stack =memblock_alloc (THREAD_SIZE ,THREAD_SIZE ); +if (!restart_stack) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,THREAD_SIZE ,THREAD_SIZE ); restart_stack +=STACK_INIT_OFFSET ;/*
@@ -488,6 +495,9 @@ static void __init setup_resources(void)for_each_memblock (memory, reg) { res =memblock_alloc (sizeof (*res),8 ); +if (!res) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*res),8 ); res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; res->name ="System RAM" ;
@@ -502,6 +512,9 @@ static void __init setup_resources(void)continue ;if (std_res->end > res->end) { sub_res =memblock_alloc (sizeof (*sub_res),8 ); +if (!sub_res) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*sub_res),8 ); *sub_res = *std_res; sub_res->end = res->end; std_res->start = res->end +1 ;
arch/s390/kernel/smp.c +4 -1
@@ -653,7 +653,7 @@ void __init smp_save_dump_cpus(void)/* Allocate a page as dumping area for the store status sigps */ page =memblock_phys_alloc_range (PAGE_SIZE ,PAGE_SIZE ,0 ,1UL <<31 );if (!page) -panic ("ERROR: Failed to allocate %x bytes below %lx\n" , +panic ("ERROR: Failed to allocate %lx bytes below %lx\n" ,PAGE_SIZE ,1UL <<31 );/* Set multi-threading state to the previous system. */
@@ -765,6 +765,9 @@ void __init smp_detect_cpus(void)/* Get CPU information */ info =memblock_alloc (sizeof (*info),8 ); +if (!info) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*info),8 );smp_get_core_info (info,1 );/* Find boot CPU type */ if (sclp.has_core_type) {
arch/s390/kernel/topology.c +6 -0
@@ -520,6 +520,9 @@ static void __init alloc_masks(struct sysinfo_15_1_x *info, nr_masks =max (nr_masks,1 );for (i =0 ; i < nr_masks; i++) { mask->next =memblock_alloc (sizeof (*mask->next),8 ); +if (!mask->next) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*mask->next),8 ); mask = mask->next; } }
@@ -538,6 +541,9 @@ void __init topology_init_early(void)if (!MACHINE_HAS_TOPOLOGY ) goto out; tl_info =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!tl_info) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); info = tl_info;store_topology (info); pr_info("The CPU configuration topology of the machine is: %d %d %d %d %d %d / %d\n",
arch/s390/numa/mode_emu.c +3 -0
@@ -313,6 +313,9 @@ static void __ref create_core_to_node_map(void)int i; emu_cores =memblock_alloc (sizeof (*emu_cores),8 ); +if (!emu_cores) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*emu_cores),8 );for (i =0 ; i <ARRAY_SIZE (emu_cores->to_node_id); i++) emu_cores->to_node_id[i] =NODE_ID_FREE ; }
arch/s390/numa/numa.c +5 -1
@@ -92,8 +92,12 @@ static void __init numa_setup_memory(void) }while (cur_base < end_of_dram);/* Allocate and fill out node_data */ -for (nid =0 ; nid <MAX_NUMNODES ; nid++) +for (nid =0 ; nid <MAX_NUMNODES ; nid++) {NODE_DATA (nid) =memblock_alloc (sizeof (pg_data_t),8 ); +if (!NODE_DATA (nid)) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (pg_data_t),8 ); + }for_each_online_node (nid) {unsigned long start_pfn, end_pfn;
arch/sh/mm/init.c +6 -0
@@ -128,6 +128,9 @@ static pmd_t * __init one_md_table_init(pud_t *pud)pmd_t *pmd; pmd =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pmd) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );pud_populate (&init_mm, pud, pmd);BUG_ON (pmd !=pmd_offset (pud,0 )); }
@@ -141,6 +144,9 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)pte_t *pte; pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );pmd_populate_kernel (&init_mm, pmd, pte);BUG_ON (pte !=pte_offset_kernel (pmd,0 )); }
arch/sh/mm/numa.c +4 -0
@@ -43,6 +43,10 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)/* Node-local pgdat */ NODE_DATA (nid) =memblock_alloc_node (sizeof (struct pglist_data ),SMP_CACHE_BYTES , nid); +if (!NODE_DATA (nid)) +panic ("%s: Failed to allocate %zu bytes align=0x%x nid=%d\n" , + __func__,sizeof (struct pglist_data ),SMP_CACHE_BYTES , + nid);NODE_DATA (nid)->node_start_pfn = start_pfn;NODE_DATA (nid)->node_spanned_pages = end_pfn - start_pfn;
arch/um/drivers/net_kern.c +3 -0
@@ -649,6 +649,9 @@ static int __init eth_setup(char *str) } new =memblock_alloc (sizeof (*new),SMP_CACHE_BYTES ); +if (!new) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*new));INIT_LIST_HEAD (&new->list); new->index = n;
arch/um/drivers/vector_kern.c +3 -0
@@ -1576,6 +1576,9 @@ static int __init vector_setup(char *str)return 1 ; } new =memblock_alloc (sizeof (*new),SMP_CACHE_BYTES ); +if (!new) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*new));INIT_LIST_HEAD (&new->list); new->unit = n; new->arguments = str;
arch/um/kernel/initrd.c +2 -0
@@ -37,6 +37,8 @@ int __init read_initrd(void) } area =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!area) +panic ("%s: Failed to allocate %llu bytes\n" , __func__, size);if (load_initrd (initrd, area, size) ==-1 )return 0 ;
arch/um/kernel/mem.c +16 -0
@@ -66,6 +66,10 @@ static void __init one_page_table_init(pmd_t *pmd)if (pmd_none (*pmd)) {pte_t *pte = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +set_pmd (pmd,__pmd (_KERNPG_TABLE + (unsigned long )__pa (pte)));if (pte !=pte_offset_kernel (pmd,0 ))
@@ -77,6 +81,10 @@ static void __init one_md_table_init(pud_t *pud) {#ifdef CONFIG_3_LEVEL_PGTABLES pmd_t *pmd_table = (pmd_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pmd_table) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +set_pud (pud,__pud (_KERNPG_TABLE + (unsigned long )__pa (pmd_table)));if (pmd_table !=pmd_offset (pud,0 ))BUG ();
@@ -126,6 +134,10 @@ static void __init fixaddr_user_init( void)fixrange_init (FIXADDR_USER_START ,FIXADDR_USER_END , swapper_pg_dir); v = (unsigned long )memblock_alloc_low (size,PAGE_SIZE ); +if (!v) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__, size,PAGE_SIZE ); +memcpy ((void *) v , (void *)FIXADDR_USER_START , size); p =__pa (v); for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
@@ -146,6 +158,10 @@ void __init paging_init(void) empty_zero_page = (unsigned long *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +for (i =0 ; i <ARRAY_SIZE (zones_size); i++) zones_size[i] =0 ;
arch/unicore32/kernel/setup.c +4 -0
@@ -207,6 +207,10 @@ request_standard_resources(struct meminfo *mi)continue ; res =memblock_alloc_low (sizeof (*res),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes align=%x\n" , + __func__,sizeof (*res),SMP_CACHE_BYTES ); + res->name ="System RAM" ; res->start = mi->bank[i].start; res->end = mi->bank[i].start + mi->bank[i].size -1 ;
arch/unicore32/mm/mmu.c +13 -2
@@ -145,8 +145,13 @@ static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot) {if (pmd_none (*pmd)) { -pte_t *pte =memblock_alloc (PTRS_PER_PTE *sizeof (pte_t), -PTRS_PER_PTE *sizeof (pte_t)); +size_t size =PTRS_PER_PTE *sizeof (pte_t); +pte_t *pte =memblock_alloc (size, size); + +if (!pte) +panic ("%s: Failed to allocate %zu bytes align=%zx\n" , + __func__, size, size); +__pmd_populate (pmd,__pa (pte) | prot); }BUG_ON (pmd_bad (*pmd));
@@ -349,6 +354,9 @@ static void __init devicemaps_init(void)* Allocate the vector page early. */ vectors =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!vectors) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );for (addr =VMALLOC_END ; addr; addr +=PGDIR_SIZE )pmd_clear (pmd_off_k (addr));
@@ -426,6 +434,9 @@ void __init paging_init(void)/* allocate the zero page. */ zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );bootmem_init ();
arch/x86/kernel/acpi/boot.c +3 -0
@@ -935,6 +935,9 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)#define HPET_RESOURCE_NAME_SIZE 9 hpet_res =memblock_alloc (sizeof (*hpet_res) +HPET_RESOURCE_NAME_SIZE ,SMP_CACHE_BYTES ); +if (!hpet_res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*hpet_res) +HPET_RESOURCE_NAME_SIZE ); hpet_res->name = (void *)&hpet_res[1 ]; hpet_res->flags =IORESOURCE_MEM ;
arch/x86/kernel/apic/io_apic.c +5 -0
@@ -2579,6 +2579,8 @@ static struct resource * __init ioapic_setup_resources(void) n *= nr_ioapics; mem =memblock_alloc (n,SMP_CACHE_BYTES ); +if (!mem) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, n); res = (void *)mem; mem +=sizeof (struct resource ) * nr_ioapics;
@@ -2623,6 +2625,9 @@ void __init io_apic_init_mappings(void)#endif ioapic_phys = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!ioapic_phys) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); ioapic_phys =__pa (ioapic_phys); }set_fixmap_nocache (idx, ioapic_phys);
arch/x86/kernel/e820.c +3 -0
@@ -1095,6 +1095,9 @@ void __init e820__reserve_resources(void) res =memblock_alloc (sizeof (*res) * e820_table->nr_entries,SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*res) * e820_table->nr_entries); e820_res = res;for (i =0 ; i < e820_table->nr_entries; i++) {
arch/x86/platform/olpc/olpc_dt.c +3 -0
@@ -141,6 +141,9 @@ void * __init prom_early_alloc(unsigned long size)* wasted bootmem) and hand off chunks of it to callers. */ res =memblock_alloc (chunk_size,SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, + chunk_size);BUG_ON (!res); prom_early_allocated += chunk_size;memset (res,0 , chunk_size);
arch/x86/xen/p2m.c +9 -2
@@ -181,8 +181,15 @@ static void p2m_init_identity(unsigned long *p2m, unsigned long pfn)static void *__ref alloc_p2m_page (void ) { -if (unlikely (!slab_is_available ())) -return memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (unlikely (!slab_is_available ())) { +void *ptr =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); + +return ptr; + }return (void *)__get_free_page (GFP_KERNEL ); }
arch/xtensa/mm/kasan_init.c +4 -0
@@ -45,6 +45,10 @@ static void __init populate(void *start, void *end)pmd_t *pmd =pmd_offset (pgd, vaddr);pte_t *pte =memblock_alloc (n_pages *sizeof (pte_t),PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %zu bytes align=0x%lx\n" , + __func__, n_pages *sizeof (pte_t),PAGE_SIZE ); +pr_debug ("%s: %p - %p\n" , __func__, start, end);for (i = j =0 ; i < n_pmds; ++i) {
arch/xtensa/mm/mmu.c +3 -0
@@ -32,6 +32,9 @@ static void * __init init_pmd(unsigned long vaddr, unsigned long n_pages) __func__, vaddr, n_pages); pte =memblock_alloc_low (n_pages *sizeof (pte_t),PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %zu bytes align=%lx\n" , + __func__, n_pages *sizeof (pte_t),PAGE_SIZE );for (i =0 ; i < n_pages; ++i)pte_clear (NULL ,0 , pte + i);
drivers/clk/ti/clk.c +3 -0
@@ -351,6 +351,9 @@ void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem)struct clk_iomap *io; io =memblock_alloc (sizeof (*io),SMP_CACHE_BYTES ); +if (!io) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*io)); io->mem = mem;
drivers/macintosh/smu.c +3 -0
@@ -493,6 +493,9 @@ int __init smu_init (void) } smu =memblock_alloc (sizeof (struct smu_device ),SMP_CACHE_BYTES ); +if (!smu) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct smu_device ));spin_lock_init (&smu->lock);INIT_LIST_HEAD (&smu->cmd_list);
drivers/of/fdt.c +7 -1
@@ -1185,7 +1185,13 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,static void *__init early_init_dt_alloc_memory_arch (u64 size,u64 align) { -return memblock_alloc (size, align); +void *ptr =memblock_alloc (size, align); + +if (!ptr) +panic ("%s: Failed to allocate %llu bytes align=0x%llx\n" , + __func__, size, align); + +return ptr; }bool __init early_init_dt_verify (void *params)
drivers/of/unittest.c +7 -1
@@ -2234,7 +2234,13 @@ static struct device_node *overlay_base_root;static void *__init dt_alloc_memory (u64 size,u64 align) { -return memblock_alloc (size, align); +void *ptr =memblock_alloc (size, align); + +if (!ptr) +panic ("%s: Failed to allocate %llu bytes align=0x%llx\n" , + __func__, size, align); + +return ptr; }/*
drivers/xen/swiotlb-xen.c +5 -2
@@ -214,10 +214,13 @@ int __ref xen_swiotlb_init(int verbose, bool early)/* * Get IO TLB memory from any location. */ -if (early) +if (early) { xen_io_tlb_start =memblock_alloc (PAGE_ALIGN (bytes),PAGE_SIZE ); -else { +if (!xen_io_tlb_start) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_ALIGN (bytes),PAGE_SIZE ); + }else {#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)while ((SLABS_PER_PAGE << order) >IO_TLB_MIN_SLABS ) {
kernel/power/snapshot.c +3 -0
@@ -965,6 +965,9 @@ void __init __register_nosave_region(unsigned long start_pfn,/* This allocation cannot fail */ region =memblock_alloc (sizeof (struct nosave_region ),SMP_CACHE_BYTES ); +if (!region) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct nosave_region )); } region->start_pfn = start_pfn; region->end_pfn = end_pfn;
lib/cpumask.c +3 -0
@@ -165,6 +165,9 @@ EXPORT_SYMBOL(zalloc_cpumask_var);void __init alloc_bootmem_cpumask_var (cpumask_var_t *mask) { *mask =memblock_alloc (cpumask_size (),SMP_CACHE_BYTES ); +if (!*mask) +panic ("%s: Failed to allocate %u bytes\n" , __func__, +cpumask_size ()); }/**
mm/kasan/init.c +8 -2
@@ -83,8 +83,14 @@ static inline bool kasan_early_shadow_page_entry(pte_t pte)static __init void *early_alloc (size_t size,int node) { -return memblock_alloc_try_nid (size, size,__pa (MAX_DMA_ADDRESS ), -MEMBLOCK_ALLOC_ACCESSIBLE , node); +void *ptr =memblock_alloc_try_nid (size, size,__pa (MAX_DMA_ADDRESS ), +MEMBLOCK_ALLOC_ACCESSIBLE , node); + +if (!ptr) +panic ("%s: Failed to allocate %zu bytes align=%zx nid=%d from=%llx\n" , + __func__, size, size, node, (u64 )__pa (MAX_DMA_ADDRESS )); + +return ptr; } static void __ref zero_pte_populate(pmd_t *pmd, unsigned long addr,
mm/sparse.c +17 -2
@@ -65,11 +65,15 @@ static noinline struct mem_section __ref *sparse_index_alloc(int nid)unsigned long array_size =SECTIONS_PER_ROOT *sizeof (struct mem_section ); -if (slab_is_available ()) +if (slab_is_available ()) { section =kzalloc_node (array_size,GFP_KERNEL , nid); -else + }else { section =memblock_alloc_node (array_size,SMP_CACHE_BYTES , nid); +if (!section) +panic ("%s: Failed to allocate %lu bytes nid=%d\n" , + __func__, array_size, nid); + }return section; }
@@ -218,6 +222,9 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) size =sizeof (struct mem_section *) *NR_SECTION_ROOTS ; align =1 << (INTERNODE_CACHE_SHIFT ); mem_section =memblock_alloc (size, align); +if (!mem_section) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size, align); }#endif
@@ -411,6 +418,10 @@ struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid, map =memblock_alloc_try_nid (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!map) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); + return map; }#endif /* !CONFIG_SPARSEMEM_VMEMMAP */
@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); + sparsemap_buf_end = sparsemap_buf + size; }
Signature · 1 line
2.7.4
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
Quoted 16 lines · Mike Rapoport
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n",__func__,
size, align);
Quoted 8 lines
Signed-off-by Mike Rapoport <[email protected]>arch/m68k/atari/stram.c | 4 ++++ arch/m68k/mm/init.c | 3 +++ arch/m68k/mm/mcfmmu.c | 6 ++++++ arch/m68k/mm/motorola.c | 9 +++++++++ arch/m68k/mm/sun3mmu.c | 6 ++++++ arch/m68k/sun3/sun3dvma.c | 3 +++
For m68k:
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportQuoted 16 lines · Mike Rapoport
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n",__func__,
size, align);
Quoted 8 lines
Signed-off-by Mike Rapoport <[email protected]>arch/m68k/atari/stram.c | 4 ++++ arch/m68k/mm/init.c | 3 +++ arch/m68k/mm/mcfmmu.c | 6 ++++++ arch/m68k/mm/motorola.c | 9 +++++++++ arch/m68k/mm/sun3mmu.c | 6 ++++++ arch/m68k/sun3/sun3dvma.c | 3 +++
For m68k:
Gr{oetje,eeting}s,
Geert
Signature · 10 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportQuoted 82 lines · Mike Rapoport
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen--- arch/alpha/kernel/core_cia.c | 3 +++ arch/alpha/kernel/core_marvel.c | 6 ++++++ arch/alpha/kernel/pci-noop.c | 13 +++++++++++-- arch/alpha/kernel/pci.c | 11 ++++++++++- arch/alpha/kernel/pci_iommu.c | 12 ++++++++++++ arch/arc/mm/highmem.c | 4 ++++ arch/arm/kernel/setup.c | 6 ++++++ arch/arm/mm/mmu.c | 14 +++++++++++++- arch/arm64/kernel/setup.c | 8 +++++--- arch/arm64/mm/kasan_init.c | 10 ++++++++++ arch/c6x/mm/dma-coherent.c | 4 ++++ arch/c6x/mm/init.c | 3 +++ arch/csky/mm/highmem.c | 5 +++++ arch/h8300/mm/init.c | 3 +++ arch/m68k/atari/stram.c | 4 ++++ arch/m68k/mm/init.c | 3 +++ arch/m68k/mm/mcfmmu.c | 6 ++++++ arch/m68k/mm/motorola.c | 9 +++++++++ arch/m68k/mm/sun3mmu.c | 6 ++++++ arch/m68k/sun3/sun3dvma.c | 3 +++ arch/microblaze/mm/init.c | 8 ++++++-- arch/mips/cavium-octeon/dma-octeon.c | 3 +++ arch/mips/kernel/setup.c | 3 +++ arch/mips/kernel/traps.c | 3 +++ arch/mips/mm/init.c | 5 +++++ arch/nds32/mm/init.c | 12 ++++++++++++ arch/openrisc/mm/ioremap.c | 8 ++++++-- arch/powerpc/kernel/dt_cpu_ftrs.c | 5 +++++ arch/powerpc/kernel/pci_32.c | 3 +++ arch/powerpc/kernel/setup-common.c | 3 +++ arch/powerpc/kernel/setup_64.c | 4 ++++ arch/powerpc/lib/alloc.c | 3 +++ arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/mmu_context_nohash.c | 9 +++++++++ arch/powerpc/mm/pgtable-book3e.c | 12 ++++++++++-- arch/powerpc/mm/pgtable-book3s64.c | 3 +++ arch/powerpc/mm/pgtable-radix.c | 9 ++++++++- arch/powerpc/mm/ppc_mmu_32.c | 3 +++ arch/powerpc/platforms/pasemi/iommu.c | 3 +++ arch/powerpc/platforms/powermac/nvram.c | 3 +++ arch/powerpc/platforms/powernv/opal.c | 3 +++ arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++++++ arch/powerpc/platforms/ps3/setup.c | 3 +++ arch/powerpc/sysdev/msi_bitmap.c | 3 +++ arch/s390/kernel/setup.c | 13 +++++++++++++ arch/s390/kernel/smp.c | 5 ++++- arch/s390/kernel/topology.c | 6 ++++++ arch/s390/numa/mode_emu.c | 3 +++ arch/s390/numa/numa.c | 6 +++++- arch/sh/mm/init.c | 6 ++++++ arch/sh/mm/numa.c | 4 ++++ arch/um/drivers/net_kern.c | 3 +++ arch/um/drivers/vector_kern.c | 3 +++ arch/um/kernel/initrd.c | 2 ++ arch/um/kernel/mem.c | 16 ++++++++++++++++ arch/unicore32/kernel/setup.c | 4 ++++ arch/unicore32/mm/mmu.c | 15 +++++++++++++-- arch/x86/kernel/acpi/boot.c | 3 +++ arch/x86/kernel/apic/io_apic.c | 5 +++++ arch/x86/kernel/e820.c | 3 +++
Quoted 8 lines
arch/x86/platform/olpc/olpc_dt.c | 3 +++ arch/x86/xen/p2m.c | 11 +++++++++-- arch/xtensa/mm/kasan_init.c | 4 ++++ arch/xtensa/mm/mmu.c | 3 +++ drivers/clk/ti/clk.c | 3 +++ drivers/macintosh/smu.c | 3 +++ drivers/of/fdt.c | 8 +++++++- drivers/of/unittest.c | 8 +++++++-
Quoted 6 lines
drivers/xen/swiotlb-xen.c | 7 +++++-- kernel/power/snapshot.c | 3 +++ lib/cpumask.c | 3 +++ mm/kasan/init.c | 10 ++++++++-- mm/sparse.c | 19 +++++++++++++++++-- 73 files changed, 409 insertions(+), 28 deletions(-)
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportQuoted 82 lines · Mike Rapoport
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen--- arch/alpha/kernel/core_cia.c | 3 +++ arch/alpha/kernel/core_marvel.c | 6 ++++++ arch/alpha/kernel/pci-noop.c | 13 +++++++++++-- arch/alpha/kernel/pci.c | 11 ++++++++++- arch/alpha/kernel/pci_iommu.c | 12 ++++++++++++ arch/arc/mm/highmem.c | 4 ++++ arch/arm/kernel/setup.c | 6 ++++++ arch/arm/mm/mmu.c | 14 +++++++++++++- arch/arm64/kernel/setup.c | 8 +++++--- arch/arm64/mm/kasan_init.c | 10 ++++++++++ arch/c6x/mm/dma-coherent.c | 4 ++++ arch/c6x/mm/init.c | 3 +++ arch/csky/mm/highmem.c | 5 +++++ arch/h8300/mm/init.c | 3 +++ arch/m68k/atari/stram.c | 4 ++++ arch/m68k/mm/init.c | 3 +++ arch/m68k/mm/mcfmmu.c | 6 ++++++ arch/m68k/mm/motorola.c | 9 +++++++++ arch/m68k/mm/sun3mmu.c | 6 ++++++ arch/m68k/sun3/sun3dvma.c | 3 +++ arch/microblaze/mm/init.c | 8 ++++++-- arch/mips/cavium-octeon/dma-octeon.c | 3 +++ arch/mips/kernel/setup.c | 3 +++ arch/mips/kernel/traps.c | 3 +++ arch/mips/mm/init.c | 5 +++++ arch/nds32/mm/init.c | 12 ++++++++++++ arch/openrisc/mm/ioremap.c | 8 ++++++-- arch/powerpc/kernel/dt_cpu_ftrs.c | 5 +++++ arch/powerpc/kernel/pci_32.c | 3 +++ arch/powerpc/kernel/setup-common.c | 3 +++ arch/powerpc/kernel/setup_64.c | 4 ++++ arch/powerpc/lib/alloc.c | 3 +++ arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/mmu_context_nohash.c | 9 +++++++++ arch/powerpc/mm/pgtable-book3e.c | 12 ++++++++++-- arch/powerpc/mm/pgtable-book3s64.c | 3 +++ arch/powerpc/mm/pgtable-radix.c | 9 ++++++++- arch/powerpc/mm/ppc_mmu_32.c | 3 +++ arch/powerpc/platforms/pasemi/iommu.c | 3 +++ arch/powerpc/platforms/powermac/nvram.c | 3 +++ arch/powerpc/platforms/powernv/opal.c | 3 +++ arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++++++ arch/powerpc/platforms/ps3/setup.c | 3 +++ arch/powerpc/sysdev/msi_bitmap.c | 3 +++ arch/s390/kernel/setup.c | 13 +++++++++++++ arch/s390/kernel/smp.c | 5 ++++- arch/s390/kernel/topology.c | 6 ++++++ arch/s390/numa/mode_emu.c | 3 +++ arch/s390/numa/numa.c | 6 +++++- arch/sh/mm/init.c | 6 ++++++ arch/sh/mm/numa.c | 4 ++++ arch/um/drivers/net_kern.c | 3 +++ arch/um/drivers/vector_kern.c | 3 +++ arch/um/kernel/initrd.c | 2 ++ arch/um/kernel/mem.c | 16 ++++++++++++++++ arch/unicore32/kernel/setup.c | 4 ++++ arch/unicore32/mm/mmu.c | 15 +++++++++++++-- arch/x86/kernel/acpi/boot.c | 3 +++ arch/x86/kernel/apic/io_apic.c | 5 +++++ arch/x86/kernel/e820.c | 3 +++
Quoted 8 lines
arch/x86/platform/olpc/olpc_dt.c | 3 +++ arch/x86/xen/p2m.c | 11 +++++++++-- arch/xtensa/mm/kasan_init.c | 4 ++++ arch/xtensa/mm/mmu.c | 3 +++ drivers/clk/ti/clk.c | 3 +++ drivers/macintosh/smu.c | 3 +++ drivers/of/fdt.c | 8 +++++++- drivers/of/unittest.c | 8 +++++++-
Quoted 6 lines
drivers/xen/swiotlb-xen.c | 7 +++++-- kernel/power/snapshot.c | 3 +++ lib/cpumask.c | 3 +++ mm/kasan/init.c | 10 ++++++++-- mm/sparse.c | 19 +++++++++++++++++-- 73 files changed, 409 insertions(+), 28 deletions(-)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportLe 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0
[...]
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 442
Quoted 8 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); +
memblock_alloc_try_nid_raw() does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
Stephen Rothwell reports a boot failure due to this change.
Christophe
Quoted 4 lines
mm/sparse.c +0
-0sparsemap_buf_end = sparsemap_buf + size; }
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
Quoted 35 lines · Christophe Leroy
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
Quoted 11 lines
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 442
Quoted 8 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
"Does not panic" does not mean it always succeeds.
Quoted 1 line
Stephen Rothwell reports a boot failure due to this change.
Please see my reply on that thread.
Quoted 6 lines
Christophe
Quoted 3 lines
mm/sparse.c +0
-0sparsemap_buf_end = sparsemap_buf + size; }
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
Le 31/01/2019 à 07:41, Mike Rapoport a écrit :
Quoted 48 lines · Christophe Leroy
Quoted 35 lines
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
Quoted 11 lines
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 442
Quoted 8 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
Quoted 1 line
"Does not panic" does not mean it always succeeds.
I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a WARN_ON() would be enough there ?
Christophe
Quoted 12 lines
Quoted 2 lines
Stephen Rothwell reports a boot failure due to this change.
Please see my reply on that thread.
Quoted 6 lines
Christophe
Quoted 3 lines
mm/sparse.c +0
-0sparsemap_buf_end = sparsemap_buf + size; }
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
Le 31/01/2019 à 07:44, Christophe Leroy a écrit :
Quoted 53 lines
Le 31/01/2019 à 07:41, Mike Rapoport a écrit :
Quoted 50 lines · Christophe Leroy
Quoted 48 lines
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, size, align);Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
mm/sparse.c static void __init sparse_buffer_init(unsigned · line 444
Quoted 10 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid) memblock_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); + if (!sparsemap_buf) + panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n", + __func__, size, PAGE_SIZE, nid, __pa(MAX_DMA_ADDRESS)); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
Quoted 3 lines
Quoted 1 line
"Does not panic" does not mean it always succeeds.
I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a
WARN_ON()would be enough there ?
Looking more in details, it looks like everything is done to live with sparsemap_buf NULL, all functions using it check it so having it NULL shouldn't imply a panic I believe, see code below.
static void *sparsemap_buf __meminitdata;
static void *sparsemap_buf_end __meminitdata;
static void __init sparse_buffer_init(unsigned long size, int nid)
{
WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */
sparsemap_buf =
memblock_alloc_try_nid_raw(size, PAGE_SIZE,
__pa(MAX_DMA_ADDRESS),
MEMBLOCK_ALLOC_ACCESSIBLE, nid);
sparsemap_buf_end = sparsemap_buf + size;
}static void __init sparse_buffer_fini(void)
{
unsigned long size = sparsemap_buf_end - sparsemap_buf;
if (sparsemap_buf && size > 0)
memblock_free_early(__pa(sparsemap_buf), size);
sparsemap_buf = NULL;
}void * __meminit sparse_buffer_alloc(unsigned long size)
{
void *ptr = NULL;
if (sparsemap_buf) {
ptr = PTR_ALIGN(sparsemap_buf, size);
if (ptr + size > sparsemap_buf_end)
ptr = NULL;
else
sparsemap_buf = ptr + size;
}
return ptr;
}Christophe
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
Quoted 60 lines · Christophe Leroy
Le 31/01/2019 à 07:44, Christophe Leroy a écrit :
Quoted 57 lines
Le 31/01/2019 à 07:41, Mike Rapoport a écrit :
Quoted 53 lines · Christophe Leroy
Quoted 36 lines
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 23 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with
adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, size, align);Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
Quoted 14 lines
mm/sparse.c static void __init sparse_buffer_init(unsigned · line 444
Quoted 10 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid) memblock_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); + if (!sparsemap_buf) + panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n", + __func__, size, PAGE_SIZE, nid, __pa(MAX_DMA_ADDRESS)); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says:
Does not
zero allocated memory, does not panic if request cannot be satisfied.)."Does not panic" does not mean it always succeeds.
Quoted 7 lines
Quoted 3 lines
I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a
WARN_ON()would be enough there ?Looking more in details, it looks like everything is done to live with
sparsemap_bufNULL, all functions using it check it so having it NULL shouldn't imply a panic I believe, see code below.
You are right, I'm preparing the fix right now.
Quoted 39 lines
static void
*sparsemap_buf__meminitdata;
static void*sparsemap_buf_end__meminitdata;static void
__initsparse_buffer_init(unsigned long size, int nid){ WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */ sparsemap_buf = memblock_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); sparsemap_buf_end = sparsemap_buf + size; }static void
__initsparse_buffer_fini(void){ unsigned long size = sparsemap_buf_end - sparsemap_buf; if (sparsemap_buf && size > 0) memblock_free_early(__pa(sparsemap_buf), size); sparsemap_buf = NULL; }void *
__meminitsparse_buffer_alloc(unsigned long size){ void *ptr = NULL; if (sparsemap_buf) { ptr = PTR_ALIGN(sparsemap_buf, size); if (ptr + size > sparsemap_buf_end) ptr = NULL; else sparsemap_buf = ptr + size; } return ptr; }Christophe
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Christophe LeroyQuoted 60 lines · Christophe Leroy
Le 31/01/2019 à 07:44, Christophe Leroy a écrit :
Quoted 57 lines
Le 31/01/2019 à 07:41, Mike Rapoport a écrit :
Quoted 53 lines · Christophe Leroy
Quoted 36 lines
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 23 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with
adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, size, align);Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
Quoted 14 lines
mm/sparse.c static void __init sparse_buffer_init(unsigned · line 444
Quoted 10 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid) memblock_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); + if (!sparsemap_buf) + panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n", + __func__, size, PAGE_SIZE, nid, __pa(MAX_DMA_ADDRESS)); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says:
Does not
zero allocated memory, does not panic if request cannot be satisfied.)."Does not panic" does not mean it always succeeds.
Quoted 7 lines
Quoted 3 lines
I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a
WARN_ON()would be enough there ?Looking more in details, it looks like everything is done to live with
sparsemap_bufNULL, all functions using it check it so having it NULL shouldn't imply a panic I believe, see code below.
You are right, I'm preparing the fix right now.
Quoted 39 lines
static void
*sparsemap_buf__meminitdata;
static void*sparsemap_buf_end__meminitdata;static void
__initsparse_buffer_init(unsigned long size, int nid){ WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */ sparsemap_buf = memblock_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); sparsemap_buf_end = sparsemap_buf + size; }static void
__initsparse_buffer_fini(void){ unsigned long size = sparsemap_buf_end - sparsemap_buf; if (sparsemap_buf && size > 0) memblock_free_early(__pa(sparsemap_buf), size); sparsemap_buf = NULL; }void *
__meminitsparse_buffer_alloc(unsigned long size){ void *ptr = NULL; if (sparsemap_buf) { ptr = PTR_ALIGN(sparsemap_buf, size); if (ptr + size > sparsemap_buf_end) ptr = NULL; else sparsemap_buf = ptr + size; } return ptr; }Christophe
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Christophe LeroyLe 31/01/2019 à 07:44, Christophe Leroy a écrit :
Quoted 53 lines
Le 31/01/2019 à 07:41, Mike Rapoport a écrit :
Quoted 50 lines · Christophe Leroy
Quoted 48 lines
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, size, align);Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
mm/sparse.c static void __init sparse_buffer_init(unsigned · line 444
Quoted 10 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid) memblock_alloc_try_nid_raw(size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid); + if (!sparsemap_buf) + panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n", + __func__, size, PAGE_SIZE, nid, __pa(MAX_DMA_ADDRESS)); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
Quoted 3 lines
Quoted 1 line
"Does not panic" does not mean it always succeeds.
I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a
WARN_ON()would be enough there ?
Looking more in details, it looks like everything is done to live with sparsemap_buf NULL, all functions using it check it so having it NULL shouldn't imply a panic I believe, see code below.
static void *sparsemap_buf __meminitdata;
static void *sparsemap_buf_end __meminitdata;
static void __init sparse_buffer_init(unsigned long size, int nid)
{
WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */
sparsemap_buf =
memblock_alloc_try_nid_raw(size, PAGE_SIZE,
__pa(MAX_DMA_ADDRESS),
MEMBLOCK_ALLOC_ACCESSIBLE, nid);
sparsemap_buf_end = sparsemap_buf + size;
}static void __init sparse_buffer_fini(void)
{
unsigned long size = sparsemap_buf_end - sparsemap_buf;
if (sparsemap_buf && size > 0)
memblock_free_early(__pa(sparsemap_buf), size);
sparsemap_buf = NULL;
}void * __meminit sparse_buffer_alloc(unsigned long size)
{
void *ptr = NULL;
if (sparsemap_buf) {
ptr = PTR_ALIGN(sparsemap_buf, size);
if (ptr + size > sparsemap_buf_end)
ptr = NULL;
else
sparsemap_buf = ptr + size;
}
return ptr;
}Christophe
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportLe 31/01/2019 à 07:41, Mike Rapoport a écrit :
Quoted 48 lines · Christophe Leroy
Quoted 35 lines
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
Quoted 11 lines
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 442
Quoted 8 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
Quoted 1 line
"Does not panic" does not mean it always succeeds.
I agree, but at least here you are changing the behaviour by making it panic explicitly. Are we sure there are not cases where the system could just continue functionning ? Maybe a WARN_ON() would be enough there ?
Christophe
Quoted 12 lines
Quoted 2 lines
Stephen Rothwell reports a boot failure due to this change.
Please see my reply on that thread.
Quoted 6 lines
Christophe
Quoted 3 lines
mm/sparse.c +0
-0sparsemap_buf_end = sparsemap_buf + size; }
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Christophe LeroyQuoted 35 lines · Christophe Leroy
Le 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0[...]
Quoted 11 lines
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 442
Quoted 8 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); +
memblock_alloc_try_nid_raw()does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
"Does not panic" does not mean it always succeeds.
Quoted 1 line
Stephen Rothwell reports a boot failure due to this change.
Please see my reply on that thread.
Quoted 6 lines
Christophe
Quoted 3 lines
mm/sparse.c +0
-0sparsemap_buf_end = sparsemap_buf + size; }
Signature · 8 lines
Sincerely yours, Mike. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportLe 21/01/2019 à 09:04, Mike Rapoport a écrit :
Quoted 22 lines
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)(quoted diff) +1
-0+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,size, align);
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen---
[...]
Quoted 4 lines
mm/sparse.c +0
-0
[...]
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 442
Quoted 8 lines
mm/sparse.c +4
-0@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); +
memblock_alloc_try_nid_raw() does not panic (help explicitly says: Does not zero allocated memory, does not panic if request cannot be satisfied.).
Stephen Rothwell reports a boot failure due to this change.
Christophe
mm/sparse.c static void __init sparse_buffer_init(unsigned long size, int nid) · line 445
Quoted 4 lines
mm/sparse.c +0
-0sparsemap_buf_end = sparsemap_buf + size; }
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportQuoted 17 lines · Mike Rapoport
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n",__func__,
size, align);
Quoted 8 lines
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen--- arch/xtensa/mm/kasan_init.c | 4 ++++ arch/xtensa/mm/mmu.c | 3 +++
For xtensa:
Signature · 2 lines
Thanks. -- Max
Re: [PATCH v2 19/21] treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportQuoted 17 lines · Mike Rapoport
Add check for the return value of memblock_alloc*() functions and call
panic()in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr =memblock_alloc(size, align);
+ if (!ptr)
+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n",__func__,
size, align);
Quoted 8 lines
Signed-off-by Mike Rapoport <[email protected]>Reviewed-by Guo Ren <[email protected]> # c-skyReviewed-by Juergen Gross <[email protected]> # Xen--- arch/xtensa/mm/kasan_init.c | 4 ++++ arch/xtensa/mm/mmu.c | 3 +++
For xtensa:
Signature · 7 lines
Thanks. -- Max _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 19/21 treewide: add checks for the return value of memblock_alloc*()
In reply to Mike RapoportAdd check for the return value of memblock_alloc*() functions and call panic() in case of error.
The panic message repeats the one used by panicing memblock allocators with adjustment of parameters to include only relevant ones.
The replacement was mostly automated with semantic patches like the one below with manual massaging of format strings.
@@
expression ptr, size, align;
@@
ptr = memblock_alloc(size, align);
+ if (!ptr)
+ panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__,
size, align);
--- arch/alpha/kernel/core_cia.c | 3 +++ arch/alpha/kernel/core_marvel.c | 6 ++++++ arch/alpha/kernel/pci-noop.c | 13 +++++++++++-- arch/alpha/kernel/pci.c | 11 ++++++++++- arch/alpha/kernel/pci_iommu.c | 12 ++++++++++++ arch/arc/mm/highmem.c | 4 ++++ arch/arm/kernel/setup.c | 6 ++++++ arch/arm/mm/mmu.c | 14 +++++++++++++- arch/arm64/kernel/setup.c | 8 +++++--- arch/arm64/mm/kasan_init.c | 10 ++++++++++ arch/c6x/mm/dma-coherent.c | 4 ++++ arch/c6x/mm/init.c | 3 +++ arch/csky/mm/highmem.c | 5 +++++ arch/h8300/mm/init.c | 3 +++ arch/m68k/atari/stram.c | 4 ++++ arch/m68k/mm/init.c | 3 +++ arch/m68k/mm/mcfmmu.c | 6 ++++++ arch/m68k/mm/motorola.c | 9 +++++++++ arch/m68k/mm/sun3mmu.c | 6 ++++++ arch/m68k/sun3/sun3dvma.c | 3 +++ arch/microblaze/mm/init.c | 8 ++++++-- arch/mips/cavium-octeon/dma-octeon.c | 3 +++ arch/mips/kernel/setup.c | 3 +++ arch/mips/kernel/traps.c | 3 +++ arch/mips/mm/init.c | 5 +++++ arch/nds32/mm/init.c | 12 ++++++++++++ arch/openrisc/mm/ioremap.c | 8 ++++++-- arch/powerpc/kernel/dt_cpu_ftrs.c | 5 +++++ arch/powerpc/kernel/pci_32.c | 3 +++ arch/powerpc/kernel/setup-common.c | 3 +++ arch/powerpc/kernel/setup_64.c | 4 ++++ arch/powerpc/lib/alloc.c | 3 +++ arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/mmu_context_nohash.c | 9 +++++++++ arch/powerpc/mm/pgtable-book3e.c | 12 ++++++++++-- arch/powerpc/mm/pgtable-book3s64.c | 3 +++ arch/powerpc/mm/pgtable-radix.c | 9 ++++++++- arch/powerpc/mm/ppc_mmu_32.c | 3 +++ arch/powerpc/platforms/pasemi/iommu.c | 3 +++ arch/powerpc/platforms/powermac/nvram.c | 3 +++ arch/powerpc/platforms/powernv/opal.c | 3 +++ arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++++++ arch/powerpc/platforms/ps3/setup.c | 3 +++ arch/powerpc/sysdev/msi_bitmap.c | 3 +++ arch/s390/kernel/setup.c | 13 +++++++++++++ arch/s390/kernel/smp.c | 5 ++++- arch/s390/kernel/topology.c | 6 ++++++ arch/s390/numa/mode_emu.c | 3 +++ arch/s390/numa/numa.c | 6 +++++- arch/sh/mm/init.c | 6 ++++++ arch/sh/mm/numa.c | 4 ++++ arch/um/drivers/net_kern.c | 3 +++ arch/um/drivers/vector_kern.c | 3 +++ arch/um/kernel/initrd.c | 2 ++ arch/um/kernel/mem.c | 16 ++++++++++++++++ arch/unicore32/kernel/setup.c | 4 ++++ arch/unicore32/mm/mmu.c | 15 +++++++++++++-- arch/x86/kernel/acpi/boot.c | 3 +++ arch/x86/kernel/apic/io_apic.c | 5 +++++ arch/x86/kernel/e820.c | 3 +++ arch/x86/platform/olpc/olpc_dt.c | 3 +++ arch/x86/xen/p2m.c | 11 +++++++++-- arch/xtensa/mm/kasan_init.c | 4 ++++ arch/xtensa/mm/mmu.c | 3 +++ drivers/clk/ti/clk.c | 3 +++ drivers/macintosh/smu.c | 3 +++ drivers/of/fdt.c | 8 +++++++- drivers/of/unittest.c | 8 +++++++- drivers/xen/swiotlb-xen.c | 7 +++++-- kernel/power/snapshot.c | 3 +++ lib/cpumask.c | 3 +++ mm/kasan/init.c | 10 ++++++++-- mm/sparse.c | 19 +++++++++++++++++-- 73 files changed, 409 insertions(+), 28 deletions(-)
arch/alpha/kernel/core_cia.c +3 -0
@@ -332,6 +332,9 @@ cia_prepare_tbia_workaround(int window)/* Use minimal 1K map. */ ppte =memblock_alloc (CIA_BROKEN_TBIA_SIZE ,32768 ); +if (!ppte) +panic ("%s: Failed to allocate %u bytes align=0x%x\n" , + __func__,CIA_BROKEN_TBIA_SIZE ,32768 ); pte = (virt_to_phys (ppte) >> (PAGE_SHIFT -1 )) |1 ;for (i =0 ; i <CIA_BROKEN_TBIA_SIZE /sizeof (unsigned long ); ++i)
arch/alpha/kernel/core_marvel.c +6 -0
@@ -83,6 +83,9 @@ mk_resource_name(int pe, int port, char *str)sprintf (tmp,"PCI %s PE %d PORT %d" , str, pe, port); name =memblock_alloc (strlen (tmp) +1 ,SMP_CACHE_BYTES ); +if (!name) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +strlen (tmp) +1 );strcpy (name, tmp);return name;
@@ -118,6 +121,9 @@ alloc_io7(unsigned int pe) } io7 =memblock_alloc (sizeof (*io7),SMP_CACHE_BYTES ); +if (!io7) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*io7)); io7->pe = pe;raw_spin_lock_init (&io7->irq_lock);
arch/alpha/kernel/pci-noop.c +11 -2
@@ -34,6 +34,9 @@ alloc_pci_controller(void)struct pci_controller *hose; hose =memblock_alloc (sizeof (*hose),SMP_CACHE_BYTES ); +if (!hose) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*hose)); *hose_tail = hose; hose_tail = &hose->next;
@@ -44,7 +47,13 @@ alloc_pci_controller(void)struct resource *__init alloc_resource (void ) { -return memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); +void *ptr =memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); + +if (!ptr) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct resource )); + +return ptr; } SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
@@ -54,7 +63,7 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,/* from hose or from bus.devfn */ if (which &IOBASE_FROM_HOSE ) { -for (hose = hose_head; hose; hose = hose->next) +for (hose = hose_head; hose; hose = hose->next)if (hose->index == bus)break ;if (!hose)
arch/alpha/kernel/pci.c +10 -1
@@ -393,6 +393,9 @@ alloc_pci_controller(void)struct pci_controller *hose; hose =memblock_alloc (sizeof (*hose),SMP_CACHE_BYTES ); +if (!hose) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*hose)); *hose_tail = hose; hose_tail = &hose->next;
@@ -403,7 +406,13 @@ alloc_pci_controller(void)struct resource *__init alloc_resource (void ) { -return memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); +void *ptr =memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); + +if (!ptr) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct resource )); + +return ptr; }
arch/alpha/kernel/pci_iommu.c +12 -0
@@ -80,6 +80,9 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base," falling back to system-wide allocation\n" , __func__, nid); arena =memblock_alloc (sizeof (*arena),SMP_CACHE_BYTES ); +if (!arena) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*arena)); } arena->ptes =memblock_alloc_node (sizeof (*arena), align, nid);
@@ -88,12 +91,21 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base," falling back to system-wide allocation\n" , __func__, nid); arena->ptes =memblock_alloc (mem_size, align); +if (!arena->ptes) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, mem_size, align); }#else /* CONFIG_DISCONTIGMEM */ arena =memblock_alloc (sizeof (*arena),SMP_CACHE_BYTES ); +if (!arena) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*arena)); arena->ptes =memblock_alloc (mem_size, align); +if (!arena->ptes) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, mem_size, align);#endif /* CONFIG_DISCONTIGMEM */
arch/arc/mm/highmem.c +4 -0
@@ -124,6 +124,10 @@ static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr) pmd_k =pmd_offset (pud_k, kvaddr); pte_k = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte_k) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +pmd_populate_kernel (&init_mm, pmd_k, pte_k);return pte_k; }
arch/arm/kernel/setup.c +6 -0
@@ -867,6 +867,9 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) boot_alias_start =phys_to_idmap (start);if (arm_has_idmap_alias () && boot_alias_start !=IDMAP_INVALID_ADDR ) { res =memblock_alloc (sizeof (*res),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__,sizeof (*res)); res->name ="System RAM (boot alias)" ; res->start = boot_alias_start; res->end =phys_to_idmap (end);
@@ -875,6 +878,9 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) } res =memblock_alloc (sizeof (*res),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*res)); res->name ="System RAM" ; res->start = start; res->end = end;
arch/arm/mm/mmu.c +13 -1
@@ -721,7 +721,13 @@ EXPORT_SYMBOL(phys_mem_access_prot);static void __init *early_alloc (unsigned long sz) { -return memblock_alloc (sz, sz); +void *ptr =memblock_alloc (sz, sz); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, sz, sz); + +return ptr; }static void *__init late_alloc (unsigned long sz)
@@ -994,6 +1000,9 @@ void __init iotable_init(struct map_desc *io_desc, int nr)return ; svm = memblock_alloc(sizeof(*svm) * nr, __alignof__(*svm)); +if (!svm) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__, sizeof(*svm) * nr, __alignof__(*svm));for (md = io_desc; nr; md++, nr--) {create_mapping (md);
@@ -1016,6 +1025,9 @@ void __init vm_reserve_area_early(unsigned long addr, unsigned long size,struct static_vm *svm; svm = memblock_alloc(sizeof(*svm), __alignof__(*svm)); +if (!svm) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__, sizeof(*svm), __alignof__(*svm)); vm = &svm->vm; vm->addr = (void *)addr;
arch/arm64/kernel/setup.c +5 -3
@@ -209,6 +209,7 @@ static void __init request_standard_resources(void)struct memblock_region *region;struct resource *res;unsigned long i =0 ; +size_t res_size; kernel_code.start =__pa_symbol (_text); kernel_code.end =__pa_symbol (__init_begin -1 );
@@ -216,9 +217,10 @@ static void __init request_standard_resources(void) kernel_data.end =__pa_symbol (_end -1 ); num_standard_resources = memblock.memory.cnt; - standard_resources =memblock_alloc_low (num_standard_resources * -sizeof (*standard_resources), -SMP_CACHE_BYTES ); + res_size = num_standard_resources *sizeof (*standard_resources); + standard_resources =memblock_alloc_low (res_size,SMP_CACHE_BYTES ); +if (!standard_resources) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, res_size);for_each_memblock (memory, region) { res = &standard_resources[i++];
arch/arm64/mm/kasan_init.c +10 -0
@@ -40,6 +40,11 @@ static phys_addr_t __init kasan_alloc_zeroed_page(int node)void *p =memblock_alloc_try_nid (PAGE_SIZE ,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_KASAN , node); +if (!p) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%llx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE , node, +__pa (MAX_DMA_ADDRESS )); +return __pa (p); }
@@ -48,6 +53,11 @@ static phys_addr_t __init kasan_alloc_raw_page(int node)void *p =memblock_alloc_try_nid_raw (PAGE_SIZE ,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_KASAN , node); +if (!p) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%llx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE , node, +__pa (MAX_DMA_ADDRESS )); +return __pa (p); }
arch/c6x/mm/dma-coherent.c +4 -0
@@ -138,6 +138,10 @@ void __init coherent_mem_init(phys_addr_t start, u32 size) dma_bitmap =memblock_alloc (BITS_TO_LONGS (dma_pages) *sizeof (long ),sizeof (long )); +if (!dma_bitmap) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__,BITS_TO_LONGS (dma_pages) *sizeof (long ), +sizeof (long )); } static void c6x_dma_sync(struct device *dev, phys_addr_t paddr, size_t size,
arch/c6x/mm/init.c +3 -0
@@ -40,6 +40,9 @@ void __init paging_init(void) empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up user data space
arch/csky/mm/highmem.c +5 -0
@@ -141,6 +141,11 @@ static void __init fixrange_init(unsigned long start, unsigned long end,for (; (k <PTRS_PER_PMD ) && (vaddr != end); pmd++, k++) {if (pmd_none (*pmd)) { pte = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE , +PAGE_SIZE ); +set_pmd (pmd,__pmd (__pa (pte)));BUG_ON (pte !=pte_offset_kernel (pmd,0 )); }
arch/h8300/mm/init.c +3 -0
@@ -68,6 +68,9 @@ void __init paging_init(void)* to a couple of allocated pages. */ empty_zero_page = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up SFC/DFC registers (user data space).
arch/m68k/atari/stram.c +4 -0
@@ -97,6 +97,10 @@ void __init atari_stram_reserve_pages(void *start_mem)pr_debug ("atari_stram pool: kernel in ST-RAM, using alloc_bootmem!\n" ); stram_pool.start = (resource_size_t )memblock_alloc_low (pool_size,PAGE_SIZE ); +if (!stram_pool.start) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__, pool_size,PAGE_SIZE ); + stram_pool.end = stram_pool.start + pool_size -1 ;request_resource (&iomem_resource, &stram_pool); stram_virt_offset =0 ;
arch/m68k/mm/init.c +3 -0
@@ -94,6 +94,9 @@ void __init paging_init(void) high_memory = (void *) end_mem; empty_zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up SFC/DFC registers (user data space).
arch/m68k/mm/mcfmmu.c +6 -0
@@ -44,6 +44,9 @@ void __init paging_init(void)int i; empty_zero_page = (void *)memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); pg_dir = swapper_pg_dir;memset (swapper_pg_dir,0 ,sizeof (swapper_pg_dir));
@@ -51,6 +54,9 @@ void __init paging_init(void) size = num_pages *sizeof (pte_t); size = (size +PAGE_SIZE ) & ~(PAGE_SIZE -1 ); next_pgtable = (unsigned long )memblock_alloc (size,PAGE_SIZE ); +if (!next_pgtable) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size,PAGE_SIZE ); bootmem_end = (next_pgtable + size +PAGE_SIZE ) &PAGE_MASK ; pg_dir +=PAGE_OFFSET >>PGDIR_SHIFT ;
arch/m68k/mm/motorola.c +9 -0
@@ -55,6 +55,9 @@ static pte_t * __init kernel_page_table(void)pte_t *ptablep; ptablep = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!ptablep) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );clear_page (ptablep);__flush_page_to_ram (ptablep);
@@ -96,6 +99,9 @@ static pmd_t * __init kernel_ptr_table(void)if (((unsigned long )last_pgtable & ~PAGE_MASK ) ==0 ) { last_pgtable = (pmd_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!last_pgtable) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );clear_page (last_pgtable);__flush_page_to_ram (last_pgtable);
@@ -278,6 +284,9 @@ void __init paging_init(void)* to a couple of allocated pages */ empty_zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );/* * Set up SFC/DFC registers
arch/m68k/mm/sun3mmu.c +6 -0
@@ -46,6 +46,9 @@ void __init paging_init(void)unsigned long size; empty_zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); address =PAGE_OFFSET ; pg_dir = swapper_pg_dir;
@@ -56,6 +59,9 @@ void __init paging_init(void) size = (size +PAGE_SIZE ) & ~(PAGE_SIZE -1 ); next_pgtable = (unsigned long )memblock_alloc (size,PAGE_SIZE ); +if (!next_pgtable) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size,PAGE_SIZE ); bootmem_end = (next_pgtable + size +PAGE_SIZE ) &PAGE_MASK ;/* Map whole memory from PAGE_OFFSET (0x0E000000) */
arch/m68k/sun3/sun3dvma.c +3 -0
@@ -269,6 +269,9 @@ void __init dvma_init(void) iommu_use =memblock_alloc (IOMMU_TOTAL_ENTRIES *sizeof (unsigned long ),SMP_CACHE_BYTES ); +if (!iommu_use) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +IOMMU_TOTAL_ENTRIES *sizeof (unsigned long ));dvma_unmap_iommu (DVMA_START ,DVMA_SIZE );
arch/microblaze/mm/init.c +6 -2
@@ -374,10 +374,14 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) {void *p; -if (mem_init_done) +if (mem_init_done) { p =kzalloc (size, mask); -else + }else { p =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!p) +panic ("%s: Failed to allocate %zu bytes\n" , + __func__, size); + }return p; }
arch/mips/cavium-octeon/dma-octeon.c +3 -0
@@ -245,6 +245,9 @@ void __init plat_swiotlb_setup(void) swiotlbsize = swiotlb_nslabs <<IO_TLB_SHIFT ; octeon_swiotlb =memblock_alloc_low (swiotlbsize,PAGE_SIZE ); +if (!octeon_swiotlb) +panic ("%s: Failed to allocate %zu bytes align=%lx\n" , + __func__, swiotlbsize,PAGE_SIZE );if (swiotlb_init_with_tbl (octeon_swiotlb, swiotlb_nslabs,1 ) == -ENOMEM )panic ("Cannot allocate SWIOTLB buffer" );
arch/mips/kernel/setup.c +3 -0
@@ -918,6 +918,9 @@ static void __init resource_init(void) end =HIGHMEM_START -1 ; res =memblock_alloc (sizeof (struct resource ),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct resource )); res->start = start; res->end = end;
arch/mips/kernel/traps.c +3 -0
@@ -2292,6 +2292,9 @@ void __init trap_init(void) ebase = (unsigned long )memblock_alloc (size,1 <<fls (size)); +if (!ebase) +panic ("%s: Failed to allocate %lu bytes align=0x%x\n" , + __func__, size,1 <<fls (size));/* * Try to ensure ebase resides in KSeg0 if possible.
arch/mips/mm/init.c +5 -0
@@ -245,6 +245,11 @@ void __init fixrange_init(unsigned long start, unsigned long end,if (pmd_none (*pmd)) { pte = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE , +PAGE_SIZE ); +set_pmd (pmd,__pmd ((unsigned long )pte));BUG_ON (pte !=pte_offset_kernel (pmd,0 )); }
arch/nds32/mm/init.c +12 -0
@@ -79,6 +79,9 @@ static void __init map_ram(void)/* Alloc one page for holding PTE's... */ pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );set_pmd (pme,__pmd (__pa (pte) + _PAGE_KERNEL_TABLE));/* Fill the newly allocated page with PTE'S */
@@ -111,6 +114,9 @@ static void __init fixedrange_init(void) pud =pud_offset (pgd, vaddr); pmd =pmd_offset (pud, vaddr); fixmap_pmd_p =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!fixmap_pmd_p) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );set_pmd (pmd,__pmd (__pa (fixmap_pmd_p) + _PAGE_KERNEL_TABLE));#ifdef CONFIG_HIGHMEM
@@ -123,6 +129,9 @@ static void __init fixedrange_init(void) pud =pud_offset (pgd, vaddr); pmd =pmd_offset (pud, vaddr); pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );set_pmd (pmd,__pmd (__pa (pte) + _PAGE_KERNEL_TABLE)); pkmap_page_table = pte;#endif /* CONFIG_HIGHMEM */
@@ -148,6 +157,9 @@ void __init paging_init(void)/* allocate space for empty_zero_page */ zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );zone_sizes_init (); empty_zero_page =virt_to_page (zero_page);
arch/openrisc/mm/ioremap.c +6 -2
@@ -122,10 +122,14 @@ pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm) {pte_t *pte; -if (likely (mem_init_done)) +if (likely (mem_init_done)) { pte = (pte_t *)get_zeroed_page (GFP_KERNEL ); -else + }else { pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); + }return pte; }
arch/powerpc/kernel/dt_cpu_ftrs.c +5 -0
@@ -1008,6 +1008,11 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const charof_scan_flat_dt_subnodes (node, count_cpufeatures_subnodes, &nr_dt_cpu_features); dt_cpu_features =memblock_alloc (sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features,PAGE_SIZE ); +if (!dt_cpu_features) +panic ("%s: Failed to allocate %zu bytes align=0x%lx\n" , + __func__, +sizeof (struct dt_cpu_feature ) * nr_dt_cpu_features, +PAGE_SIZE );cpufeatures_setup_start (isa);
arch/powerpc/kernel/pci_32.c +3 -0
@@ -205,6 +205,9 @@ pci_create_OF_bus_map(void) of_prop =memblock_alloc (sizeof (struct property ) +256 ,SMP_CACHE_BYTES ); +if (!of_prop) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct property ) +256 ); dn =of_find_node_by_path ("/" );if (dn) {memset (of_prop,-1 ,sizeof (struct property ) +256 );
arch/powerpc/kernel/setup-common.c +3 -0
@@ -461,6 +461,9 @@ void __init smp_setup_cpu_maps(void) cpu_to_phys_id =memblock_alloc (nr_cpu_ids *sizeof (u32), __alignof__(u32 )); +if (!cpu_to_phys_id) +panic ("%s: Failed to allocate %zu bytes align=0x%zx\n" , + __func__, nr_cpu_ids *sizeof (u32), __alignof__(u32 ));for_each_node_by_type (dn,"cpu" ) {const __be32 *intserv;
arch/powerpc/kernel/setup_64.c +4 -0
@@ -931,6 +931,10 @@ static void __ref init_fallback_flush(void) l1d_flush_fallback_area =memblock_alloc_try_nid (l1d_size *2 , l1d_size,MEMBLOCK_LOW_LIMIT , limit,NUMA_NO_NODE ); +if (!l1d_flush_fallback_area) +panic ("%s: Failed to allocate %llu bytes align=0x%llx max_addr=%pa\n" , + __func__, l1d_size *2 , l1d_size, &limit); +for_each_possible_cpu (cpu) {struct paca_struct *paca = paca_ptrs[cpu];
arch/powerpc/lib/alloc.c +3 -0
@@ -15,6 +15,9 @@ void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) p =kzalloc (size, mask); else { p =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!p) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, + size); }return p; }
arch/powerpc/mm/hash_utils_64.c +3 -0
@@ -915,6 +915,9 @@ static void __init htab_initialize(void) linear_map_hash_slots =memblock_alloc_try_nid ( linear_map_hash_count,1 ,MEMBLOCK_LOW_LIMIT , ppc64_rma_size,NUMA_NO_NODE ); +if (!linear_map_hash_slots) +panic ("%s: Failed to allocate %lu bytes max_addr=%pa\n" , + __func__, linear_map_hash_count, &ppc64_rma_size); }#endif /* CONFIG_DEBUG_PAGEALLOC */
arch/powerpc/mm/mmu_context_nohash.c +9 -0
@@ -461,10 +461,19 @@ void __init mmu_context_init(void)* Allocate the maps used by context management */ context_map =memblock_alloc (CTX_MAP_SIZE ,SMP_CACHE_BYTES ); +if (!context_map) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +CTX_MAP_SIZE ); context_mm =memblock_alloc (sizeof (void *) * (LAST_CONTEXT +1 ),SMP_CACHE_BYTES ); +if (!context_mm) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (void *) * (LAST_CONTEXT +1 ));#ifdef CONFIG_SMP stale_map[boot_cpuid] =memblock_alloc (CTX_MAP_SIZE ,SMP_CACHE_BYTES ); +if (!stale_map[boot_cpuid]) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +CTX_MAP_SIZE ); cpuhp_setup_state_nocalls(CPUHP_POWERPC_MMU_CTX_PREPARE, "powerpc/mmu/ctx:prepare",
arch/powerpc/mm/pgtable-book3e.c +10 -2
@@ -57,8 +57,16 @@ void vmemmap_remove_mapping(unsigned long start,static __ref void *early_alloc_pgtable (unsigned long size) { -return memblock_alloc_try_nid (size, size,MEMBLOCK_LOW_LIMIT , -__pa (MAX_DMA_ADDRESS ),NUMA_NO_NODE ); +void *ptr; + + ptr =memblock_alloc_try_nid (size, size,MEMBLOCK_LOW_LIMIT , +__pa (MAX_DMA_ADDRESS ),NUMA_NO_NODE ); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx max_addr=%lx\n" , + __func__, size, size,__pa (MAX_DMA_ADDRESS )); + +return ptr; }/*
arch/powerpc/mm/pgtable-book3s64.c +3 -0
@@ -197,6 +197,9 @@ void __init mmu_partition_table_init(void)BUILD_BUG_ON_MSG ((PATB_SIZE_SHIFT >36 ),"Partition table size too large." );/* Initialize the Partition Table with no entries */ partition_tb =memblock_alloc (patb_size, patb_size); +if (!partition_tb) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, patb_size, patb_size);/* * update partition table control register,
arch/powerpc/mm/pgtable-radix.c +8 -1
@@ -53,13 +53,20 @@ static __ref void *early_alloc_pgtable(unsigned long size, int nid, {phys_addr_t min_addr =MEMBLOCK_LOW_LIMIT ;phys_addr_t max_addr =MEMBLOCK_ALLOC_ANYWHERE ; +void *ptr;if (region_start) min_addr = region_start;if (region_end) max_addr = region_end; -return memblock_alloc_try_nid (size, size, min_addr, max_addr, nid); + ptr =memblock_alloc_try_nid (size, size, min_addr, max_addr, nid); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%pa max_addr=%pa\n" , + __func__, size, size, nid, &min_addr, &max_addr); + +return ptr; } static int early_map_kernel_page(unsigned long ea, unsigned long pa,
arch/powerpc/mm/ppc_mmu_32.c +3 -0
@@ -212,6 +212,9 @@ void __init MMU_init_hw(void)*/ if ( ppc_md.progress ) ppc_md.progress ("hash:find piece" ,0x322 ); Hash =memblock_alloc (Hash_size, Hash_size); +if (!Hash) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, Hash_size, Hash_size); _SDR1 =__pa (Hash) |SDR1_LOW_BITS ; Hash_end = (struct hash_pte *) ((unsigned long )Hash + Hash_size);
arch/powerpc/platforms/pasemi/iommu.c +3 -0
@@ -211,6 +211,9 @@ static int __init iob_init(struct device_node *dn) iob_l2_base =memblock_alloc_try_nid_raw (1UL <<21 ,1UL <<21 ,MEMBLOCK_LOW_LIMIT ,0x80000000 ,NUMA_NO_NODE ); +if (!iob_l2_base) +panic ("%s: Failed to allocate %lu bytes align=0x%lx max_addr=%x\n" , + __func__,1UL <<21 ,1UL <<21 ,0x80000000 );pr_info ("IOBMAP L2 allocated at: %p\n" , iob_l2_base);
arch/powerpc/platforms/powermac/nvram.c +3 -0
@@ -514,6 +514,9 @@ static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)return -EINVAL ; } nvram_image =memblock_alloc (NVRAM_SIZE ,SMP_CACHE_BYTES ); +if (!nvram_image) +panic ("%s: Failed to allocate %u bytes\n" , __func__, +NVRAM_SIZE ); nvram_data =ioremap (addr,NVRAM_SIZE *2 ); nvram_naddrs =1 ;/* Make sure we get the correct case */
arch/powerpc/platforms/powernv/opal.c +3 -0
@@ -172,6 +172,9 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node,* Allocate a buffer to hold the MC recoverable ranges. */ mc_recoverable_range =memblock_alloc (size, __alignof__(u64 )); +if (!mc_recoverable_range) +panic ("%s: Failed to allocate %u bytes align=0x%lx\n" , + __func__, size, __alignof__(u64 ));for (i =0 ; i < mc_recoverable_range_len; i++) { mc_recoverable_range[i].start_addr =
arch/powerpc/platforms/powernv/pci-ioda.c +8 -0
@@ -3727,6 +3727,9 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,pr_debug (" PHB-ID : 0x%016llx\n" , phb_id); phb =memblock_alloc (sizeof (*phb),SMP_CACHE_BYTES ); +if (!phb) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*phb));/* Allocate PCI controller */ phb->hose = hose =pcibios_alloc_controller (np);
@@ -3773,6 +3776,9 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, phb->diag_data_size =PNV_PCI_DIAG_BUF_SIZE ; phb->diag_data =memblock_alloc (phb->diag_data_size,SMP_CACHE_BYTES ); +if (!phb->diag_data) +panic ("%s: Failed to allocate %u bytes\n" , __func__, + phb->diag_data_size);/* Parse 32-bit and IO ranges (if any) */ pci_process_bridge_OF_ranges (hose, np, !hose->global_number);
@@ -3832,6 +3838,8 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, pemap_off = size; size += phb->ioda.total_pe_num *sizeof (struct pnv_ioda_pe ); aux =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!aux) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, size); phb->ioda.pe_alloc = aux; phb->ioda.m64_segmap = aux + m64map_off; phb->ioda.m32_segmap = aux + m32map_off;
arch/powerpc/platforms/ps3/setup.c +3 -0
@@ -127,6 +127,9 @@ static void __init prealloc(struct ps3_prealloc *p)return ; p->address =memblock_alloc (p->size, p->align); +if (!p->address) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, p->size, p->align);printk (KERN_INFO "%s: %lu bytes at %p\n" , p->name, p->size, p->address);
arch/powerpc/sysdev/msi_bitmap.c +3 -0
@@ -129,6 +129,9 @@ int __ref msi_bitmap_alloc(struct msi_bitmap *bmp, unsigned int irq_count, bmp->bitmap =kzalloc (size,GFP_KERNEL ); else { bmp->bitmap =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!bmp->bitmap) +panic ("%s: Failed to allocate %u bytes\n" , __func__, + size);/* the bitmap won't be freed from memblock allocator */ kmemleak_not_leak (bmp->bitmap); }
arch/s390/kernel/setup.c +13 -0
@@ -378,6 +378,10 @@ static void __init setup_lowcore(void)*/ BUILD_BUG_ON (sizeof (struct lowcore ) !=LC_PAGES *PAGE_SIZE ); lc =memblock_alloc_low (sizeof (*lc),sizeof (*lc)); +if (!lc) +panic ("%s: Failed to allocate %zu bytes align=%zx\n" , + __func__,sizeof (*lc),sizeof (*lc)); + lc->restart_psw.mask =PSW_KERNEL_BITS ; lc->restart_psw.addr = (unsigned long ) restart_int_handler; lc->external_new_psw.mask = PSW_KERNEL_BITS |
@@ -422,6 +426,9 @@ static void __init setup_lowcore(void)* all CPUs in cast *one* of them does a PSW restart. */ restart_stack =memblock_alloc (THREAD_SIZE ,THREAD_SIZE ); +if (!restart_stack) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,THREAD_SIZE ,THREAD_SIZE ); restart_stack +=STACK_INIT_OFFSET ;/*
@@ -488,6 +495,9 @@ static void __init setup_resources(void)for_each_memblock (memory, reg) { res =memblock_alloc (sizeof (*res),8 ); +if (!res) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*res),8 ); res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; res->name ="System RAM" ;
@@ -502,6 +512,9 @@ static void __init setup_resources(void)continue ;if (std_res->end > res->end) { sub_res =memblock_alloc (sizeof (*sub_res),8 ); +if (!sub_res) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*sub_res),8 ); *sub_res = *std_res; sub_res->end = res->end; std_res->start = res->end +1 ;
arch/s390/kernel/smp.c +4 -1
@@ -653,7 +653,7 @@ void __init smp_save_dump_cpus(void)/* Allocate a page as dumping area for the store status sigps */ page =memblock_phys_alloc_range (PAGE_SIZE ,PAGE_SIZE ,0 ,1UL <<31 );if (!page) -panic ("ERROR: Failed to allocate %x bytes below %lx\n" , +panic ("ERROR: Failed to allocate %lx bytes below %lx\n" ,PAGE_SIZE ,1UL <<31 );/* Set multi-threading state to the previous system. */
@@ -765,6 +765,9 @@ void __init smp_detect_cpus(void)/* Get CPU information */ info =memblock_alloc (sizeof (*info),8 ); +if (!info) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*info),8 );smp_get_core_info (info,1 );/* Find boot CPU type */ if (sclp.has_core_type) {
arch/s390/kernel/topology.c +6 -0
@@ -520,6 +520,9 @@ static void __init alloc_masks(struct sysinfo_15_1_x *info, nr_masks =max (nr_masks,1 );for (i =0 ; i < nr_masks; i++) { mask->next =memblock_alloc (sizeof (*mask->next),8 ); +if (!mask->next) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*mask->next),8 ); mask = mask->next; } }
@@ -538,6 +541,9 @@ void __init topology_init_early(void)if (!MACHINE_HAS_TOPOLOGY ) goto out; tl_info =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!tl_info) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); info = tl_info;store_topology (info); pr_info("The CPU configuration topology of the machine is: %d %d %d %d %d %d / %d\n",
arch/s390/numa/mode_emu.c +3 -0
@@ -313,6 +313,9 @@ static void __ref create_core_to_node_map(void)int i; emu_cores =memblock_alloc (sizeof (*emu_cores),8 ); +if (!emu_cores) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (*emu_cores),8 );for (i =0 ; i <ARRAY_SIZE (emu_cores->to_node_id); i++) emu_cores->to_node_id[i] =NODE_ID_FREE ; }
arch/s390/numa/numa.c +5 -1
@@ -92,8 +92,12 @@ static void __init numa_setup_memory(void) }while (cur_base < end_of_dram);/* Allocate and fill out node_data */ -for (nid =0 ; nid <MAX_NUMNODES ; nid++) +for (nid =0 ; nid <MAX_NUMNODES ; nid++) {NODE_DATA (nid) =memblock_alloc (sizeof (pg_data_t),8 ); +if (!NODE_DATA (nid)) +panic ("%s: Failed to allocate %zu bytes align=0x%x\n" , + __func__,sizeof (pg_data_t),8 ); + }for_each_online_node (nid) {unsigned long start_pfn, end_pfn;
arch/sh/mm/init.c +6 -0
@@ -128,6 +128,9 @@ static pmd_t * __init one_md_table_init(pud_t *pud)pmd_t *pmd; pmd =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pmd) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );pud_populate (&init_mm, pud, pmd);BUG_ON (pmd !=pmd_offset (pud,0 )); }
@@ -141,6 +144,9 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)pte_t *pte; pte =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );pmd_populate_kernel (&init_mm, pmd, pte);BUG_ON (pte !=pte_offset_kernel (pmd,0 )); }
arch/sh/mm/numa.c +4 -0
@@ -43,6 +43,10 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)/* Node-local pgdat */ NODE_DATA (nid) =memblock_alloc_node (sizeof (struct pglist_data ),SMP_CACHE_BYTES , nid); +if (!NODE_DATA (nid)) +panic ("%s: Failed to allocate %zu bytes align=0x%x nid=%d\n" , + __func__,sizeof (struct pglist_data ),SMP_CACHE_BYTES , + nid);NODE_DATA (nid)->node_start_pfn = start_pfn;NODE_DATA (nid)->node_spanned_pages = end_pfn - start_pfn;
arch/um/drivers/net_kern.c +3 -0
@@ -649,6 +649,9 @@ static int __init eth_setup(char *str) } new =memblock_alloc (sizeof (*new),SMP_CACHE_BYTES ); +if (!new) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*new));INIT_LIST_HEAD (&new->list); new->index = n;
arch/um/drivers/vector_kern.c +3 -0
@@ -1576,6 +1576,9 @@ static int __init vector_setup(char *str)return 1 ; } new =memblock_alloc (sizeof (*new),SMP_CACHE_BYTES ); +if (!new) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*new));INIT_LIST_HEAD (&new->list); new->unit = n; new->arguments = str;
arch/um/kernel/initrd.c +2 -0
@@ -37,6 +37,8 @@ int __init read_initrd(void) } area =memblock_alloc (size,SMP_CACHE_BYTES ); +if (!area) +panic ("%s: Failed to allocate %llu bytes\n" , __func__, size);if (load_initrd (initrd, area, size) ==-1 )return 0 ;
arch/um/kernel/mem.c +16 -0
@@ -66,6 +66,10 @@ static void __init one_page_table_init(pmd_t *pmd)if (pmd_none (*pmd)) {pte_t *pte = (pte_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +set_pmd (pmd,__pmd (_KERNPG_TABLE + (unsigned long )__pa (pte)));if (pte !=pte_offset_kernel (pmd,0 ))
@@ -77,6 +81,10 @@ static void __init one_md_table_init(pud_t *pud) {#ifdef CONFIG_3_LEVEL_PGTABLES pmd_t *pmd_table = (pmd_t *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!pmd_table) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +set_pud (pud,__pud (_KERNPG_TABLE + (unsigned long )__pa (pmd_table)));if (pmd_table !=pmd_offset (pud,0 ))BUG ();
@@ -126,6 +134,10 @@ static void __init fixaddr_user_init( void)fixrange_init (FIXADDR_USER_START ,FIXADDR_USER_END , swapper_pg_dir); v = (unsigned long )memblock_alloc_low (size,PAGE_SIZE ); +if (!v) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__, size,PAGE_SIZE ); +memcpy ((void *) v , (void *)FIXADDR_USER_START , size); p =__pa (v); for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
@@ -146,6 +158,10 @@ void __init paging_init(void) empty_zero_page = (unsigned long *)memblock_alloc_low (PAGE_SIZE ,PAGE_SIZE ); +if (!empty_zero_page) +panic ("%s: Failed to allocate %lu bytes align=%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); +for (i =0 ; i <ARRAY_SIZE (zones_size); i++) zones_size[i] =0 ;
arch/unicore32/kernel/setup.c +4 -0
@@ -207,6 +207,10 @@ request_standard_resources(struct meminfo *mi)continue ; res =memblock_alloc_low (sizeof (*res),SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes align=%x\n" , + __func__,sizeof (*res),SMP_CACHE_BYTES ); + res->name ="System RAM" ; res->start = mi->bank[i].start; res->end = mi->bank[i].start + mi->bank[i].size -1 ;
arch/unicore32/mm/mmu.c +13 -2
@@ -145,8 +145,13 @@ static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot) {if (pmd_none (*pmd)) { -pte_t *pte =memblock_alloc (PTRS_PER_PTE *sizeof (pte_t), -PTRS_PER_PTE *sizeof (pte_t)); +size_t size =PTRS_PER_PTE *sizeof (pte_t); +pte_t *pte =memblock_alloc (size, size); + +if (!pte) +panic ("%s: Failed to allocate %zu bytes align=%zx\n" , + __func__, size, size); +__pmd_populate (pmd,__pa (pte) | prot); }BUG_ON (pmd_bad (*pmd));
@@ -349,6 +354,9 @@ static void __init devicemaps_init(void)* Allocate the vector page early. */ vectors =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!vectors) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );for (addr =VMALLOC_END ; addr; addr +=PGDIR_SIZE )pmd_clear (pmd_off_k (addr));
@@ -426,6 +434,9 @@ void __init paging_init(void)/* allocate the zero page. */ zero_page =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!zero_page) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE );bootmem_init ();
arch/x86/kernel/acpi/boot.c +3 -0
@@ -935,6 +935,9 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)#define HPET_RESOURCE_NAME_SIZE 9 hpet_res =memblock_alloc (sizeof (*hpet_res) +HPET_RESOURCE_NAME_SIZE ,SMP_CACHE_BYTES ); +if (!hpet_res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*hpet_res) +HPET_RESOURCE_NAME_SIZE ); hpet_res->name = (void *)&hpet_res[1 ]; hpet_res->flags =IORESOURCE_MEM ;
arch/x86/kernel/apic/io_apic.c +5 -0
@@ -2579,6 +2579,8 @@ static struct resource * __init ioapic_setup_resources(void) n *= nr_ioapics; mem =memblock_alloc (n,SMP_CACHE_BYTES ); +if (!mem) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, n); res = (void *)mem; mem +=sizeof (struct resource ) * nr_ioapics;
@@ -2623,6 +2625,9 @@ void __init io_apic_init_mappings(void)#endif ioapic_phys = (unsigned long )memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (!ioapic_phys) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); ioapic_phys =__pa (ioapic_phys); }set_fixmap_nocache (idx, ioapic_phys);
arch/x86/kernel/e820.c +3 -0
@@ -1095,6 +1095,9 @@ void __init e820__reserve_resources(void) res =memblock_alloc (sizeof (*res) * e820_table->nr_entries,SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*res) * e820_table->nr_entries); e820_res = res;for (i =0 ; i < e820_table->nr_entries; i++) {
arch/x86/platform/olpc/olpc_dt.c +3 -0
@@ -141,6 +141,9 @@ void * __init prom_early_alloc(unsigned long size)* wasted bootmem) and hand off chunks of it to callers. */ res =memblock_alloc (chunk_size,SMP_CACHE_BYTES ); +if (!res) +panic ("%s: Failed to allocate %lu bytes\n" , __func__, + chunk_size);BUG_ON (!res); prom_early_allocated += chunk_size;memset (res,0 , chunk_size);
arch/x86/xen/p2m.c +9 -2
@@ -181,8 +181,15 @@ static void p2m_init_identity(unsigned long *p2m, unsigned long pfn)static void *__ref alloc_p2m_page (void ) { -if (unlikely (!slab_is_available ())) -return memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); +if (unlikely (!slab_is_available ())) { +void *ptr =memblock_alloc (PAGE_SIZE ,PAGE_SIZE ); + +if (!ptr) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_SIZE ,PAGE_SIZE ); + +return ptr; + }return (void *)__get_free_page (GFP_KERNEL ); }
arch/xtensa/mm/kasan_init.c +4 -0
@@ -45,6 +45,10 @@ static void __init populate(void *start, void *end)pmd_t *pmd =pmd_offset (pgd, vaddr);pte_t *pte =memblock_alloc (n_pages *sizeof (pte_t),PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %zu bytes align=0x%lx\n" , + __func__, n_pages *sizeof (pte_t),PAGE_SIZE ); +pr_debug ("%s: %p - %p\n" , __func__, start, end);for (i = j =0 ; i < n_pmds; ++i) {
arch/xtensa/mm/mmu.c +3 -0
@@ -32,6 +32,9 @@ static void * __init init_pmd(unsigned long vaddr, unsigned long n_pages) __func__, vaddr, n_pages); pte =memblock_alloc_low (n_pages *sizeof (pte_t),PAGE_SIZE ); +if (!pte) +panic ("%s: Failed to allocate %zu bytes align=%lx\n" , + __func__, n_pages *sizeof (pte_t),PAGE_SIZE );for (i =0 ; i < n_pages; ++i)pte_clear (NULL ,0 , pte + i);
drivers/clk/ti/clk.c +3 -0
@@ -351,6 +351,9 @@ void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem)struct clk_iomap *io; io =memblock_alloc (sizeof (*io),SMP_CACHE_BYTES ); +if (!io) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (*io)); io->mem = mem;
drivers/macintosh/smu.c +3 -0
@@ -493,6 +493,9 @@ int __init smu_init (void) } smu =memblock_alloc (sizeof (struct smu_device ),SMP_CACHE_BYTES ); +if (!smu) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct smu_device ));spin_lock_init (&smu->lock);INIT_LIST_HEAD (&smu->cmd_list);
drivers/of/fdt.c +7 -1
@@ -1185,7 +1185,13 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,static void *__init early_init_dt_alloc_memory_arch (u64 size,u64 align) { -return memblock_alloc (size, align); +void *ptr =memblock_alloc (size, align); + +if (!ptr) +panic ("%s: Failed to allocate %llu bytes align=0x%llx\n" , + __func__, size, align); + +return ptr; }bool __init early_init_dt_verify (void *params)
drivers/of/unittest.c +7 -1
@@ -2234,7 +2234,13 @@ static struct device_node *overlay_base_root;static void *__init dt_alloc_memory (u64 size,u64 align) { -return memblock_alloc (size, align); +void *ptr =memblock_alloc (size, align); + +if (!ptr) +panic ("%s: Failed to allocate %llu bytes align=0x%llx\n" , + __func__, size, align); + +return ptr; }/*
drivers/xen/swiotlb-xen.c +5 -2
@@ -214,10 +214,13 @@ int __ref xen_swiotlb_init(int verbose, bool early)/* * Get IO TLB memory from any location. */ -if (early) +if (early) { xen_io_tlb_start =memblock_alloc (PAGE_ALIGN (bytes),PAGE_SIZE ); -else { +if (!xen_io_tlb_start) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__,PAGE_ALIGN (bytes),PAGE_SIZE ); + }else {#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))#define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)while ((SLABS_PER_PAGE << order) >IO_TLB_MIN_SLABS ) {
kernel/power/snapshot.c +3 -0
@@ -965,6 +965,9 @@ void __init __register_nosave_region(unsigned long start_pfn,/* This allocation cannot fail */ region =memblock_alloc (sizeof (struct nosave_region ),SMP_CACHE_BYTES ); +if (!region) +panic ("%s: Failed to allocate %zu bytes\n" , __func__, +sizeof (struct nosave_region )); } region->start_pfn = start_pfn; region->end_pfn = end_pfn;
lib/cpumask.c +3 -0
@@ -165,6 +165,9 @@ EXPORT_SYMBOL(zalloc_cpumask_var);void __init alloc_bootmem_cpumask_var (cpumask_var_t *mask) { *mask =memblock_alloc (cpumask_size (),SMP_CACHE_BYTES ); +if (!*mask) +panic ("%s: Failed to allocate %u bytes\n" , __func__, +cpumask_size ()); }/**
mm/kasan/init.c +8 -2
@@ -83,8 +83,14 @@ static inline bool kasan_early_shadow_page_entry(pte_t pte)static __init void *early_alloc (size_t size,int node) { -return memblock_alloc_try_nid (size, size,__pa (MAX_DMA_ADDRESS ), -MEMBLOCK_ALLOC_ACCESSIBLE , node); +void *ptr =memblock_alloc_try_nid (size, size,__pa (MAX_DMA_ADDRESS ), +MEMBLOCK_ALLOC_ACCESSIBLE , node); + +if (!ptr) +panic ("%s: Failed to allocate %zu bytes align=%zx nid=%d from=%llx\n" , + __func__, size, size, node, (u64 )__pa (MAX_DMA_ADDRESS )); + +return ptr; } static void __ref zero_pte_populate(pmd_t *pmd, unsigned long addr,
mm/sparse.c +17 -2
@@ -65,11 +65,15 @@ static noinline struct mem_section __ref *sparse_index_alloc(int nid)unsigned long array_size =SECTIONS_PER_ROOT *sizeof (struct mem_section ); -if (slab_is_available ()) +if (slab_is_available ()) { section =kzalloc_node (array_size,GFP_KERNEL , nid); -else + }else { section =memblock_alloc_node (array_size,SMP_CACHE_BYTES , nid); +if (!section) +panic ("%s: Failed to allocate %lu bytes nid=%d\n" , + __func__, array_size, nid); + }return section; }
@@ -218,6 +222,9 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) size =sizeof (struct mem_section *) *NR_SECTION_ROOTS ; align =1 << (INTERNODE_CACHE_SHIFT ); mem_section =memblock_alloc (size, align); +if (!mem_section) +panic ("%s: Failed to allocate %lu bytes align=0x%lx\n" , + __func__, size, align); }#endif
@@ -411,6 +418,10 @@ struct page __init *sparse_mem_map_populate(unsigned long pnum, int nid, map =memblock_alloc_try_nid (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!map) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); + return map; }#endif /* !CONFIG_SPARSEMEM_VMEMMAP */
@@ -425,6 +436,10 @@ static void __init sparse_buffer_init(unsigned long size, int nid)memblock_alloc_try_nid_raw (size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); +if (!sparsemap_buf) +panic ("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%lx\n" , + __func__, size,PAGE_SIZE , nid,__pa (MAX_DMA_ADDRESS )); + sparsemap_buf_end = sparsemap_buf + size; }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 20/21 memblock: memblock_alloc_try_nid: don't panic
In reply to Mike RapoportAs all the memblock_alloc*() users are now checking the return value and panic() in case of error, the panic() call can be removed from the core memblock allocator, namely memblock_alloc_try_nid().
--- mm/memblock.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
mm/memblock.c +5 -10
@@ -1526,7 +1526,7 @@ void * __init memblock_alloc_try_nid_nopanic( }/** -* memblock_alloc_try_nid - allocate boot memory block with panicking +* memblock_alloc_try_nid - allocate boot memory block * @size: size of memory block to be allocated in bytes * @align: alignment of the region and block's size * @min_addr: the lower bound of the memory region from where the allocation
@@ -1536,9 +1536,8 @@ void * __init memblock_alloc_try_nid_nopanic(* allocate only from memory limited by memblock.current_limit value * @nid: nid of the free area to find, %NUMA_NO_NODE for any node * -* Public panicking version of memblock_alloc_try_nid_nopanic() -* which provides debug information (including caller info), if enabled, -* and panics if the request can not be satisfied. +* Public function, provides additional debug information (including caller +* info), if enabled. This function zeroes the allocated memory. * * Return: * Virtual address of allocated memory block on success, NULL on failure.
@@ -1555,14 +1554,10 @@ void * __init memblock_alloc_try_nid( &max_addr, (void *)_RET_IP_); ptr =memblock_alloc_internal (size, align, min_addr, max_addr, nid); -if (ptr) { +if (ptr)memset (ptr,0 , size); -return ptr; - } -panic ("%s: Failed to allocate %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa\n" , - __func__, (u64 )size, (u64 )align, nid, &min_addr, &max_addr); -return NULL ; +return ptr; }/**
Signature · 1 line
2.7.4
PATCH v2 20/21 memblock: memblock_alloc_try_nid: don't panic
In reply to Mike RapoportAs all the memblock_alloc*() users are now checking the return value and panic() in case of error, the panic() call can be removed from the core memblock allocator, namely memblock_alloc_try_nid().
--- mm/memblock.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
mm/memblock.c +5 -10
@@ -1526,7 +1526,7 @@ void * __init memblock_alloc_try_nid_nopanic( }/** -* memblock_alloc_try_nid - allocate boot memory block with panicking +* memblock_alloc_try_nid - allocate boot memory block * @size: size of memory block to be allocated in bytes * @align: alignment of the region and block's size * @min_addr: the lower bound of the memory region from where the allocation
@@ -1536,9 +1536,8 @@ void * __init memblock_alloc_try_nid_nopanic(* allocate only from memory limited by memblock.current_limit value * @nid: nid of the free area to find, %NUMA_NO_NODE for any node * -* Public panicking version of memblock_alloc_try_nid_nopanic() -* which provides debug information (including caller info), if enabled, -* and panics if the request can not be satisfied. +* Public function, provides additional debug information (including caller +* info), if enabled. This function zeroes the allocated memory. * * Return: * Virtual address of allocated memory block on success, NULL on failure.
@@ -1555,14 +1554,10 @@ void * __init memblock_alloc_try_nid( &max_addr, (void *)_RET_IP_); ptr =memblock_alloc_internal (size, align, min_addr, max_addr, nid); -if (ptr) { +if (ptr)memset (ptr,0 , size); -return ptr; - } -panic ("%s: Failed to allocate %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa\n" , - __func__, (u64 )size, (u64 )align, nid, &min_addr, &max_addr); -return NULL ; +return ptr; }/**
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 21/21 memblock: drop memblock_alloc_*_nopanic() variants
In reply to Mike RapoportAs all the memblock allocation functions return NULL in case of error rather than panic(), the duplicates with _nopanic suffix can be removed.
--- arch/arc/kernel/unwind.c | 3 +-- arch/sh/mm/init.c | 2 +- arch/x86/kernel/setup_percpu.c | 10 +++++----- arch/x86/mm/kasan_init_64.c | 14 ++++++++------ drivers/firmware/memmap.c | 2 +- drivers/usb/early/xhci-dbc.c | 2 +- include/linux/memblock.h | 35 ----------------------------------- kernel/dma/swiotlb.c | 2 +- kernel/printk/printk.c | 9 +-------- mm/memblock.c | 35 ----------------------------------- mm/page_alloc.c | 10 +++++----- mm/page_ext.c | 2 +- mm/percpu.c | 11 ++++------- mm/sparse.c | 6 ++---- 14 files changed, 31 insertions(+), 112 deletions(-)
arch/arc/kernel/unwind.c +1 -2
@@ -181,8 +181,7 @@ static void init_unwind_hdr(struct unwind_table *table,*/ static void *__init unw_hdr_alloc_early (unsigned long sz) { -return memblock_alloc_from_nopanic (sz,sizeof (unsigned int ), -MAX_DMA_ADDRESS ); +return memblock_alloc_from (sz,sizeof (unsigned int ),MAX_DMA_ADDRESS ); }static void *unw_hdr_alloc (unsigned long sz)
arch/sh/mm/init.c +1 -1
@@ -202,7 +202,7 @@ void __init allocate_pgdat(unsigned int nid)get_pfn_range_for_nid (nid, &start_pfn, &end_pfn);#ifdef CONFIG_NEED_MULTIPLE_NODES -NODE_DATA (nid) =memblock_alloc_try_nid_nopanic ( +NODE_DATA (nid) =memblock_alloc_try_nid (sizeof (struct pglist_data ),SMP_CACHE_BYTES ,MEMBLOCK_LOW_LIMIT ,MEMBLOCK_ALLOC_ACCESSIBLE , nid);
arch/x86/kernel/setup_percpu.c +5 -5
@@ -106,22 +106,22 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size,void *ptr;if (!node_online (node) || !NODE_DATA (node)) { - ptr =memblock_alloc_from_nopanic (size, align, goal); + ptr =memblock_alloc_from (size, align, goal);pr_info ("cpu %d has no node %d or node-local memory\n" , cpu, node);pr_debug ("per cpu data for cpu%d %lu bytes at %016lx\n" , cpu, size,__pa (ptr)); }else { - ptr =memblock_alloc_try_nid_nopanic (size, align, goal, -MEMBLOCK_ALLOC_ACCESSIBLE , - node); + ptr =memblock_alloc_try_nid (size, align, goal, +MEMBLOCK_ALLOC_ACCESSIBLE , + node);pr_debug ("per cpu data for cpu%d %lu bytes on node%d at %016lx\n" , cpu, size, node,__pa (ptr)); }return ptr;#else -return memblock_alloc_from_nopanic (size, align, goal); +return memblock_alloc_from (size, align, goal);#endif }
arch/x86/mm/kasan_init_64.c +8 -6
@@ -24,14 +24,16 @@ extern struct range pfn_mapped[E820_MAX_ENTRIES];static p4d_t tmp_p4d_table[MAX_PTRS_PER_P4D ]__initdata __aligned(PAGE_SIZE) ; -static __init void *early_alloc (size_t size,int nid,bool panic) +static __init void *early_alloc (size_t size,int nid,bool should_panic) { -if (panic) -return memblock_alloc_try_nid (size, size, -__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); -else -return memblock_alloc_try_nid_nopanic (size, size, +void *ptr =memblock_alloc_try_nid (size, size,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); + +if (!ptr && should_panic) +panic ("%pS: Failed to allocate page, nid=%d from=%lx\n" , + (void *)_RET_IP_, nid,__pa (MAX_DMA_ADDRESS )); + +return ptr; } static void __init kasan_populate_pmd(pmd_t *pmd, unsigned long addr,
drivers/firmware/memmap.c +1 -1
@@ -333,7 +333,7 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type) {struct firmware_map_entry *entry; - entry =memblock_alloc_nopanic (sizeof (struct firmware_map_entry ), + entry =memblock_alloc (sizeof (struct firmware_map_entry ),SMP_CACHE_BYTES );if (WARN_ON (!entry))return -ENOMEM ;
drivers/usb/early/xhci-dbc.c +1 -1
@@ -94,7 +94,7 @@ static void * __init xdbc_get_page(dma_addr_t *dma_addr) {void *virt; - virt =memblock_alloc_nopanic (PAGE_SIZE ,PAGE_SIZE ); + virt =memblock_alloc (PAGE_SIZE ,PAGE_SIZE );if (!virt)return NULL ;
include/linux/memblock.h +0 -35
@@ -379,9 +379,6 @@ static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,void *memblock_alloc_try_nid_raw (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr,phys_addr_t max_addr,int nid); -void *memblock_alloc_try_nid_nopanic (phys_addr_t size,phys_addr_t align, -phys_addr_t min_addr,phys_addr_t max_addr, -int nid);void *memblock_alloc_try_nid (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr,phys_addr_t max_addr,int nid);
@@ -408,36 +405,12 @@ static inline void * __init memblock_alloc_from(phys_addr_t size, MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); } -static inline void *__init memblock_alloc_nopanic (phys_addr_t size, -phys_addr_t align) -{ -return memblock_alloc_try_nid_nopanic (size, align,MEMBLOCK_LOW_LIMIT , -MEMBLOCK_ALLOC_ACCESSIBLE , -NUMA_NO_NODE ); -} -static inline void *__init memblock_alloc_low (phys_addr_t size,phys_addr_t align) {return memblock_alloc_try_nid (size, align,MEMBLOCK_LOW_LIMIT ,ARCH_LOW_ADDRESS_LIMIT ,NUMA_NO_NODE ); } -static inline void *__init memblock_alloc_low_nopanic (phys_addr_t size, -phys_addr_t align) -{ -return memblock_alloc_try_nid_nopanic (size, align,MEMBLOCK_LOW_LIMIT , -ARCH_LOW_ADDRESS_LIMIT , -NUMA_NO_NODE ); -} - -static inline void *__init memblock_alloc_from_nopanic (phys_addr_t size, -phys_addr_t align, -phys_addr_t min_addr) -{ -return memblock_alloc_try_nid_nopanic (size, align, min_addr, -MEMBLOCK_ALLOC_ACCESSIBLE , -NUMA_NO_NODE ); -}static inline void *__init memblock_alloc_node (phys_addr_t size,phys_addr_t align,int nid)
@@ -446,14 +419,6 @@ static inline void * __init memblock_alloc_node(phys_addr_t size, MEMBLOCK_ALLOC_ACCESSIBLE, nid); } -static inline void *__init memblock_alloc_node_nopanic (phys_addr_t size, -int nid) -{ -return memblock_alloc_try_nid_nopanic (size,SMP_CACHE_BYTES , -MEMBLOCK_LOW_LIMIT , -MEMBLOCK_ALLOC_ACCESSIBLE , nid); -} -static inline void __init memblock_free_early (phys_addr_t base,phys_addr_t size) {
kernel/dma/swiotlb.c +1 -1
@@ -248,7 +248,7 @@ swiotlb_init(int verbose) bytes = io_tlb_nslabs <<IO_TLB_SHIFT ;/* Get IO TLB memory from the low pages */ - vstart =memblock_alloc_low_nopanic (PAGE_ALIGN (bytes),PAGE_SIZE ); + vstart =memblock_alloc_low (PAGE_ALIGN (bytes),PAGE_SIZE );if (vstart && !swiotlb_init_with_tbl (vstart, io_tlb_nslabs, verbose))return ;
kernel/printk/printk.c +1 -8
@@ -1147,14 +1147,7 @@ void __init setup_log_buf(int early)if (!new_log_buf_len)return ; -if (early) { - new_log_buf = -memblock_alloc (new_log_buf_len,LOG_ALIGN ); - }else { - new_log_buf =memblock_alloc_nopanic (new_log_buf_len, -LOG_ALIGN ); - } - + new_log_buf =memblock_alloc (new_log_buf_len,LOG_ALIGN );if (unlikely (!new_log_buf)) {pr_err ("log_buf_len: %lu bytes not available\n" , new_log_buf_len);
mm/memblock.c +0 -35
@@ -1491,41 +1491,6 @@ void * __init memblock_alloc_try_nid_raw( }/** -* memblock_alloc_try_nid_nopanic - allocate boot memory block -* @size: size of memory block to be allocated in bytes -* @align: alignment of the region and block's size -* @min_addr: the lower bound of the memory region from where the allocation -* is preferred (phys address) -* @max_addr: the upper bound of the memory region from where the allocation -* is preferred (phys address), or %MEMBLOCK_ALLOC_ACCESSIBLE to -* allocate only from memory limited by memblock.current_limit value -* @nid: nid of the free area to find, %NUMA_NO_NODE for any node -* -* Public function, provides additional debug information (including caller -* info), if enabled. This function zeroes the allocated memory. -* -* Return: -* Virtual address of allocated memory block on success, NULL on failure. -*/ -void *__init memblock_alloc_try_nid_nopanic ( -phys_addr_t size,phys_addr_t align, -phys_addr_t min_addr,phys_addr_t max_addr, -int nid) -{ -void *ptr; - -memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pF\n" , - __func__, (u64 )size, (u64 )align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); - - ptr =memblock_alloc_internal (size, align, - min_addr, max_addr, nid); -if (ptr) -memset (ptr,0 , size); -return ptr; -} - -/** * memblock_alloc_try_nid - allocate boot memory block * @size: size of memory block to be allocated in bytes * @align: alignment of the region and block's size
mm/page_alloc.c +5 -5
@@ -6556,8 +6556,8 @@ static void __ref setup_usemap(struct pglist_data *pgdat, zone->pageblock_flags =NULL ;if (usemapsize) zone->pageblock_flags = -memblock_alloc_node_nopanic (usemapsize, - pgdat->node_id); +memblock_alloc_node (usemapsize,SMP_CACHE_BYTES , + pgdat->node_id); }#else static inline void setup_usemap(struct pglist_data *pgdat, struct zone *zone,
@@ -6786,7 +6786,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) end =pgdat_end_pfn (pgdat); end =ALIGN (end,MAX_ORDER_NR_PAGES ); size = (end - start) *sizeof (struct page ); - map =memblock_alloc_node_nopanic (size, pgdat->node_id); + map =memblock_alloc_node (size,SMP_CACHE_BYTES , + pgdat->node_id); pgdat->node_mem_map = map + offset; } pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n",
@@ -8064,8 +8065,7 @@ void *__init alloc_large_system_hash(const char *tablename, size = bucketsize << log2qty;if (flags &HASH_EARLY ) {if (flags &HASH_ZERO ) - table =memblock_alloc_nopanic (size, -SMP_CACHE_BYTES ); + table =memblock_alloc (size,SMP_CACHE_BYTES );else table =memblock_alloc_raw (size,SMP_CACHE_BYTES );
mm/page_ext.c +1 -1
@@ -161,7 +161,7 @@ static int __init alloc_node_page_ext(int nid) table_size =get_entry_size () * nr_pages; - base =memblock_alloc_try_nid_nopanic ( + base =memblock_alloc_try_nid ( table_size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid);if (!base)
mm/percpu.c +4 -7
@@ -1905,7 +1905,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups, __alignof__(ai->groups[0].cpu_map[0])); ai_size = base_size + nr_units *sizeof (ai->groups[0 ].cpu_map[0 ]); - ptr =memblock_alloc_nopanic (PFN_ALIGN (ai_size),PAGE_SIZE ); + ptr =memblock_alloc (PFN_ALIGN (ai_size),PAGE_SIZE );if (!ptr)return NULL ; ai = ptr;
@@ -2496,7 +2496,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size, size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; areas_size =PFN_ALIGN (ai->nr_groups *sizeof (void *)); - areas =memblock_alloc_nopanic (areas_size,SMP_CACHE_BYTES ); + areas =memblock_alloc (areas_size,SMP_CACHE_BYTES );if (!areas) { rc = -ENOMEM ; goto out_free;
@@ -2729,8 +2729,7 @@ EXPORT_SYMBOL(__per_cpu_offset);static void *__init pcpu_dfl_fc_alloc (unsigned int cpu,size_t size,size_t align) { -return memblock_alloc_from_nopanic ( - size, align,__pa (MAX_DMA_ADDRESS )); +return memblock_alloc_from (size, align,__pa (MAX_DMA_ADDRESS )); }static void __init pcpu_dfl_fc_free (void *ptr,size_t size)
@@ -2778,9 +2777,7 @@ void __init setup_per_cpu_areas(void)void *fc; ai =pcpu_alloc_alloc_info (1 ,1 ); - fc =memblock_alloc_from_nopanic (unit_size, -PAGE_SIZE , -__pa (MAX_DMA_ADDRESS )); + fc =memblock_alloc_from (unit_size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ));if (!ai || !fc)panic ("Failed to allocate memory for percpu areas." );/* kmemleak tracks the percpu allocations separately */
mm/sparse.c +2 -4
@@ -330,9 +330,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, limit = goal + (1UL <<PA_SECTION_SHIFT ); nid =early_pfn_to_nid (goal >>PAGE_SHIFT ); again: - p =memblock_alloc_try_nid_nopanic (size, -SMP_CACHE_BYTES , goal, limit, - nid); + p =memblock_alloc_try_nid (size,SMP_CACHE_BYTES , goal, limit, nid);if (!p && limit) { limit =0 ; goto again;
@@ -386,7 +384,7 @@ static unsigned long * __init sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, unsigned long size) { -return memblock_alloc_node_nopanic (size, pgdat->node_id); + return memblock_alloc_node(size, SMP_CACHE_BYTES, pgdat->node_id); }static void __init check_usemap_section_nr (int nid,unsigned long *usemap)
Signature · 1 line
2.7.4
Re: [PATCH v2 21/21] memblock: drop memblock_alloc_*_nopanic() variants
Quoted 5 lines · Mike Rapoport
As all the memblock allocation functions return NULL in case of error rather than
panic(), the duplicates with_nopanicsuffix can be removed.Signed-off-by Mike Rapoport <[email protected]>
Quoted 10 lines
--- arch/arc/kernel/unwind.c | 3 +-- arch/sh/mm/init.c | 2 +- arch/x86/kernel/setup_percpu.c | 10 +++++----- arch/x86/mm/kasan_init_64.c | 14 ++++++++------ drivers/firmware/memmap.c | 2 +- drivers/usb/early/xhci-dbc.c | 2 +- include/linux/memblock.h | 35 ----------------------------------- kernel/dma/swiotlb.c | 2 +- kernel/printk/printk.c | 9 +--------
For printk:
Best Regards,
Petr
Quoted 7 lines
mm/memblock.c | 35 ----------------------------------- mm/page_alloc.c | 10 +++++----- mm/page_ext.c | 2 +- mm/percpu.c | 11 ++++------- mm/sparse.c | 6 ++---- 14 files changed, 31 insertions(+), 112 deletions(-)
Re: [PATCH v2 21/21] memblock: drop memblock_alloc_*_nopanic() variants
In reply to Mike RapoportQuoted 5 lines · Mike Rapoport
As all the memblock allocation functions return NULL in case of error rather than
panic(), the duplicates with_nopanicsuffix can be removed.Signed-off-by Mike Rapoport <[email protected]>
Quoted 10 lines
--- arch/arc/kernel/unwind.c | 3 +-- arch/sh/mm/init.c | 2 +- arch/x86/kernel/setup_percpu.c | 10 +++++----- arch/x86/mm/kasan_init_64.c | 14 ++++++++------ drivers/firmware/memmap.c | 2 +- drivers/usb/early/xhci-dbc.c | 2 +- include/linux/memblock.h | 35 ----------------------------------- kernel/dma/swiotlb.c | 2 +- kernel/printk/printk.c | 9 +--------
For printk:
Best Regards,
Petr
Quoted 7 lines
mm/memblock.c | 35 ----------------------------------- mm/page_alloc.c | 10 +++++----- mm/page_ext.c | 2 +- mm/percpu.c | 11 ++++------- mm/sparse.c | 6 ++---- 14 files changed, 31 insertions(+), 112 deletions(-)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 21/21 memblock: drop memblock_alloc_*_nopanic() variants
In reply to Mike RapoportAs all the memblock allocation functions return NULL in case of error rather than panic(), the duplicates with _nopanic suffix can be removed.
--- arch/arc/kernel/unwind.c | 3 +-- arch/sh/mm/init.c | 2 +- arch/x86/kernel/setup_percpu.c | 10 +++++----- arch/x86/mm/kasan_init_64.c | 14 ++++++++------ drivers/firmware/memmap.c | 2 +- drivers/usb/early/xhci-dbc.c | 2 +- include/linux/memblock.h | 35 ----------------------------------- kernel/dma/swiotlb.c | 2 +- kernel/printk/printk.c | 9 +-------- mm/memblock.c | 35 ----------------------------------- mm/page_alloc.c | 10 +++++----- mm/page_ext.c | 2 +- mm/percpu.c | 11 ++++------- mm/sparse.c | 6 ++---- 14 files changed, 31 insertions(+), 112 deletions(-)
arch/arc/kernel/unwind.c +1 -2
@@ -181,8 +181,7 @@ static void init_unwind_hdr(struct unwind_table *table,*/ static void *__init unw_hdr_alloc_early (unsigned long sz) { -return memblock_alloc_from_nopanic (sz,sizeof (unsigned int ), -MAX_DMA_ADDRESS ); +return memblock_alloc_from (sz,sizeof (unsigned int ),MAX_DMA_ADDRESS ); }static void *unw_hdr_alloc (unsigned long sz)
arch/sh/mm/init.c +1 -1
@@ -202,7 +202,7 @@ void __init allocate_pgdat(unsigned int nid)get_pfn_range_for_nid (nid, &start_pfn, &end_pfn);#ifdef CONFIG_NEED_MULTIPLE_NODES -NODE_DATA (nid) =memblock_alloc_try_nid_nopanic ( +NODE_DATA (nid) =memblock_alloc_try_nid (sizeof (struct pglist_data ),SMP_CACHE_BYTES ,MEMBLOCK_LOW_LIMIT ,MEMBLOCK_ALLOC_ACCESSIBLE , nid);
arch/x86/kernel/setup_percpu.c +5 -5
@@ -106,22 +106,22 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size,void *ptr;if (!node_online (node) || !NODE_DATA (node)) { - ptr =memblock_alloc_from_nopanic (size, align, goal); + ptr =memblock_alloc_from (size, align, goal);pr_info ("cpu %d has no node %d or node-local memory\n" , cpu, node);pr_debug ("per cpu data for cpu%d %lu bytes at %016lx\n" , cpu, size,__pa (ptr)); }else { - ptr =memblock_alloc_try_nid_nopanic (size, align, goal, -MEMBLOCK_ALLOC_ACCESSIBLE , - node); + ptr =memblock_alloc_try_nid (size, align, goal, +MEMBLOCK_ALLOC_ACCESSIBLE , + node);pr_debug ("per cpu data for cpu%d %lu bytes on node%d at %016lx\n" , cpu, size, node,__pa (ptr)); }return ptr;#else -return memblock_alloc_from_nopanic (size, align, goal); +return memblock_alloc_from (size, align, goal);#endif }
arch/x86/mm/kasan_init_64.c +8 -6
@@ -24,14 +24,16 @@ extern struct range pfn_mapped[E820_MAX_ENTRIES];static p4d_t tmp_p4d_table[MAX_PTRS_PER_P4D ]__initdata __aligned(PAGE_SIZE) ; -static __init void *early_alloc (size_t size,int nid,bool panic) +static __init void *early_alloc (size_t size,int nid,bool should_panic) { -if (panic) -return memblock_alloc_try_nid (size, size, -__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); -else -return memblock_alloc_try_nid_nopanic (size, size, +void *ptr =memblock_alloc_try_nid (size, size,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid); + +if (!ptr && should_panic) +panic ("%pS: Failed to allocate page, nid=%d from=%lx\n" , + (void *)_RET_IP_, nid,__pa (MAX_DMA_ADDRESS )); + +return ptr; } static void __init kasan_populate_pmd(pmd_t *pmd, unsigned long addr,
drivers/firmware/memmap.c +1 -1
@@ -333,7 +333,7 @@ int __init firmware_map_add_early(u64 start, u64 end, const char *type) {struct firmware_map_entry *entry; - entry =memblock_alloc_nopanic (sizeof (struct firmware_map_entry ), + entry =memblock_alloc (sizeof (struct firmware_map_entry ),SMP_CACHE_BYTES );if (WARN_ON (!entry))return -ENOMEM ;
drivers/usb/early/xhci-dbc.c +1 -1
@@ -94,7 +94,7 @@ static void * __init xdbc_get_page(dma_addr_t *dma_addr) {void *virt; - virt =memblock_alloc_nopanic (PAGE_SIZE ,PAGE_SIZE ); + virt =memblock_alloc (PAGE_SIZE ,PAGE_SIZE );if (!virt)return NULL ;
include/linux/memblock.h +0 -35
@@ -379,9 +379,6 @@ static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,void *memblock_alloc_try_nid_raw (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr,phys_addr_t max_addr,int nid); -void *memblock_alloc_try_nid_nopanic (phys_addr_t size,phys_addr_t align, -phys_addr_t min_addr,phys_addr_t max_addr, -int nid);void *memblock_alloc_try_nid (phys_addr_t size,phys_addr_t align,phys_addr_t min_addr,phys_addr_t max_addr,int nid);
@@ -408,36 +405,12 @@ static inline void * __init memblock_alloc_from(phys_addr_t size, MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); } -static inline void *__init memblock_alloc_nopanic (phys_addr_t size, -phys_addr_t align) -{ -return memblock_alloc_try_nid_nopanic (size, align,MEMBLOCK_LOW_LIMIT , -MEMBLOCK_ALLOC_ACCESSIBLE , -NUMA_NO_NODE ); -} -static inline void *__init memblock_alloc_low (phys_addr_t size,phys_addr_t align) {return memblock_alloc_try_nid (size, align,MEMBLOCK_LOW_LIMIT ,ARCH_LOW_ADDRESS_LIMIT ,NUMA_NO_NODE ); } -static inline void *__init memblock_alloc_low_nopanic (phys_addr_t size, -phys_addr_t align) -{ -return memblock_alloc_try_nid_nopanic (size, align,MEMBLOCK_LOW_LIMIT , -ARCH_LOW_ADDRESS_LIMIT , -NUMA_NO_NODE ); -} - -static inline void *__init memblock_alloc_from_nopanic (phys_addr_t size, -phys_addr_t align, -phys_addr_t min_addr) -{ -return memblock_alloc_try_nid_nopanic (size, align, min_addr, -MEMBLOCK_ALLOC_ACCESSIBLE , -NUMA_NO_NODE ); -}static inline void *__init memblock_alloc_node (phys_addr_t size,phys_addr_t align,int nid)
@@ -446,14 +419,6 @@ static inline void * __init memblock_alloc_node(phys_addr_t size, MEMBLOCK_ALLOC_ACCESSIBLE, nid); } -static inline void *__init memblock_alloc_node_nopanic (phys_addr_t size, -int nid) -{ -return memblock_alloc_try_nid_nopanic (size,SMP_CACHE_BYTES , -MEMBLOCK_LOW_LIMIT , -MEMBLOCK_ALLOC_ACCESSIBLE , nid); -} -static inline void __init memblock_free_early (phys_addr_t base,phys_addr_t size) {
kernel/dma/swiotlb.c +1 -1
@@ -248,7 +248,7 @@ swiotlb_init(int verbose) bytes = io_tlb_nslabs <<IO_TLB_SHIFT ;/* Get IO TLB memory from the low pages */ - vstart =memblock_alloc_low_nopanic (PAGE_ALIGN (bytes),PAGE_SIZE ); + vstart =memblock_alloc_low (PAGE_ALIGN (bytes),PAGE_SIZE );if (vstart && !swiotlb_init_with_tbl (vstart, io_tlb_nslabs, verbose))return ;
kernel/printk/printk.c +1 -8
@@ -1147,14 +1147,7 @@ void __init setup_log_buf(int early)if (!new_log_buf_len)return ; -if (early) { - new_log_buf = -memblock_alloc (new_log_buf_len,LOG_ALIGN ); - }else { - new_log_buf =memblock_alloc_nopanic (new_log_buf_len, -LOG_ALIGN ); - } - + new_log_buf =memblock_alloc (new_log_buf_len,LOG_ALIGN );if (unlikely (!new_log_buf)) {pr_err ("log_buf_len: %lu bytes not available\n" , new_log_buf_len);
mm/memblock.c +0 -35
@@ -1491,41 +1491,6 @@ void * __init memblock_alloc_try_nid_raw( }/** -* memblock_alloc_try_nid_nopanic - allocate boot memory block -* @size: size of memory block to be allocated in bytes -* @align: alignment of the region and block's size -* @min_addr: the lower bound of the memory region from where the allocation -* is preferred (phys address) -* @max_addr: the upper bound of the memory region from where the allocation -* is preferred (phys address), or %MEMBLOCK_ALLOC_ACCESSIBLE to -* allocate only from memory limited by memblock.current_limit value -* @nid: nid of the free area to find, %NUMA_NO_NODE for any node -* -* Public function, provides additional debug information (including caller -* info), if enabled. This function zeroes the allocated memory. -* -* Return: -* Virtual address of allocated memory block on success, NULL on failure. -*/ -void *__init memblock_alloc_try_nid_nopanic ( -phys_addr_t size,phys_addr_t align, -phys_addr_t min_addr,phys_addr_t max_addr, -int nid) -{ -void *ptr; - -memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=%pa max_addr=%pa %pF\n" , - __func__, (u64 )size, (u64 )align, nid, &min_addr, - &max_addr, (void *)_RET_IP_); - - ptr =memblock_alloc_internal (size, align, - min_addr, max_addr, nid); -if (ptr) -memset (ptr,0 , size); -return ptr; -} - -/** * memblock_alloc_try_nid - allocate boot memory block * @size: size of memory block to be allocated in bytes * @align: alignment of the region and block's size
mm/page_alloc.c +5 -5
@@ -6556,8 +6556,8 @@ static void __ref setup_usemap(struct pglist_data *pgdat, zone->pageblock_flags =NULL ;if (usemapsize) zone->pageblock_flags = -memblock_alloc_node_nopanic (usemapsize, - pgdat->node_id); +memblock_alloc_node (usemapsize,SMP_CACHE_BYTES , + pgdat->node_id); }#else static inline void setup_usemap(struct pglist_data *pgdat, struct zone *zone,
@@ -6786,7 +6786,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) end =pgdat_end_pfn (pgdat); end =ALIGN (end,MAX_ORDER_NR_PAGES ); size = (end - start) *sizeof (struct page ); - map =memblock_alloc_node_nopanic (size, pgdat->node_id); + map =memblock_alloc_node (size,SMP_CACHE_BYTES , + pgdat->node_id); pgdat->node_mem_map = map + offset; } pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n",
@@ -8064,8 +8065,7 @@ void *__init alloc_large_system_hash(const char *tablename, size = bucketsize << log2qty;if (flags &HASH_EARLY ) {if (flags &HASH_ZERO ) - table =memblock_alloc_nopanic (size, -SMP_CACHE_BYTES ); + table =memblock_alloc (size,SMP_CACHE_BYTES );else table =memblock_alloc_raw (size,SMP_CACHE_BYTES );
mm/page_ext.c +1 -1
@@ -161,7 +161,7 @@ static int __init alloc_node_page_ext(int nid) table_size =get_entry_size () * nr_pages; - base =memblock_alloc_try_nid_nopanic ( + base =memblock_alloc_try_nid ( table_size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ),MEMBLOCK_ALLOC_ACCESSIBLE , nid);if (!base)
mm/percpu.c +4 -7
@@ -1905,7 +1905,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups, __alignof__(ai->groups[0].cpu_map[0])); ai_size = base_size + nr_units *sizeof (ai->groups[0 ].cpu_map[0 ]); - ptr =memblock_alloc_nopanic (PFN_ALIGN (ai_size),PAGE_SIZE ); + ptr =memblock_alloc (PFN_ALIGN (ai_size),PAGE_SIZE );if (!ptr)return NULL ; ai = ptr;
@@ -2496,7 +2496,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size, size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; areas_size =PFN_ALIGN (ai->nr_groups *sizeof (void *)); - areas =memblock_alloc_nopanic (areas_size,SMP_CACHE_BYTES ); + areas =memblock_alloc (areas_size,SMP_CACHE_BYTES );if (!areas) { rc = -ENOMEM ; goto out_free;
@@ -2729,8 +2729,7 @@ EXPORT_SYMBOL(__per_cpu_offset);static void *__init pcpu_dfl_fc_alloc (unsigned int cpu,size_t size,size_t align) { -return memblock_alloc_from_nopanic ( - size, align,__pa (MAX_DMA_ADDRESS )); +return memblock_alloc_from (size, align,__pa (MAX_DMA_ADDRESS )); }static void __init pcpu_dfl_fc_free (void *ptr,size_t size)
@@ -2778,9 +2777,7 @@ void __init setup_per_cpu_areas(void)void *fc; ai =pcpu_alloc_alloc_info (1 ,1 ); - fc =memblock_alloc_from_nopanic (unit_size, -PAGE_SIZE , -__pa (MAX_DMA_ADDRESS )); + fc =memblock_alloc_from (unit_size,PAGE_SIZE ,__pa (MAX_DMA_ADDRESS ));if (!ai || !fc)panic ("Failed to allocate memory for percpu areas." );/* kmemleak tracks the percpu allocations separately */
mm/sparse.c +2 -4
@@ -330,9 +330,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, limit = goal + (1UL <<PA_SECTION_SHIFT ); nid =early_pfn_to_nid (goal >>PAGE_SHIFT ); again: - p =memblock_alloc_try_nid_nopanic (size, -SMP_CACHE_BYTES , goal, limit, - nid); + p =memblock_alloc_try_nid (size,SMP_CACHE_BYTES , goal, limit, nid);if (!p && limit) { limit =0 ; goto again;
@@ -386,7 +384,7 @@ static unsigned long * __init sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, unsigned long size) { -return memblock_alloc_node_nopanic (size, pgdat->node_id); + return memblock_alloc_node(size, SMP_CACHE_BYTES, pgdat->node_id); }static void __init check_usemap_section_nr (int nid,unsigned long *usemap)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 55 lines · Mike Rapoport
Hi,
Current memblock API is quite extensive and, which is more annoying, duplicated. Except the low-level functions that allow searching for a free memory region and marking it as reserved, memblock provides three (well, two and a half) sets of functions to allocate memory. There are several overlapping functions that return a physical address and there are functions that return virtual address. Those that return the virtual address may also clear the allocated memory. And, on top of all that, some allocators panic and some return NULL in case of error.
This set tries to reduce the mess, and trim down the amount of memblock allocation methods.
Patches 1-10 consolidate the functions that return physical address of the allocated memory
Patches 11-13 are some trivial cleanups
Patches 14-19 add checks for the return value of memblock_alloc*() and panics in case of errors. The patches 14-18 include some minor refactoring to have better readability of the resulting code and patch 19 is a mechanical addition of
if (!ptr) panic();after memblock_alloc*() calls.
And, finally, patches 20 and 21 remove
panic()calls memblock and_nopanicvariants from memblock.v2 changes:
* replace some more %lu with %zu
* remove panics where they are not needed in s390 and in printk
* collect Acked-by and Reviewed-by.Christophe Leroy (1):
powerpc: use memblock functions returning virtual addressMike Rapoport (20):
openrisc: prefer memblock APIs returning virtual address
memblock: replacememblock_alloc_base(ANYWHERE)withmemblock_phys_alloc
memblock: dropmemblock_alloc_base_nid()
memblock: emphasize thatmemblock_alloc_range()returns a physical address
memblock:memblock_phys_alloc_try_nid(): don't panic
memblock:memblock_phys_alloc(): don't panic
memblock: drop__memblock_alloc_base()
memblock: dropmemblock_alloc_base()
memblock: refactor internal allocation functions
memblock: makememblock_find_in_range_node()andchoose_memblock_flags()static
arch: usememblock_alloc()instead ofmemblock_alloc_from(size, align, 0)
arch: don't memset(0) memory returned bymemblock_alloc()
Quoted 9 lines
ia64: add checks for the return value of memblock_alloc*()
sparc: add checks for the return value of memblock_alloc*() mm/percpu: add checks for the return value of memblock_alloc*() init/main: add checks for the return value of memblock_alloc*()
swiotlb: add checks for the return value of memblock_alloc*()
treewide: add checks for the return value of memblock_alloc*()
memblock:memblock_alloc_try_nid: don't panic
memblock: drop memblock_alloc_*_nopanic() variants
I know it's rather late, but this patch broke the Etnaviv 3D graphics in my i.MX6Q.
When I try to use the 3D, it returns some errors and the dmesg log shows some memory allocation errors too:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside valid memory window [ 3.760583] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.766766] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0 [ 3.776131] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0
# glmark2-es2-drm Error creating gpu Error: eglCreateWindowSurface failed with error: 0x3009 Error: eglCreateWindowSurface failed with error: 0x3009 Error: CanvasGeneric: Invalid EGL state Error: main: Could not initialize canvas
Before this patch:
[ 3.691995] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.698356] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.704792] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.710488] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.733649] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.756115] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.762250] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0 [ 3.771432] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0
and the 3D gemos work without this.
I don't know enough about the i.MX6 nor the 3D accelerator to know how to fix it.
I am hoping someone in the know might have some suggestions.
Quoted 131 lines
arch/alpha/kernel/core_cia.c | 5 +- arch/alpha/kernel/core_marvel.c | 6 + arch/alpha/kernel/pci-noop.c | 13 +- arch/alpha/kernel/pci.c | 11 +- arch/alpha/kernel/pci_iommu.c | 16 +- arch/alpha/kernel/setup.c | 2 +- arch/arc/kernel/unwind.c | 3 +- arch/arc/mm/highmem.c | 4 + arch/arm/kernel/setup.c | 6 + arch/arm/mm/init.c | 6 +- arch/arm/mm/mmu.c | 14 +- arch/arm64/kernel/setup.c | 8 +- arch/arm64/mm/kasan_init.c | 10 ++ arch/arm64/mm/mmu.c | 2 + arch/arm64/mm/numa.c | 4 + arch/c6x/mm/dma-coherent.c | 4 + arch/c6x/mm/init.c | 4 +- arch/csky/mm/highmem.c | 5 + arch/h8300/mm/init.c | 4 +- arch/ia64/kernel/mca.c | 25 +-- arch/ia64/mm/contig.c | 8 +- arch/ia64/mm/discontig.c | 4 + arch/ia64/mm/init.c | 38 ++++- arch/ia64/mm/tlb.c | 6 + arch/ia64/sn/kernel/io_common.c | 3 + arch/ia64/sn/kernel/setup.c | 12 +- arch/m68k/atari/stram.c | 4 + arch/m68k/mm/init.c | 3 + arch/m68k/mm/mcfmmu.c | 7 +- arch/m68k/mm/motorola.c | 9 ++ arch/m68k/mm/sun3mmu.c | 6 + arch/m68k/sun3/sun3dvma.c | 3 + arch/microblaze/mm/init.c | 10 +- arch/mips/cavium-octeon/dma-octeon.c | 3 + arch/mips/kernel/setup.c | 3 + arch/mips/kernel/traps.c | 5 +- arch/mips/mm/init.c | 5 + arch/nds32/mm/init.c | 12 ++ arch/openrisc/mm/init.c | 5 +- arch/openrisc/mm/ioremap.c | 8 +- arch/powerpc/kernel/dt_cpu_ftrs.c | 8 +- arch/powerpc/kernel/irq.c | 5 - arch/powerpc/kernel/paca.c | 6 +- arch/powerpc/kernel/pci_32.c | 3 + arch/powerpc/kernel/prom.c | 5 +- arch/powerpc/kernel/rtas.c | 6 +- arch/powerpc/kernel/setup-common.c | 3 + arch/powerpc/kernel/setup_32.c | 26 ++-- arch/powerpc/kernel/setup_64.c | 4 + arch/powerpc/lib/alloc.c | 3 + arch/powerpc/mm/hash_utils_64.c | 11 +- arch/powerpc/mm/mmu_context_nohash.c | 9 ++ arch/powerpc/mm/numa.c | 4 + arch/powerpc/mm/pgtable-book3e.c | 12 +- arch/powerpc/mm/pgtable-book3s64.c | 3 + arch/powerpc/mm/pgtable-radix.c | 9 +- arch/powerpc/mm/ppc_mmu_32.c | 3 + arch/powerpc/platforms/pasemi/iommu.c | 3 + arch/powerpc/platforms/powermac/nvram.c | 3 + arch/powerpc/platforms/powernv/opal.c | 3 + arch/powerpc/platforms/powernv/pci-ioda.c | 8 + arch/powerpc/platforms/ps3/setup.c | 3 + arch/powerpc/sysdev/dart_iommu.c | 3 + arch/powerpc/sysdev/msi_bitmap.c | 3 + arch/s390/kernel/crash_dump.c | 3 + arch/s390/kernel/setup.c | 16 ++ arch/s390/kernel/smp.c | 9 +- arch/s390/kernel/topology.c | 6 + arch/s390/numa/mode_emu.c | 3 + arch/s390/numa/numa.c | 6 +- arch/sh/boards/mach-ap325rxa/setup.c | 5 +- arch/sh/boards/mach-ecovec24/setup.c | 10 +- arch/sh/boards/mach-kfr2r09/setup.c | 5 +- arch/sh/boards/mach-migor/setup.c | 5 +- arch/sh/boards/mach-se/7724/setup.c | 10 +- arch/sh/kernel/machine_kexec.c | 3 +- arch/sh/mm/init.c | 8 +- arch/sh/mm/numa.c | 4 + arch/sparc/kernel/prom_32.c | 6 +- arch/sparc/kernel/setup_64.c | 6 + arch/sparc/kernel/smp_64.c | 12 ++ arch/sparc/mm/init_32.c | 2 +- arch/sparc/mm/init_64.c | 11 ++ arch/sparc/mm/srmmu.c | 18 ++- arch/um/drivers/net_kern.c | 3 + arch/um/drivers/vector_kern.c | 3 + arch/um/kernel/initrd.c | 2 + arch/um/kernel/mem.c | 16 ++ arch/unicore32/kernel/setup.c | 4 + arch/unicore32/mm/mmu.c | 15 +- arch/x86/kernel/acpi/boot.c | 3 + arch/x86/kernel/apic/io_apic.c | 5 + arch/x86/kernel/e820.c | 5 +- arch/x86/kernel/setup_percpu.c | 10 +- arch/x86/mm/kasan_init_64.c | 14 +- arch/x86/mm/numa.c | 12 +- arch/x86/platform/olpc/olpc_dt.c | 3 + arch/x86/xen/p2m.c | 11 +- arch/xtensa/mm/kasan_init.c | 10 +- arch/xtensa/mm/mmu.c | 3 + drivers/clk/ti/clk.c | 3 + drivers/firmware/memmap.c | 2 +- drivers/macintosh/smu.c | 5 +- drivers/of/fdt.c | 8 +- drivers/of/of_reserved_mem.c | 7 +- drivers/of/unittest.c | 8 +- drivers/usb/early/xhci-dbc.c | 2 +- drivers/xen/swiotlb-xen.c | 7 +- include/linux/memblock.h | 59 +------ init/main.c | 26 +++- kernel/dma/swiotlb.c | 21 ++- kernel/power/snapshot.c | 3 + kernel/printk/printk.c | 9 +- lib/cpumask.c | 3 + mm/cma.c | 10 +- mm/kasan/init.c | 10 +- mm/memblock.c | 249 ++++++++++-------------------- mm/page_alloc.c | 10 +- mm/page_ext.c | 2 +- mm/percpu.c | 84 +++++++--- mm/sparse.c | 25 ++- 121 files changed, 860 insertions(+), 412 deletions(-)--
2.7.4_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
(updated CC)
Hi,
Quoted 35 lines · Adam Ford
Quoted 25 lines · Mike Rapoport
Hi,
v2 changes:
* replace some more %lu with %zu
* remove panics where they are not needed in s390 and in printk
* collect Acked-by and Reviewed-by.Christophe Leroy (1):
powerpc: use memblock functions returning virtual addressMike Rapoport (20):
openrisc: prefer memblock APIs returning virtual address
memblock: replacememblock_alloc_base(ANYWHERE)withmemblock_phys_alloc
memblock: dropmemblock_alloc_base_nid()
memblock: emphasize thatmemblock_alloc_range()returns a physical address
memblock:memblock_phys_alloc_try_nid(): don't panic
memblock:memblock_phys_alloc(): don't panic
memblock: drop__memblock_alloc_base()
memblock: dropmemblock_alloc_base()
memblock: refactor internal allocation functions
memblock: makememblock_find_in_range_node()andchoose_memblock_flags()static
arch: usememblock_alloc()instead ofmemblock_alloc_from(size, align, 0)
arch: don't memset(0) memory returned bymemblock_alloc()Quoted 9 lines
ia64: add checks for the return value of memblock_alloc*()
sparc: add checks for the return value of memblock_alloc*() mm/percpu: add checks for the return value of memblock_alloc*() init/main: add checks for the return value of memblock_alloc*()
swiotlb: add checks for the return value of memblock_alloc*()
treewide: add checks for the return value of memblock_alloc*()
memblock:memblock_alloc_try_nid: don't panic
memblock: drop memblock_alloc_*_nopanic() variants
Quoted 2 lines
I know it's rather late, but this patch broke the Etnaviv 3D graphics in my i.MX6Q.
Can you identify the exact patch from the series that caused the regression?
Quoted 34 lines
When I try to use the 3D, it returns some errors and the dmesg log shows some memory allocation errors too:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside valid memory window [ 3.760583] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.766766] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0 [ 3.776131] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0# glmark2-es2-drm Error creating gpu Error: eglCreateWindowSurface failed with error: 0x3009 Error: eglCreateWindowSurface failed with error: 0x3009 Error: CanvasGeneric: Invalid EGL state Error: main: Could not initialize canvasBefore this patch:
[ 3.691995] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.698356] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.704792] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.710488] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.733649] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.756115] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.762250] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0 [ 3.771432] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0
Quoted 5 lines
and the 3D gemos work without this.
I don't know enough about the i.MX6 nor the 3D accelerator to know how to fix it.
I am hoping someone in the know might have some suggestions.
Can you please add "memblock=debug" to your kernel command line and send kernel logs for both working and failing versions?
Signature · 2 lines
Sincerely yours, Mike.
Hi Adam,
Quoted 13 lines · Adam Ford
I know it's rather late, but this patch broke the Etnaviv 3D graphics in my i.MX6Q.
When I try to use the 3D, it returns some errors and the dmesg log shows some memory allocation errors too:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside valid
Quoted 1 line
memory window
This looks similar to what was reported at:
https://bugs.freedesktop.org/show_bug.cgi?id=111789
Does it help if you use the same suggestion and pass cma=256M in your kernel command line?
Quoted 20 lines · Fabio Estevam
Hi Adam,
Quoted 13 lines · Adam Ford
I know it's rather late, but this patch broke the Etnaviv 3D graphics in my i.MX6Q.
When I try to use the 3D, it returns some errors and the dmesg log shows some memory allocation errors too:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside validQuoted 1 line
memory window
Quoted 5 lines
This looks similar to what was reported at:
https://bugs.freedesktop.org/show_bug.cgi?id=111789Does it help if you use the same suggestion and pass cma=256M in your kernel command line?
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like imx6ul-ccimx6ulsom.dtsi did?
adam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?
I don't think so.
Were you able to identify what was the exact commit that caused such regression?
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the 92d12f9544b7 ("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.
I also noticed that if I create a reserved memory node as was done one imx6ul-ccimx6ulsom.dtsi the 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?
adam
Hi,
Quoted 8 lines · Adam Ford
Quoted 7 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?
Quoted 7 lines
Quoted 3 lines
I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.
Can you please test with this change:
mm/memblock.c +0 -3
@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);
Quoted 9 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
Signature · 2 lines
Sincerely yours, Mike.
Quoted 14 lines · Mike Rapoport
Hi,
Quoted 10 lines · Adam Ford
Quoted 9 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
adam
Quoted 29 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
--
Sincerely yours,
Mike.
Quoted 22 lines · Adam Ford
Quoted 21 lines · Mike Rapoport
Hi,
Quoted 15 lines · Adam Ford
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.
Quoted 5 lines
Quoted 2 lines
Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
It's not really a fix, I just wanted to see how exactly 92d12f9544b7 ("memblock:
refactor internal allocation functions") broke your setup.
Can you share the dts you are using and the full kernel log?
Quoted 31 lines
adam
Quoted 29 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
--
Sincerely yours,
Mike.
Signature · 2 lines
Sincerely yours, Mike.
I am attaching two logs. I now the mailing lists will be unhappy, but
don't want to try and spam a bunch of log through the mailing liast.
The two logs show the differences between the working and non-working imx6q 3D accelerator when trying to run a simple glmark2-es2-drm demo.
The only change between them is the 2 line code change you suggested.
In both cases, I have cma=128M set in my bootargs. Historically this has been sufficient, but cma=256M has not made a difference.
adam
Quoted 62 lines · Mike Rapoport
Quoted 22 lines · Adam Ford
Quoted 21 lines · Mike Rapoport
Hi,
Quoted 15 lines · Adam Ford
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.Quoted 5 lines
Quoted 2 lines
Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
It's not really a fix, I just wanted to see how exactly
92d12f9544b7("memblock:
refactor internal allocation functions") broke your setup.Can you share the dts you are using and the full kernel log?
Quoted 27 lines
adam
Quoted 25 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
--
Sincerely yours,
Mike.--
Sincerely yours,
Mike.
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 5.3.1-dirty (aford@aford-IdeaCentre-A730) (gcc version 8.3.0 (Buildroot 2019.02.5-00192-gcd72d5bf57-dirty)) #2 SMP Sun Sep 29 08:26:09 CDT 2019 [ 0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] OF: fdt: Machine model: Logic PD i.MX6QD SOM-M3 [ 0.000000] printk: debug: ignoring loglevel setting. [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] cma: Reserved 128 MiB at 0x88000000 [ 0.000000] On node 0 totalpages: 524288 [ 0.000000] Normal zone: 1536 pages used for memmap [ 0.000000] Normal zone: 0 pages reserved [ 0.000000] Normal zone: 196608 pages, LIFO batch:63 [ 0.000000] HighMem zone: 327680 pages, LIFO batch:63 [ 0.000000] percpu: Embedded 21 pages/cpu s54632 r8192 d23192 u86016 [ 0.000000] pcpu-alloc: s54632 r8192 d23192 u86016 alloc=21*4096 [ 0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 522752 [ 0.000000] Kernel command line: console=ttymxc0,115200 root=PARTUUID=60f4e103-02 rootwait rw ignore_loglevel cma=128M [ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear) [ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 1922048K/2097152K available (12288K kernel code, 956K rwdata, 4252K rodata, 1024K init, 6920K bss, 44032K reserved, 131072K cma-reserved, 1179648K highmem) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 [ 0.000000] Running RCU self tests [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] rcu: RCU event tracing is enabled. [ 0.000000] rcu: RCU lockdep checking is enabled. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies. [ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 [ 0.000000] L2C-310 errata 752271 769419 enabled [ 0.000000] L2C-310 enabling early BRESP for Cortex-A9 [ 0.000000] L2C-310 full line of zeros enabled for Cortex-A9 [ 0.000000] L2C-310 ID prefetch enabled, offset 16 lines [ 0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled [ 0.000000] L2C-310 cache controller enabled, 16 ways, 1024 kB [ 0.000000] L2C-310: CACHE_ID 0x410000c7, AUX_CTRL 0x76470001 [ 0.000000] random: get_random_bytes called from start_kernel+0x2f4/0x504 with crng_init=0 [ 0.000000] Switching to timer-based delay loop, resolution 333ns [ 0.000008] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns [ 0.000034] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns [ 0.001789] Console: colour dummy device 80x30 [ 0.001830] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar [ 0.001847] ... MAX_LOCKDEP_SUBCLASSES: 8 [ 0.001864] ... MAX_LOCK_DEPTH: 48 [ 0.001880] ... MAX_LOCKDEP_KEYS: 8192 [ 0.001897] ... CLASSHASH_SIZE: 4096 [ 0.001913] ... MAX_LOCKDEP_ENTRIES: 32768 [ 0.001929] ... MAX_LOCKDEP_CHAINS: 65536 [ 0.001945] ... CHAINHASH_SIZE: 32768 [ 0.001961] memory used by lock dependency info: 4413 kB [ 0.001977] per task-struct memory footprint: 1536 bytes [ 0.002080] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000) [ 0.002109] pid_max: default: 32768 minimum: 301 [ 0.002458] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear) [ 0.002495] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear) [ 0.005590] CPU: Testing write buffer coherency: ok [ 0.005678] CPU0: Spectre v2: using BPIALL workaround [ 0.006996] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.009303] Setting up static identity map for 0x10100000 - 0x10100078 [ 0.010190] rcu: Hierarchical SRCU implementation. [ 0.011740] smp: Bringing up secondary CPUs ... [ 0.014217] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 [ 0.014228] CPU1: Spectre v2: using BPIALL workaround [ 0.016979] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002 [ 0.016991] CPU2: Spectre v2: using BPIALL workaround [ 0.019187] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003 [ 0.019198] CPU3: Spectre v2: using BPIALL workaround [ 0.019789] smp: Brought up 1 node, 4 CPUs [ 0.019813] SMP: Total of 4 processors activated (24.00 BogoMIPS). [ 0.019833] CPU: All CPU(s) started in SVC mode. [ 0.022517] devtmpfs: initialized [ 0.053207] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 [ 0.055505] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.055572] futex hash table entries: 1024 (order: 4, 65536 bytes, linear) [ 0.063395] pinctrl core: initialized pinctrl subsystem [ 0.068304] NET: Registered protocol family 16 [ 0.088841] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.092073] cpuidle: using governor menu [ 0.092372] CPU identified as i.MX6Q, silicon rev 1.5 [ 0.112034] vdd1p1: supplied by regulator-dummy [ 0.113817] vdd3p0: supplied by regulator-dummy [ 0.115083] vdd2p5: supplied by regulator-dummy [ 0.117458] vddpu: supplied by regulator-dummy [ 0.147316] No ATAGs? [ 0.147778] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers. [ 0.147868] hw-breakpoint: maximum watchpoint size is 4 bytes. [ 0.151803] imx6q-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver [ 0.244029] mxs-dma 110000.dma-apbh: initialized [ 0.338934] 3v3_aud: supplied by reg_3v3 [ 0.340173] hdmi-supply: supplied by reg_3v3 [ 0.341400] uart3-supply: supplied by reg_3v3 [ 0.342592] 1v8-supply: supplied by reg_3v3 [ 0.345761] lcd_panel_pwr: supplied by reg_3v3 [ 0.346945] nLCD_RESET: supplied by lcd_panel_pwr [ 0.350401] vgaarb: loaded [ 0.351996] SCSI subsystem initialized [ 0.352602] libata version 3.00 loaded. [ 0.353403] usbcore: registered new interface driver usbfs [ 0.353619] usbcore: registered new interface driver hub [ 0.353880] usbcore: registered new device driver usb [ 0.354344] usb_phy_generic usbphynop1: usbphynop1 supply vcc not found, using dummy regulator [ 0.355073] usb_phy_generic usbphynop2: usbphynop2 supply vcc not found, using dummy regulator [ 0.358862] i2c i2c-0: IMX I2C adapter registered [ 0.379070] pcf857x 2-0020: probed [ 0.379271] i2c i2c-2: IMX I2C adapter registered [ 0.379696] mc: Linux media interface: v0.10 [ 0.379820] videodev: Linux video capture interface: v2.00 [ 0.380296] pps_core: LinuxPPS API ver. 1 registered [ 0.380321] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]> [ 0.380379] PTP clock support registered [ 0.381312] Advanced Linux Sound Architecture Driver Initialized. [ 0.384978] Bluetooth: Core ver 2.22 [ 0.385099] NET: Registered protocol family 31 [ 0.385123] Bluetooth: HCI device and connection manager initialized [ 0.385236] Bluetooth: HCI socket layer initialized [ 0.385270] Bluetooth: L2CAP socket layer initialized [ 0.385418] Bluetooth: SCO socket layer initialized [ 0.387794] clocksource: Switched to clocksource mxc_timer1 [ 1.094855] VFS: Disk quotas dquot_6.6.0 [ 1.095033] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [ 1.121459] thermal_sys: Registered thermal governor 'step_wise' [ 1.122193] NET: Registered protocol family 2 [ 1.123985] tcp_listen_portaddr_hash hash table entries: 512 (order: 2, 20480 bytes, linear) [ 1.124117] TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear) [ 1.124289] TCP bind hash table entries: 8192 (order: 6, 294912 bytes, linear) [ 1.125364] TCP: Hash tables configured (established 8192 bind 8192) [ 1.125975] UDP hash table entries: 512 (order: 3, 40960 bytes, linear) [ 1.126172] UDP-Lite hash table entries: 512 (order: 3, 40960 bytes, linear) [ 1.126733] NET: Registered protocol family 1 [ 1.129132] RPC: Registered named UNIX socket transport module. [ 1.129219] RPC: Registered udp transport module. [ 1.129242] RPC: Registered tcp transport module. [ 1.129265] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 1.130329] PCI: CLS 0 bytes, default 64 [ 1.132382] hw perfevents: no interrupt-affinity property for /pmu, guessing. [ 1.133033] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available [ 1.137893] Initialise system trusted keyrings [ 1.138546] workingset: timestamp_bits=30 max_order=19 bucket_order=0 [ 1.156067] NFS: Registering the id_resolver key type [ 1.156247] Key type id_resolver registered [ 1.156339] Key type id_legacy registered [ 1.156535] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc. [ 1.157908] fuse: init (API version 7.31) [ 1.197152] Key type asymmetric registered [ 1.197292] Asymmetric key parser 'x509' registered [ 1.197558] bounce: pool size: 64 pages [ 1.197765] io scheduler mq-deadline registered [ 1.197791] io scheduler kyber registered [ 1.205113] imx6q-pcie 1ffc000.pcie: host bridge /soc/pcie@1ffc000 ranges: [ 1.205311] imx6q-pcie 1ffc000.pcie: IO 0x01f80000..0x01f8ffff -> 0x00000000 [ 1.205517] imx6q-pcie 1ffc000.pcie: MEM 0x01000000..0x01efffff -> 0x01000000 [ 1.216186] imx-sdma 20ec000.sdma: Direct firmware load for imx/sdma/sdma-imx6q.bin failed with error -2 [ 1.216285] imx-sdma 20ec000.sdma: Falling back to sysfs fallback for: imx/sdma/sdma-imx6q.bin [ 1.219974] imx-pgc-pd imx-pgc-power-domain.0: DMA mask not set [ 1.220501] imx-pgc-pd imx-pgc-power-domain.1: DMA mask not set [ 1.224576] pfuze100-regulator 2-0008: Full layer: 2, Metal layer: 1 [ 1.225450] pfuze100-regulator 2-0008: FAB: 0, FIN: 0 [ 1.225477] pfuze100-regulator 2-0008: pfuze100 found. [ 1.236518] gen_rgmii: Bringing 1200000uV into 1800000-1800000uV [ 1.244362] gen_1v5: Bringing 800000uV into 1500000-1500000uV [ 1.258150] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 27, base_baud = 5000000) is a IMX [ 2.186716] printk: console [ttymxc0] enabled [ 2.194531] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 71, base_baud = 5000000) is a IMX [ 2.203691] serial serial0: tty port ttymxc1 registered [ 2.209751] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 72, base_baud = 5000000) is a IMX [ 2.243501] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 2.249909] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 2.256133] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 2.261897] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 2.284606] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 2.307108] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 2.313317] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0 [ 2.318423] imx6q-pcie 1ffc000.pcie: Phy link never came up [ 2.322201] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0 [ 2.329081] imx6q-pcie 1ffc000.pcie: PCI host bridge to bus 0000:00 [ 2.336535] imx-ipuv3 2400000.ipu: IPUv3H probed [ 2.338673] pci_bus 0000:00: root bus resource [bus 00-ff] [ 2.345806] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013). [ 2.348720] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] [ 2.355358] [drm] No driver support for vblank timestamp query. [ 2.361594] pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff] [ 2.368870] imx-drm display-subsystem: bound imx-ipuv3-crtc.2 (ops ipu_crtc_ops) [ 2.374751] pci 0000:00:00.0: [16c3:abcd] type 01 class 0x060400 [ 2.382181] imx-drm display-subsystem: bound imx-ipuv3-crtc.3 (ops ipu_crtc_ops) [ 2.387983] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x000fffff] [ 2.395661] imx-drm display-subsystem: bound imx-ipuv3-crtc.6 (ops ipu_crtc_ops) [ 2.401673] pci 0000:00:00.0: reg 0x38: [mem 0x00000000-0x0000ffff pref] [ 2.409370] imx-drm display-subsystem: bound imx-ipuv3-crtc.7 (ops ipu_crtc_ops) [ 2.416114] pci 0000:00:00.0: supports D1 [ 2.424219] dwhdmi-imx 120000.hdmi: Detected HDMI TX controller v1.30a with HDCP (DWC HDMI 3D TX PHY) [ 2.427274] pci 0000:00:00.0: PME# supported from D0 D1 D3hot D3cold [ 2.441298] imx-drm display-subsystem: bound 120000.hdmi (ops dw_hdmi_imx_ops) [ 2.448214] PCI: bus0: Fast back to back transfers disabled [ 2.450777] imx-drm display-subsystem: bound ldb (ops imx_ldb_ops) [ 2.460053] PCI: bus1: Fast back to back transfers enabled [ 2.464526] [drm] Initialized imx-drm 1.0.0 20120507 for display-subsystem on minor 1 [ 2.467468] pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff] [ 2.482301] pci 0000:00:00.0: BAR 6: assigned [mem 0x01100000-0x0110ffff pref] [ 2.489612] pci 0000:00:00.0: PCI bridge to [bus 01-ff] [ 3.168314] Console: switching to colour frame buffer device 100x30 [ 3.190946] imx-drm display-subsystem: fb0: imx-drmdrmfb frame buffer device [ 3.198619] imx-ipuv3 2800000.ipu: IPUv3H probed [ 3.227753] brd: module loaded [ 3.261972] loop: module loaded [ 3.267561] at24 2-0051: 8192 byte 24c64 EEPROM, read-only, 0 bytes/write [ 3.276254] at24 2-0052: 8192 byte 24c64 EEPROM, writable, 32 bytes/write [ 3.291472] nand: No NAND device found [ 3.300111] libphy: Fixed MDIO Bus: probed [ 3.305513] CAN device driver interface [ 3.312029] ethernet-supply: supplied by gen_rgmii [ 3.410748] pps pps0: new PPS source ptp0 [ 3.416150] fec 2188000.ethernet: Invalid MAC address: 00:00:00:00:00:00 [ 3.422967] fec 2188000.ethernet: Using random MAC address: 6e:c7:5f:d3:58:ee [ 3.438612] libphy: fec_enet_mii_bus: probed [ 3.444226] fec 2188000.ethernet eth0: registered PHC device 0 [ 3.451991] usbcore: registered new interface driver r8152 [ 3.457589] usbcore: registered new interface driver lan78xx [ 3.463456] usbcore: registered new interface driver asix [ 3.469019] usbcore: registered new interface driver ax88179_178a [ 3.475215] usbcore: registered new interface driver cdc_ether [ 3.481248] usbcore: registered new interface driver smsc95xx [ 3.487094] usbcore: registered new interface driver net1080 [ 3.492902] usbcore: registered new interface driver cdc_subset [ 3.498971] usbcore: registered new interface driver zaurus [ 3.504641] usbcore: registered new interface driver MOSCHIP usb-ethernet driver [ 3.512245] usbcore: registered new interface driver cdc_ncm [ 3.517976] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 3.524524] ehci-pci: EHCI PCI platform driver [ 3.529274] ehci-mxc: Freescale On-Chip EHCI Host driver [ 3.535486] usbcore: registered new interface driver usb-storage [ 3.554389] imx_usb 2184200.usb: No over current polarity defined [ 3.620331] random: fast init done [ 3.647822] ci_hdrc ci_hdrc.1: EHCI Host Controller [ 3.653013] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1 [ 3.687816] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00 [ 3.694565] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.03 [ 3.703046] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 3.710354] usb usb1: Product: EHCI Host Controller [ 3.715255] usb usb1: Manufacturer: Linux 5.3.1-dirty ehci_hcd [ 3.721158] usb usb1: SerialNumber: ci_hdrc.1 [ 3.728664] hub 1-0:1.0: USB hub found [ 3.732688] hub 1-0:1.0: 1 port detected [ 3.749417] snvs_rtc 20cc000.snvs:snvs-rtc-lp: registered as rtc0 [ 3.755910] i2c /dev entries driver [ 3.769530] imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0) [ 3.776228] Bluetooth: HCI UART driver ver 2.3 [ 3.780779] Bluetooth: HCI UART protocol H4 registered [ 3.786052] Bluetooth: HCI UART protocol LL registered [ 3.793239] sdhci: Secure Digital Host Controller Interface driver [ 3.799499] sdhci: Copyright(c) Pierre Ossman [ 3.803880] sdhci-pltfm: SDHCI platform and OF driver helper [ 3.849515] mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA [ 3.860054] sdhci-esdhc-imx 2194000.usdhc: Got CD GPIO [ 3.880865] hci-ti serial0-0: Direct firmware load for ti-connectivity/TIInit_11.8.32.bts failed with error -2 [ 3.891142] hci-ti serial0-0: Falling back to sysfs fallback for: ti-connectivity/TIInit_11.8.32.bts [ 3.901922] mmc1: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA [ 3.954146] mmc0: new DDR MMC card at address 0001 [ 3.963605] mmcblk0: mmc0:0001 DG4008 7.28 GiB [ 3.970467] mmcblk0boot0: mmc0:0001 DG4008 partition 1 4.00 MiB [ 3.978727] mmcblk0boot1: mmc0:0001 DG4008 partition 2 4.00 MiB [ 3.985780] mmcblk0rpmb: mmc0:0001 DG4008 partition 3 4.00 MiB, chardev (244:0) [ 3.998615] mmcblk0: p1 p2 [ 4.028897] mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA [ 4.046580] sdhci-esdhc-imx 2198000.usdhc: card claims to support voltages below defined range [ 4.050278] caam 2100000.caam: Entropy delay = 3200 [ 4.082262] mmc2: new high speed SDIO card at address 0001 [ 4.107835] usb 1-1: new high-speed USB device number 2 using ci_hdrc [ 4.121069] caam 2100000.caam: Instantiated RNG4 SH0 [ 4.181828] caam 2100000.caam: Instantiated RNG4 SH1 [ 4.186825] caam 2100000.caam: device ID = 0x0a16010000000000 (Era 4) [ 4.193357] caam 2100000.caam: job rings = 2, qi = 0 [ 4.205787] mmc1: host does not support reading read-only switch, assuming write-enable [ 4.223295] mmc1: new high speed SDHC card at address aaaa [ 4.232112] mmcblk1: mmc1:aaaa SL32G 29.7 GiB [ 4.242765] mmcblk1: p1 p2 [ 4.249727] caam algorithms registered in /proc/crypto [ 4.265783] caam_jr 2101000.jr0: registering rng-caam [ 4.274554] usbcore: registered new interface driver usbhid [ 4.280514] usbhid: USB HID core driver [ 4.288287] ipu1_csi0: Registered ipu1_csi0 capture as /dev/video0 [ 4.295992] ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video1 [ 4.304611] ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video2 [ 4.311673] imx-media: ipu1_csi0:1 -> ipu1_ic_prp:0 [ 4.316749] imx-media: ipu1_csi0:1 -> ipu1_vdic:0 [ 4.321582] imx-media: ipu1_vdic:2 -> ipu1_ic_prp:0 [ 4.326487] imx-media: ipu1_ic_prp:1 -> ipu1_ic_prpenc:0 [ 4.328921] usb 1-1: New USB device found, idVendor=0424, idProduct=2514, bcdDevice= b.b3 [ 4.331868] imx-media: ipu1_ic_prp:2 -> ipu1_ic_prpvf:0 [ 4.340129] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 4.345348] imx-media: subdev ipu1_csi0 bound [ 4.354672] hub 1-1:1.0: USB hub found [ 4.357894] ipu1_csi1: Registered ipu1_csi1 capture as /dev/video3 [ 4.361148] hub 1-1:1.0: 4 ports detected [ 4.366918] imx-media: ipu1_csi1:1 -> ipu1_ic_prp:0 [ 4.376071] imx-media: ipu1_csi1:1 -> ipu1_vdic:0 [ 4.380851] imx-media: subdev ipu1_csi1 bound [ 4.386180] ipu2_csi0: Registered ipu2_csi0 capture as /dev/video4 [ 4.392988] ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video5 [ 4.400707] ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video6 [ 4.407658] imx-media: ipu2_csi0:1 -> ipu2_ic_prp:0 [ 4.412645] imx-media: ipu2_csi0:1 -> ipu2_vdic:0 [ 4.417374] imx-media: ipu2_vdic:2 -> ipu2_ic_prp:0 [ 4.422333] imx-media: ipu2_ic_prp:1 -> ipu2_ic_prpenc:0 [ 4.427719] imx-media: ipu2_ic_prp:2 -> ipu2_ic_prpvf:0 [ 4.432983] imx-media: subdev ipu2_csi0 bound [ 4.438300] ipu2_csi1: Registered ipu2_csi1 capture as /dev/video7 [ 4.444512] imx-media: ipu2_csi1:1 -> ipu2_ic_prp:0 [ 4.449479] imx-media: ipu2_csi1:1 -> ipu2_vdic:0 [ 4.454213] imx-media: subdev ipu2_csi1 bound [ 4.475738] wm8962 0-001a: customer id 0 revision F [ 4.495480] fsl-asoc-card sound: ASoC: failed to init link HiFi: -517 [ 4.505628] fsl-ssi-dai 202c000.ssi: No cache defaults, reading back from HW [ 4.519683] NET: Registered protocol family 10 [ 4.527909] Segment Routing with IPv6 [ 4.531709] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 4.539595] NET: Registered protocol family 17 [ 4.544094] can: controller area network core (rev 20170425 abi 9) [ 4.550553] NET: Registered protocol family 29 [ 4.555032] can: raw protocol (rev 20170425) [ 4.559508] can: broadcast manager protocol (rev 20170425 t) [ 4.565211] can: netlink gateway (rev 20170425) max_hops=1 [ 4.571177] Key type dns_resolver registered [ 4.577482] vddarm: supplied by vddcore [ 4.582166] vddsoc: supplied by vddsoc [ 4.593690] Registering SWP/SWPB emulation handler [ 4.602141] Loading compiled-in X.509 certificates [ 4.683401] imx_thermal tempmon: Automotive CPU temperature grade - max:125C critical:120C passive:115C [ 4.698779] input: WM8962 Beep Generator as /devices/soc0/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-001a/input/input0 [ 4.769278] fsl-asoc-card sound: wm8962 <-> 202c000.ssi mapping ok [ 4.797269] input: keyboard as /devices/soc0/keyboard/input/input1 [ 4.807487] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01T00:06:48 UTC (408) [ 4.817105] cfg80211: Loading compiled-in X.509 certificates for regulatory database [ 4.829867] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7' [ 4.837909] vwl1837: disabling [ 4.837918] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2 [ 4.841021] platform regulatory.0: Falling back to sysfs fallback for: regulatory.db [ 4.857519] usb_otg_vbus: disabling [ 4.861153] 3v3_aud: disabling [ 4.864241] mipi_pwr_en: disabling [ 4.867796] ALSA device list: [ 4.870790] #0: wm8962-audio [ 4.911663] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null) [ 4.920736] VFS: Mounted root (ext4 filesystem) on device 179:26. [ 4.933364] devtmpfs: mounted [ 4.939135] Freeing unused kernel memory: 1024K [ 4.944644] Run /sbin/init as init process [ 5.249968] EXT4-fs (mmcblk1p2): re-mounted. Opts: (null) Starting syslogd: OK Starting klogd: OK Populating /dev using udev: [ 6.520602] udevd[286]: starting version 3.2.7 [ 6.570851] random: udevd: uninitialized urandom read (16 bytes read) [ 6.582136] random: udevd: uninitialized urandom read (16 bytes read) [ 6.588854] random: udevd: uninitialized urandom read (16 bytes read) [ 6.611962] udevd[286]: specified group 'kvm' unknown [ 6.653875] udevd[288]: starting eudev-3.2.7 [ 7.050422] evbug: Connected device: input0 (WM8962 Beep Generator at 0-001a) [ 7.064244] evbug: Connected device: input1 (keyboard at gpio-keys/input0) [ 7.171694] coda 2040000.vpu: Direct firmware load for vpu_fw_imx6q.bin failed with error -2 [ 7.180268] coda 2040000.vpu: Falling back to sysfs fallback for: vpu_fw_imx6q.bin [ 7.288552] imx-media: ipu1_csi0_mux:2 -> ipu1_csi0:0 [ 7.293716] imx-media: imx6-mipi-csi2:2 -> ipu1_csi1:0 [ 7.298987] imx-media: imx6-mipi-csi2:3 -> ipu2_csi0:0 [ 7.304211] imx-media: ipu2_csi1_mux:2 -> ipu2_csi1:0 [ 7.309478] imx-media: imx6-mipi-csi2:1 -> ipu1_csi0_mux:0 [ 7.315134] imx-media: imx6-mipi-csi2:4 -> ipu2_csi1_mux:0 [ 7.320778] imx-media: ov5640 2-0010:0 -> imx6-mipi-csi2:0 [ 7.768023] wl18xx_driver wl18xx.2.auto: Direct firmware load for ti-connectivity/wl18xx-conf.bin failed with error -2 [ 7.778814] wl18xx_driver wl18xx.2.auto: Falling back to sysfs fallback for: ti-connectivity/wl18xx-conf.bin done Initializing random number generator... [ 7.853723] urandom_read: 2 callbacks suppressed [ 7.853736] random: dd: uninitialized urandom read (512 bytes read) done. Starting rngd: OK [ 7.956291] random: crng init done
Starting system message bus: done
Starting network: OK
Starting sshd: OK
Welcome to Buildroot
buildroot login:
Welcome to Buildroot
buildroot login: root
# glmark2-es2-drm
=======================================================
glmark2 2014.03
=======================================================
OpenGL Information
GL_VENDOR: etnaviv
GL_RENDERER: Vivante GC2000 rev 5108
GL_VERSION: OpenGL ES 2.0 Mesa 18.3.3
=======================================================Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 5.3.1 (aford@aford-IdeaCentre-A730) (gcc version 8.3.0 (Buildroot 2019.02.5-00192-gcd72d5bf57-dirty)) #1 SMP Sun Sep 29 08:10:00 CDT 2019 [ 0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] OF: fdt: Machine model: Logic PD i.MX6QD SOM-M3 [ 0.000000] printk: debug: ignoring loglevel setting. [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] cma: Reserved 128 MiB at 0x38000000 [ 0.000000] On node 0 totalpages: 524288 [ 0.000000] Normal zone: 1536 pages used for memmap [ 0.000000] Normal zone: 0 pages reserved [ 0.000000] Normal zone: 196608 pages, LIFO batch:63 [ 0.000000] HighMem zone: 327680 pages, LIFO batch:63 [ 0.000000] percpu: Embedded 21 pages/cpu s54632 r8192 d23192 u86016 [ 0.000000] pcpu-alloc: s54632 r8192 d23192 u86016 alloc=21*4096 [ 0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 522752 [ 0.000000] Kernel command line: console=ttymxc0,115200 root=PARTUUID=60f4e103-02 rootwait rw ignore_loglevel cma=128M [ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear) [ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear) [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 1921792K/2097152K available (12288K kernel code, 956K rwdata, 4252K rodata, 1024K init, 6920K bss, 44288K reserved, 131072K cma-reserved, 1310720K highmem) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 [ 0.000000] Running RCU self tests [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] rcu: RCU event tracing is enabled. [ 0.000000] rcu: RCU lockdep checking is enabled. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies. [ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 [ 0.000000] L2C-310 errata 752271 769419 enabled [ 0.000000] L2C-310 enabling early BRESP for Cortex-A9 [ 0.000000] L2C-310 full line of zeros enabled for Cortex-A9 [ 0.000000] L2C-310 ID prefetch enabled, offset 16 lines [ 0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled [ 0.000000] L2C-310 cache controller enabled, 16 ways, 1024 kB [ 0.000000] L2C-310: CACHE_ID 0x410000c7, AUX_CTRL 0x76470001 [ 0.000000] random: get_random_bytes called from start_kernel+0x2f4/0x504 with crng_init=0 [ 0.000000] Switching to timer-based delay loop, resolution 333ns [ 0.000008] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns [ 0.000035] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns [ 0.001790] Console: colour dummy device 80x30 [ 0.001832] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar [ 0.001852] ... MAX_LOCKDEP_SUBCLASSES: 8 [ 0.001869] ... MAX_LOCK_DEPTH: 48 [ 0.001885] ... MAX_LOCKDEP_KEYS: 8192 [ 0.001902] ... CLASSHASH_SIZE: 4096 [ 0.001918] ... MAX_LOCKDEP_ENTRIES: 32768 [ 0.001934] ... MAX_LOCKDEP_CHAINS: 65536 [ 0.001949] ... CHAINHASH_SIZE: 32768 [ 0.001966] memory used by lock dependency info: 4413 kB [ 0.001981] per task-struct memory footprint: 1536 bytes [ 0.002081] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000) [ 0.002109] pid_max: default: 32768 minimum: 301 [ 0.002457] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear) [ 0.002494] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear) [ 0.005567] CPU: Testing write buffer coherency: ok [ 0.005655] CPU0: Spectre v2: using BPIALL workaround [ 0.006969] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.009281] Setting up static identity map for 0x10100000 - 0x10100078 [ 0.010179] rcu: Hierarchical SRCU implementation. [ 0.011750] smp: Bringing up secondary CPUs ... [ 0.014273] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001 [ 0.014284] CPU1: Spectre v2: using BPIALL workaround [ 0.017035] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002 [ 0.017049] CPU2: Spectre v2: using BPIALL workaround [ 0.019241] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003 [ 0.019254] CPU3: Spectre v2: using BPIALL workaround [ 0.019815] smp: Brought up 1 node, 4 CPUs [ 0.019839] SMP: Total of 4 processors activated (24.00 BogoMIPS). [ 0.019859] CPU: All CPU(s) started in SVC mode. [ 0.022531] devtmpfs: initialized [ 0.053293] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4 [ 0.055577] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.055644] futex hash table entries: 1024 (order: 4, 65536 bytes, linear) [ 0.063246] pinctrl core: initialized pinctrl subsystem [ 0.068141] NET: Registered protocol family 16 [ 0.089728] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.093011] cpuidle: using governor menu [ 0.093313] CPU identified as i.MX6Q, silicon rev 1.5 [ 0.112900] vdd1p1: supplied by regulator-dummy [ 0.114676] vdd3p0: supplied by regulator-dummy [ 0.115931] vdd2p5: supplied by regulator-dummy [ 0.118297] vddpu: supplied by regulator-dummy [ 0.148143] No ATAGs? [ 0.148613] hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers. [ 0.148705] hw-breakpoint: maximum watchpoint size is 4 bytes. [ 0.152636] imx6q-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver [ 0.244915] mxs-dma 110000.dma-apbh: initialized [ 0.349010] 3v3_aud: supplied by reg_3v3 [ 0.350217] hdmi-supply: supplied by reg_3v3 [ 0.351445] uart3-supply: supplied by reg_3v3 [ 0.352635] 1v8-supply: supplied by reg_3v3 [ 0.355758] lcd_panel_pwr: supplied by reg_3v3 [ 0.356940] nLCD_RESET: supplied by lcd_panel_pwr [ 0.360424] vgaarb: loaded [ 0.362017] SCSI subsystem initialized [ 0.362642] libata version 3.00 loaded. [ 0.363439] usbcore: registered new interface driver usbfs [ 0.363647] usbcore: registered new interface driver hub [ 0.363916] usbcore: registered new device driver usb [ 0.364374] usb_phy_generic usbphynop1: usbphynop1 supply vcc not found, using dummy regulator [ 0.365103] usb_phy_generic usbphynop2: usbphynop2 supply vcc not found, using dummy regulator [ 0.368899] i2c i2c-0: IMX I2C adapter registered [ 0.389141] pcf857x 2-0020: probed [ 0.389334] i2c i2c-2: IMX I2C adapter registered [ 0.389761] mc: Linux media interface: v0.10 [ 0.389891] videodev: Linux video capture interface: v2.00 [ 0.390348] pps_core: LinuxPPS API ver. 1 registered [ 0.390372] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]> [ 0.390426] PTP clock support registered [ 0.391359] Advanced Linux Sound Architecture Driver Initialized. [ 0.395049] Bluetooth: Core ver 2.22 [ 0.395169] NET: Registered protocol family 31 [ 0.395189] Bluetooth: HCI device and connection manager initialized [ 0.395302] Bluetooth: HCI socket layer initialized [ 0.395339] Bluetooth: L2CAP socket layer initialized [ 0.395481] Bluetooth: SCO socket layer initialized [ 0.397885] clocksource: Switched to clocksource mxc_timer1 [ 1.104745] VFS: Disk quotas dquot_6.6.0 [ 1.104923] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [ 1.131189] thermal_sys: Registered thermal governor 'step_wise' [ 1.131936] NET: Registered protocol family 2 [ 1.133757] tcp_listen_portaddr_hash hash table entries: 512 (order: 2, 20480 bytes, linear) [ 1.133896] TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear) [ 1.134067] TCP bind hash table entries: 8192 (order: 6, 294912 bytes, linear) [ 1.135145] TCP: Hash tables configured (established 8192 bind 8192) [ 1.135748] UDP hash table entries: 512 (order: 3, 40960 bytes, linear) [ 1.135949] UDP-Lite hash table entries: 512 (order: 3, 40960 bytes, linear) [ 1.136503] NET: Registered protocol family 1 [ 1.138850] RPC: Registered named UNIX socket transport module. [ 1.138940] RPC: Registered udp transport module. [ 1.138962] RPC: Registered tcp transport module. [ 1.138982] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 1.140040] PCI: CLS 0 bytes, default 64 [ 1.142087] hw perfevents: no interrupt-affinity property for /pmu, guessing. [ 1.142758] hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available [ 1.147487] Initialise system trusted keyrings [ 1.148222] workingset: timestamp_bits=30 max_order=19 bucket_order=0 [ 1.165742] NFS: Registering the id_resolver key type [ 1.165907] Key type id_resolver registered [ 1.165994] Key type id_legacy registered [ 1.166176] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc. [ 1.167476] fuse: init (API version 7.31) [ 1.207531] Key type asymmetric registered [ 1.207671] Asymmetric key parser 'x509' registered [ 1.208017] bounce: pool size: 64 pages [ 1.208197] io scheduler mq-deadline registered [ 1.208239] io scheduler kyber registered [ 1.215241] imx6q-pcie 1ffc000.pcie: host bridge /soc/pcie@1ffc000 ranges: [ 1.215441] imx6q-pcie 1ffc000.pcie: IO 0x01f80000..0x01f8ffff -> 0x00000000 [ 1.215649] imx6q-pcie 1ffc000.pcie: MEM 0x01000000..0x01efffff -> 0x01000000 [ 1.226349] imx-sdma 20ec000.sdma: Direct firmware load for imx/sdma/sdma-imx6q.bin failed with error -2 [ 1.226447] imx-sdma 20ec000.sdma: Falling back to sysfs fallback for: imx/sdma/sdma-imx6q.bin [ 1.230166] imx-pgc-pd imx-pgc-power-domain.0: DMA mask not set [ 1.230711] imx-pgc-pd imx-pgc-power-domain.1: DMA mask not set [ 1.234831] pfuze100-regulator 2-0008: Full layer: 2, Metal layer: 1 [ 1.235709] pfuze100-regulator 2-0008: FAB: 0, FIN: 0 [ 1.235736] pfuze100-regulator 2-0008: pfuze100 found. [ 1.246751] gen_rgmii: Bringing 1200000uV into 1800000-1800000uV [ 1.254558] gen_1v5: Bringing 800000uV into 1500000-1500000uV [ 1.269047] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 27, base_baud = 5000000) is a IMX [ 2.197113] printk: console [ttymxc0] enabled [ 2.204911] 21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 71, base_baud = 5000000) is a IMX [ 2.214080] serial serial0: tty port ttymxc1 registered [ 2.220167] 21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 72, base_baud = 5000000) is a IMX [ 2.253851] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 2.260296] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 2.266510] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 2.272285] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 2.294321] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 2.302723] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 2.324067] etnaviv-gpu 134000.gpu: command buffer outside valid memory window [ 2.328504] imx6q-pcie 1ffc000.pcie: Phy link never came up [ 2.332376] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 2.341012] imx6q-pcie 1ffc000.pcie: PCI host bridge to bus 0000:00 [ 2.343079] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0 [ 2.349538] pci_bus 0000:00: root bus resource [bus 00-ff] [ 2.358431] [drm] Initialized etnaviv 1.2.0 20151214 for etnaviv on minor 0 [ 2.361178] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] [ 2.372688] imx-ipuv3 2400000.ipu: IPUv3H probed [ 2.374372] pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff] [ 2.381792] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013). [ 2.386260] pci 0000:00:00.0: [16c3:abcd] type 01 class 0x060400 [ 2.392710] [drm] No driver support for vblank timestamp query. [ 2.394090] imx-drm display-subsystem: bound imx-ipuv3-crtc.2 (ops ipu_crtc_ops) [ 2.398855] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x000fffff] [ 2.405031] imx-drm display-subsystem: bound imx-ipuv3-crtc.3 (ops ipu_crtc_ops) [ 2.412209] pci 0000:00:00.0: reg 0x38: [mem 0x00000000-0x0000ffff pref] [ 2.418855] imx-drm display-subsystem: bound imx-ipuv3-crtc.6 (ops ipu_crtc_ops) [ 2.426225] pci 0000:00:00.0: supports D1 [ 2.432964] imx-drm display-subsystem: bound imx-ipuv3-crtc.7 (ops ipu_crtc_ops) [ 2.440107] pci 0000:00:00.0: PME# supported from D0 D1 D3hot D3cold [ 2.445261] PCI: bus0: Fast back to back transfers disabled [ 2.452627] dwhdmi-imx 120000.hdmi: Detected HDMI TX controller v1.30a with HDCP (DWC HDMI 3D TX PHY) [ 2.462321] PCI: bus1: Fast back to back transfers enabled [ 2.468588] imx-drm display-subsystem: bound 120000.hdmi (ops dw_hdmi_imx_ops) [ 2.473026] pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff] [ 2.478962] imx-drm display-subsystem: bound ldb (ops imx_ldb_ops) [ 2.485677] pci 0000:00:00.0: BAR 6: assigned [mem 0x01100000-0x0110ffff pref] [ 2.495219] [drm] Initialized imx-drm 1.0.0 20120507 for display-subsystem on minor 1 [ 2.498765] pci 0000:00:00.0: PCI bridge to [bus 01-ff] [ 3.203527] Console: switching to colour frame buffer device 100x30 [ 3.226230] imx-drm display-subsystem: fb0: imx-drmdrmfb frame buffer device [ 3.233903] imx-ipuv3 2800000.ipu: IPUv3H probed [ 3.263128] brd: module loaded [ 3.297194] loop: module loaded [ 3.302874] at24 2-0051: 8192 byte 24c64 EEPROM, read-only, 0 bytes/write [ 3.311613] at24 2-0052: 8192 byte 24c64 EEPROM, writable, 32 bytes/write [ 3.326659] nand: No NAND device found [ 3.335305] libphy: Fixed MDIO Bus: probed [ 3.340752] CAN device driver interface [ 3.347184] ethernet-supply: supplied by gen_rgmii [ 3.450797] pps pps0: new PPS source ptp0 [ 3.455996] fec 2188000.ethernet: Invalid MAC address: 00:00:00:00:00:00 [ 3.462805] fec 2188000.ethernet: Using random MAC address: 3a:a4:b5:43:1f:dc [ 3.478534] libphy: fec_enet_mii_bus: probed [ 3.484131] fec 2188000.ethernet eth0: registered PHC device 0 [ 3.491915] usbcore: registered new interface driver r8152 [ 3.497512] usbcore: registered new interface driver lan78xx [ 3.503361] usbcore: registered new interface driver asix [ 3.508915] usbcore: registered new interface driver ax88179_178a [ 3.515110] usbcore: registered new interface driver cdc_ether [ 3.521135] usbcore: registered new interface driver smsc95xx [ 3.526980] usbcore: registered new interface driver net1080 [ 3.532794] usbcore: registered new interface driver cdc_subset [ 3.538866] usbcore: registered new interface driver zaurus [ 3.544540] usbcore: registered new interface driver MOSCHIP usb-ethernet driver [ 3.552140] usbcore: registered new interface driver cdc_ncm [ 3.557879] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 3.564427] ehci-pci: EHCI PCI platform driver [ 3.569174] ehci-mxc: Freescale On-Chip EHCI Host driver [ 3.575453] usbcore: registered new interface driver usb-storage [ 3.594529] imx_usb 2184200.usb: No over current polarity defined [ 3.606880] random: fast init done [ 3.687896] ci_hdrc ci_hdrc.1: EHCI Host Controller [ 3.693078] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1 [ 3.727888] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00 [ 3.734725] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.03 [ 3.743216] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 3.750518] usb usb1: Product: EHCI Host Controller [ 3.755419] usb usb1: Manufacturer: Linux 5.3.1 ehci_hcd [ 3.760803] usb usb1: SerialNumber: ci_hdrc.1 [ 3.768341] hub 1-0:1.0: USB hub found [ 3.772385] hub 1-0:1.0: 1 port detected [ 3.789324] snvs_rtc 20cc000.snvs:snvs-rtc-lp: registered as rtc0 [ 3.795811] i2c /dev entries driver [ 3.809478] imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0) [ 3.816179] Bluetooth: HCI UART driver ver 2.3 [ 3.820733] Bluetooth: HCI UART protocol H4 registered [ 3.826006] Bluetooth: HCI UART protocol LL registered [ 3.833183] sdhci: Secure Digital Host Controller Interface driver [ 3.839445] sdhci: Copyright(c) Pierre Ossman [ 3.843824] sdhci-pltfm: SDHCI platform and OF driver helper [ 3.889557] mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA [ 3.898762] sdhci-esdhc-imx 2194000.usdhc: Got CD GPIO [ 3.920686] hci-ti serial0-0: Direct firmware load for ti-connectivity/TIInit_11.8.32.bts failed with error -2 [ 3.931063] hci-ti serial0-0: Falling back to sysfs fallback for: ti-connectivity/TIInit_11.8.32.bts [ 3.944044] mmc1: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA [ 4.003832] mmc0: new DDR MMC card at address 0001 [ 4.013356] mmcblk0: mmc0:0001 DG4008 7.28 GiB [ 4.020115] mmcblk0boot0: mmc0:0001 DG4008 partition 1 4.00 MiB [ 4.028617] mmcblk0boot1: mmc0:0001 DG4008 partition 2 4.00 MiB [ 4.035632] mmcblk0rpmb: mmc0:0001 DG4008 partition 3 4.00 MiB, chardev (244:0) [ 4.048816] mmcblk0: p1 p2 [ 4.070725] mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA [ 4.087218] sdhci-esdhc-imx 2198000.usdhc: card claims to support voltages below defined range [ 4.099739] caam 2100000.caam: Entropy delay = 3200 [ 4.118650] mmc2: new high speed SDIO card at address 0001 [ 4.165435] caam 2100000.caam: Instantiated RNG4 SH0 [ 4.226194] caam 2100000.caam: Instantiated RNG4 SH1 [ 4.231232] caam 2100000.caam: device ID = 0x0a16010000000000 (Era 4) [ 4.237695] caam 2100000.caam: job rings = 2, qi = 0 [ 4.242906] usb 1-1: new high-speed USB device number 2 using ci_hdrc [ 4.260727] mmc1: host does not support reading read-only switch, assuming write-enable [ 4.278280] mmc1: new high speed SDHC card at address aaaa [ 4.287178] mmcblk1: mmc1:aaaa SL32G 29.7 GiB [ 4.287495] caam algorithms registered in /proc/crypto [ 4.297352] mmcblk1: p1 p2 [ 4.308600] caam_jr 2101000.jr0: registering rng-caam [ 4.316878] usbcore: registered new interface driver usbhid [ 4.322919] usbhid: USB HID core driver [ 4.330780] ipu1_csi0: Registered ipu1_csi0 capture as /dev/video0 [ 4.338856] ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video1 [ 4.346622] ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video2 [ 4.353819] imx-media: ipu1_csi0:1 -> ipu1_ic_prp:0 [ 4.358957] imx-media: ipu1_csi0:1 -> ipu1_vdic:0 [ 4.363692] imx-media: ipu1_vdic:2 -> ipu1_ic_prp:0 [ 4.368638] imx-media: ipu1_ic_prp:1 -> ipu1_ic_prpenc:0 [ 4.373975] imx-media: ipu1_ic_prp:2 -> ipu1_ic_prpvf:0 [ 4.379265] imx-media: subdev ipu1_csi0 bound [ 4.384590] ipu1_csi1: Registered ipu1_csi1 capture as /dev/video3 [ 4.390873] imx-media: ipu1_csi1:1 -> ipu1_ic_prp:0 [ 4.395778] imx-media: ipu1_csi1:1 -> ipu1_vdic:0 [ 4.400552] imx-media: subdev ipu1_csi1 bound [ 4.405818] ipu2_csi0: Registered ipu2_csi0 capture as /dev/video4 [ 4.412623] ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video5 [ 4.420366] ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video6 [ 4.427332] imx-media: ipu2_csi0:1 -> ipu2_ic_prp:0 [ 4.432305] imx-media: ipu2_csi0:1 -> ipu2_vdic:0 [ 4.437038] imx-media: ipu2_vdic:2 -> ipu2_ic_prp:0 [ 4.441993] imx-media: ipu2_ic_prp:1 -> ipu2_ic_prpenc:0 [ 4.447330] imx-media: ipu2_ic_prp:2 -> ipu2_ic_prpvf:0 [ 4.452627] imx-media: subdev ipu2_csi0 bound [ 4.457976] ipu2_csi1: Registered ipu2_csi1 capture as /dev/video7 [ 4.459112] usb 1-1: New USB device found, idVendor=0424, idProduct=2514, bcdDevice= b.b3 [ 4.464183] imx-media: ipu2_csi1:1 -> ipu2_ic_prp:0 [ 4.464206] imx-media: ipu2_csi1:1 -> ipu2_vdic:0 [ 4.472498] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 4.477390] imx-media: subdev ipu2_csi1 bound [ 4.484761] hub 1-1:1.0: USB hub found [ 4.497850] hub 1-1:1.0: 4 ports detected [ 4.506586] wm8962 0-001a: customer id 0 revision F [ 4.526108] fsl-asoc-card sound: ASoC: failed to init link HiFi: -517 [ 4.536365] fsl-ssi-dai 202c000.ssi: No cache defaults, reading back from HW [ 4.550354] NET: Registered protocol family 10 [ 4.558511] Segment Routing with IPv6 [ 4.562325] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 4.570216] NET: Registered protocol family 17 [ 4.574716] can: controller area network core (rev 20170425 abi 9) [ 4.581182] NET: Registered protocol family 29 [ 4.585663] can: raw protocol (rev 20170425) [ 4.590134] can: broadcast manager protocol (rev 20170425 t) [ 4.595837] can: netlink gateway (rev 20170425) max_hops=1 [ 4.601810] Key type dns_resolver registered [ 4.608204] vddarm: supplied by vddcore [ 4.612847] vddsoc: supplied by vddsoc [ 4.626599] Registering SWP/SWPB emulation handler [ 4.632730] Loading compiled-in X.509 certificates [ 4.714356] imx_thermal tempmon: Automotive CPU temperature grade - max:125C critical:120C passive:115C [ 4.729737] input: WM8962 Beep Generator as /devices/soc0/soc/2100000.aips-bus/21a0000.i2c/i2c-0/0-001a/input/input0 [ 4.794418] fsl-asoc-card sound: wm8962 <-> 202c000.ssi mapping ok [ 4.814160] input: keyboard as /devices/soc0/keyboard/input/input1 [ 4.824252] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01T00:00:01 UTC (1) [ 4.834065] cfg80211: Loading compiled-in X.509 certificates for regulatory database [ 4.848207] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7' [ 4.855884] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2 [ 4.858529] vwl1837: disabling [ 4.864587] platform regulatory.0: Falling back to sysfs fallback for: regulatory.db [ 4.867663] usb_otg_vbus: disabling [ 4.879069] 3v3_aud: disabling [ 4.882157] mipi_pwr_en: disabling [ 4.885666] ALSA device list: [ 4.888697] #0: wm8962-audio [ 4.929065] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null) [ 4.938076] VFS: Mounted root (ext4 filesystem) on device 179:26. [ 4.949844] devtmpfs: mounted [ 4.955550] Freeing unused kernel memory: 1024K [ 4.999945] Run /sbin/init as init process [ 5.311019] EXT4-fs (mmcblk1p2): re-mounted. Opts: (null) Starting syslogd: OK Starting klogd: OK Populating /dev using udev: [ 6.617397] udevd[286]: starting version 3.2.7 [ 6.657342] random: udevd: uninitialized urandom read (16 bytes read) [ 6.668656] random: udevd: uninitialized urandom read (16 bytes read) [ 6.675256] random: udevd: uninitialized urandom read (16 bytes read) [ 6.699592] udevd[286]: specified group 'kvm' unknown [ 6.741291] udevd[288]: starting eudev-3.2.7 [ 7.124728] evbug: Connected device: input0 (WM8962 Beep Generator at 0-001a) [ 7.139556] evbug: Connected device: input1 (keyboard at gpio-keys/input0) [ 7.214789] coda 2040000.vpu: Direct firmware load for vpu_fw_imx6q.bin failed with error -2 [ 7.223468] coda 2040000.vpu: Falling back to sysfs fallback for: vpu_fw_imx6q.bin [ 7.351719] imx-media: ipu1_csi0_mux:2 -> ipu1_csi0:0 [ 7.360679] imx-media: imx6-mipi-csi2:2 -> ipu1_csi1:0 [ 7.375400] imx-media: imx6-mipi-csi2:3 -> ipu2_csi0:0 [ 7.394398] imx-media: ipu2_csi1_mux:2 -> ipu2_csi1:0 [ 7.400581] imx-media: imx6-mipi-csi2:1 -> ipu1_csi0_mux:0 [ 7.406896] imx-media: imx6-mipi-csi2:4 -> ipu2_csi1_mux:0 [ 7.414098] imx-media: ov5640 2-0010:0 -> imx6-mipi-csi2:0 [ 7.884552] wl18xx_driver wl18xx.2.auto: Direct firmware load for ti-connectivity/wl18xx-conf.bin failed with error -2 [ 7.895428] wl18xx_driver wl18xx.2.auto: Falling back to sysfs fallback for: ti-connectivity/wl18xx-conf.bin done Initializing random number generator... [ 7.970813] urandom_read: 2 callbacks suppressed [ 7.970824] random: dd: uninitialized urandom read (512 bytes read) done. Starting rngd: OK [ 8.071645] random: crng init done
Starting system message bus: done
Starting network: OK
Starting sshd: OK
Welcome to Buildroot
buildroot login:
Welcome to Buildroot
buildroot login: root
# glmark2-es2-drm Error creating gpu Error: eglCreateWindowSurface failed with error: 0x3009 Error: eglCreateWindowSurface failed with error: 0x3009 Error: CanvasGeneric: Invalid EGL state Error: main: Could not initialize canvas #
_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Quoted 11 lines · Adam Ford
I am attaching two logs. I now the mailing lists will be unhappy, but
don't want to try and spam a bunch of log through the mailing liast.
The two logs show the differences between the working and non-working imx6q 3D accelerator when trying to run a simple glmark2-es2-drm demo.The only change between them is the 2 line code change you suggested.
In both cases, I have cma=128M set in my bootargs. Historically this has been sufficient, but cma=256M has not made a difference.
Mike any suggestions on how to move forward?
I was hoping to get the fixes tested and pushed before 5.4 is released if at all possible
Quoted 74 lines
adam
Quoted 71 lines · Mike Rapoport
Quoted 22 lines · Adam Ford
Quoted 21 lines · Mike Rapoport
Hi,
Quoted 15 lines · Adam Ford
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.Quoted 5 lines
Quoted 2 lines
Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
It's not really a fix, I just wanted to see how exactly
92d12f9544b7("memblock:
refactor internal allocation functions") broke your setup.Can you share the dts you are using and the full kernel log?
Quoted 31 lines
adam
Quoted 29 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
--
Sincerely yours,
Mike.--
Sincerely yours,
Mike.
Hi Adam,
Quoted 9 lines · Adam Ford
Quoted 8 lines · Adam Ford
I am attaching two logs. I now the mailing lists will be unhappy, but
don't want to try and spam a bunch of log through the mailing liast.
The two logs show the differences between the working and non-working imx6q 3D accelerator when trying to run a simple glmark2-es2-drm demo.The only change between them is the 2 line code change you suggested.
Quoted 7 lines
Quoted 3 lines
In both cases, I have cma=128M set in my bootargs. Historically this has been sufficient, but cma=256M has not made a difference.
Mike any suggestions on how to move forward?
I was hoping to get the fixes tested and pushed before 5.4 is released if at all possible
I have a fix (below) that kinda restores the original behaviour, but I still would like to double check to make sure it's not a band aid and I haven't missed the actual root cause.
Can you please send me your device tree definition and the output of
cat /sys/kernel/debug/memblock/memory
and
cat /sys/kernel/debug/memblock/reserved
Thanks!
From 06529f861772b7dea2912fc2245debe4690139b8 Mon Sep 17 00:00:00 2001
From: Mike Rapoport <[email protected]>
Date: Wed, 2 Oct 2019 10:14:17 +0300
Subject: [PATCH] mm: memblock: do not enforce current limit for memblock_phys*
family
Until commit 92d12f9544b7 ("memblock: refactor internal allocation functions") the maximal address for memblock allocations was forced to memblock.current_limit only for the allocation functions returning virtual address. The changes introduced by that commit moved the limit enforcement into the allocation core and as a result the allocation functions returning physical address also started to limit allocations to memblock.current_limit.
This caused breakage of etnaviv GPU driver:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside valid memory window [ 3.760583] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.766766] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0
Restore the behaviour of memblock_phys* family so that these functions will not enforce memblock.current_limit.
--- mm/memblock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/memblock.c +3 -3
@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);
@@ -1469,6 +1466,9 @@ static void * __init memblock_alloc_internal(if (WARN_ON_ONCE (slab_is_available ()))return kzalloc_node (size,GFP_NOWAIT , nid); +if (max_addr > memblock.current_limit) + max_addr = memblock.current_limit; + alloc =memblock_alloc_range_nid (size, align, min_addr, max_addr, nid);/* retry allocation without lower limit */
Signature · 1 line
2.7.4
Quoted 74 lines
Quoted 74 lines
adam
Quoted 71 lines · Mike Rapoport
Quoted 22 lines · Adam Ford
Quoted 21 lines · Mike Rapoport
Hi,
Quoted 15 lines · Adam Ford
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.Quoted 5 lines
Quoted 2 lines
Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
It's not really a fix, I just wanted to see how exactly
92d12f9544b7("memblock:
refactor internal allocation functions") broke your setup.Can you share the dts you are using and the full kernel log?
Quoted 31 lines
adam
Quoted 29 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
--
Sincerely yours,
Mike.--
Sincerely yours,
Mike.
Signature · 2 lines
Sincerely yours, Mike.
Adam Ford
Tested-byQuoted 27 lines · Mike Rapoport
Hi Adam,
Quoted 9 lines · Adam Ford
Quoted 8 lines · Adam Ford
I am attaching two logs. I now the mailing lists will be unhappy, but
don't want to try and spam a bunch of log through the mailing liast.
The two logs show the differences between the working and non-working imx6q 3D accelerator when trying to run a simple glmark2-es2-drm demo.The only change between them is the 2 line code change you suggested.
Quoted 7 lines
Quoted 3 lines
In both cases, I have cma=128M set in my bootargs. Historically this has been sufficient, but cma=256M has not made a difference.
Mike any suggestions on how to move forward?
I was hoping to get the fixes tested and pushed before 5.4 is released if at all possibleI have a fix (below) that kinda restores the original behaviour, but I still would like to double check to make sure it's not a band aid and I haven't missed the actual root cause.
Can you please send me your device tree definition and the output of
Quoted 8 lines
cat
/sys/kernel/debug/memblock/memoryand
cat
/sys/kernel/debug/memblock/reservedThanks!
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 1: 0x10100000..0x11ab141f 2: 0x1fff1000..0x1fffcfff 3: 0x2ee40000..0x2ef53fff 4: 0x2ef56940..0x2ef56c43 5: 0x2ef56c48..0x2fffefff 6: 0x2ffff0c0..0x2ffff4d8 7: 0x2ffff500..0x2ffff55f 8: 0x2ffff580..0x2ffff703 9: 0x2ffff740..0x2ffff918 10: 0x2ffff940..0x2ffff9cf 11: 0x2ffffa00..0x2ffffa0f 12: 0x2ffffa40..0x2ffffa43 13: 0x2ffffa80..0x2ffffad5 14: 0x2ffffb00..0x2ffffb55 15: 0x2ffffb80..0x2ffffbd5 16: 0x2ffffc00..0x2ffffc4e 17: 0x2ffffc50..0x2ffffc6a 18: 0x2ffffc6c..0x2ffffce6 19: 0x2ffffce8..0x2ffffd02 20: 0x2ffffd04..0x2ffffd1e 21: 0x2ffffd20..0x2ffffd3a 22: 0x2ffffd3c..0x2ffffd56 23: 0x2ffffd58..0x2ffffe30 24: 0x2ffffe34..0x2ffffe4c 25: 0x2ffffe50..0x2ffffe68 26: 0x2ffffe6c..0x2ffffe84 27: 0x2ffffe88..0x2ffffea0 28: 0x2ffffea4..0x2ffffebc 29: 0x2ffffec0..0x2ffffedf 30: 0x2ffffee4..0x2ffffefc 31: 0x2fffff00..0x2fffff13 32: 0x2fffff28..0x2fffff4b 33: 0x2fffff50..0x2fffff84 34: 0x2fffff88..0x3fffffff
After the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 1: 0x10100000..0x11ab141f 2: 0x1fff1000..0x1fffcfff 3: 0x3eec0000..0x3efd3fff 4: 0x3efd6940..0x3efd6c43 5: 0x3efd6c48..0x3fffbfff 6: 0x3fffc0c0..0x3fffc4d8 7: 0x3fffc500..0x3fffc55f 8: 0x3fffc580..0x3fffc703 9: 0x3fffc740..0x3fffc918 10: 0x3fffc940..0x3fffc9cf 11: 0x3fffca00..0x3fffca0f 12: 0x3fffca40..0x3fffca43 13: 0x3fffca80..0x3fffca83 14: 0x3fffcac0..0x3fffcb15 15: 0x3fffcb40..0x3fffcb95 16: 0x3fffcbc0..0x3fffcc15 17: 0x3fffcc28..0x3fffcc72 18: 0x3fffcc74..0x3fffcc8e 19: 0x3fffcc90..0x3fffcd0a 20: 0x3fffcd0c..0x3fffcd26 21: 0x3fffcd28..0x3fffcd42 22: 0x3fffcd44..0x3fffcd5e 23: 0x3fffcd60..0x3fffcd7a 24: 0x3fffcd7c..0x3fffce54 25: 0x3fffce58..0x3fffce70 26: 0x3fffce74..0x3fffce8c 27: 0x3fffce90..0x3fffcea8 28: 0x3fffceac..0x3fffcec4 29: 0x3fffcec8..0x3fffcee0 30: 0x3fffcee4..0x3fffcefc 31: 0x3fffcf00..0x3fffcf1f 32: 0x3fffcf28..0x3fffcf53 33: 0x3fffcf68..0x3fffcf8b 34: 0x3fffcf90..0x3fffcfac 35: 0x3fffcfb0..0x3fffffff 36: 0x80000000..0x8fffffff
Quoted 28 lines
From
06529f861772b7dea2912fc2245debe4690139b8Mon Sep 17 00:00:00 2001
From: Mike Rapoport <[email protected]>
Date: Wed, 2 Oct 2019 10:14:17 +0300
Subject: [PATCH] mm: memblock: do not enforce current limit for memblock_phys*
familyUntil commit
92d12f9544b7("memblock: refactor internal allocation functions") the maximal address for memblock allocations was forced to memblock.current_limit only for the allocation functions returning virtual address. The changes introduced by that commit moved the limit enforcement into the allocation core and as a result the allocation functions returning physical address also started to limit allocations to memblock.current_limit.This caused breakage of etnaviv GPU driver:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside valid memory window [ 3.760583] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.766766] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0
Quoted 3 lines
Restore the behaviour of memblock_phys* family so that these functions will not enforce memblock.current_limit.
This fixed the issue. Thank you
Quoted 114 lines
Fixes 92d12f9544b7 ("memblock: refactor internal allocation functions")Reported-by Adam Ford <[email protected]>Signed-off-by Mike Rapoport <[email protected]>--- mm/memblock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/memblock.c +3
-4@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);@@ -1469,6 +1466,9 @@ static void * __init memblock_alloc_internal(if (WARN_ON_ONCE (slab_is_available ()))return kzalloc_node (size,GFP_NOWAIT , nid); +if (max_addr > memblock.current_limit) + max_addr = memblock.current_limit; + alloc =memblock_alloc_range_nid (size, align, min_addr, max_addr, nid);/* retry allocation without lower limit */ --2.7.4
Quoted 70 lines
Quoted 70 lines
adam
Quoted 67 lines · Mike Rapoport
Quoted 22 lines · Adam Ford
Quoted 21 lines · Mike Rapoport
Hi,
Quoted 15 lines · Adam Ford
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.Quoted 5 lines
Quoted 2 lines
Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
It's not really a fix, I just wanted to see how exactly
92d12f9544b7("memblock:
refactor internal allocation functions") broke your setup.Can you share the dts you are using and the full kernel log?
Quoted 31 lines
adam
Quoted 29 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
--
Sincerely yours,
Mike.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
Sincerely yours,
Mike.--
Sincerely yours,
Mike.
(trimmed the CC)
Quoted 12 lines · Adam Ford
Quoted 1 line · Mike Rapoport
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffff
Quoted 6 lines
After the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffff
I'm still not convinced that the memblock refactoring didn't uncovered an issue in etnaviv driver.
Why moving the CMA area from 0x80000000 to 0x30000000 makes it fail?
BTW, the code that complained about "command buffer outside valid memory window" has been removed by the commit 17e4660ae3d7 ("drm/etnaviv:
implement per-process address spaces on MMUv2").
Could be that recent changes to MMU management of etnaviv resolve the issue?
Quoted 150 lines
Quoted 28 lines
From
06529f861772b7dea2912fc2245debe4690139b8Mon Sep 17 00:00:00 2001
From: Mike Rapoport <[email protected]>
Date: Wed, 2 Oct 2019 10:14:17 +0300
Subject: [PATCH] mm: memblock: do not enforce current limit for memblock_phys*
familyUntil commit
92d12f9544b7("memblock: refactor internal allocation functions") the maximal address for memblock allocations was forced to memblock.current_limit only for the allocation functions returning virtual address. The changes introduced by that commit moved the limit enforcement into the allocation core and as a result the allocation functions returning physical address also started to limit allocations to memblock.current_limit.This caused breakage of etnaviv GPU driver:
[ 3.682347] etnaviv etnaviv: bound 130000.gpu (ops gpu_ops) [ 3.688669] etnaviv etnaviv: bound 134000.gpu (ops gpu_ops) [ 3.695099] etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) [ 3.700800] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 [ 3.723013] etnaviv-gpu 130000.gpu: command buffer outside valid memory window [ 3.731308] etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 [ 3.752437] etnaviv-gpu 134000.gpu: command buffer outside valid memory window [ 3.760583] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 [ 3.766766] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0Quoted 3 lines
Restore the behaviour of memblock_phys* family so that these functions will not enforce memblock.current_limit.
This fixed the issue. Thank you
Quoted 114 lines
Fixes 92d12f9544b7 ("memblock: refactor internal allocation functions")Reported-by Adam Ford <[email protected]>Signed-off-by Mike Rapoport <[email protected]>--- mm/memblock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/memblock.c +3
-4@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);@@ -1469,6 +1466,9 @@ static void * __init memblock_alloc_internal(if (WARN_ON_ONCE (slab_is_available ()))return kzalloc_node (size,GFP_NOWAIT , nid); +if (max_addr > memblock.current_limit) + max_addr = memblock.current_limit; + alloc =memblock_alloc_range_nid (size, align, min_addr, max_addr, nid);/* retry allocation without lower limit */ --2.7.4
Quoted 70 lines
Quoted 70 lines
adam
Quoted 67 lines · Mike Rapoport
Quoted 22 lines · Adam Ford
Quoted 21 lines · Mike Rapoport
Hi,
Quoted 15 lines · Adam Ford
Quoted 10 lines · Fabio Estevam
Quoted 3 lines · Adam Ford
I tried cma=256M and noticed the cma dump at the beginning didn't change. Do we need to setup a reserved-memory node like
imx6ul-ccimx6ulsom.dtsidid?I don't think so.
Were you able to identify what was the exact commit that caused such regression?
I was able to narrow it down the
92d12f9544b7("memblock: refactor internal allocation functions") that caused the regression with Etnaviv.Quoted 5 lines
Quoted 2 lines
Can you please test with this change:
That appears to have fixed my issue. I am not sure what the impact is, but is this a safe option?
It's not really a fix, I just wanted to see how exactly
92d12f9544b7("memblock:
refactor internal allocation functions") broke your setup.Can you share the dts you are using and the full kernel log?
Quoted 31 lines
adam
Quoted 29 lines
mm/memblock.c +0
-3@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);Quoted 10 lines
I also noticed that if I create a reserved memory node as was done one
imx6ul-ccimx6ulsom.dtsithe 3D seems to work again, but without it, I was getting errors regardless of the 'cma=256M' or not.
I don't have a problem using the reserved memory, but I guess I am not sure what the amount should be. I know for the video decoding 1080p, I have historically used cma=128M, but with the 3D also needing some memory allocation, is that enough or should I use 256M?adam
--
Sincerely yours,
Mike.Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
Sincerely yours,
Mike.--
Sincerely yours,
Mike.
Signature · 2 lines
Sincerely yours, Mike.
Russell King - ARM Linux admin
maintainerQuoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 12 lines · Adam Ford
Quoted 1 line · Mike Rapoport
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffQuoted 6 lines
After the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffff
Quoted 4 lines
I'm still not convinced that the memblock refactoring didn't uncovered an issue in etnaviv driver.
Why moving the CMA area from
0x80000000to0x30000000makes it fail?
I think you have that the wrong way round.
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory window" has been removed by the commit
17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Could be that recent changes to MMU management of etnaviv resolve the issue?
The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical RAM.
I've reported the problem previously but there was no resolution, other than pointing the blame at CMA.
https://lists.freedesktop.org/archives/dri-devel/2019-June/thread.html#223516
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Quoted 23 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 18 lines · Adam Ford
Quoted 1 line · Mike Rapoport
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffff
Quoted 6 lines
Quoted 4 lines
I'm still not convinced that the memblock refactoring didn't uncovered an issue in etnaviv driver.
Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at 0x80000000 and does not work when it is at 0x30000000.
He also sent logs a few days ago [1], they also confirm that.
[1] https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/
Quoted 10 lines
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory window" has been removed by the commit
17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Could be that recent changes to MMU management of etnaviv resolve the issue?
The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical RAM.
I've mentioned that patch because it removed the check for cmdbuf address for MMUv1:
@@ -785,15 +768,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
PAGE_SIZE);
if (ret) {
dev_err(gpu->dev, "could not create command buffer\n");- goto unmap_suballoc;
- }
-
- if (!(gpu->identity.minor_features1 & chipMinorFeatures1_MMU_VERSION) &&
- etnaviv_cmdbuf_get_va(&gpu->buffer, &gpu->cmdbuf_mapping) > 0x80000000) {
- ret = -EINVAL;
- dev_err(gpu->dev,
- "command buffer outside valid memory window\n");
- goto free_buffer;
+ goto fail;
}
/* Setup event management */I really don't know how etnaviv works, so I hoped that people who understand it would help.
Quoted 9 lines
I've reported the problem previously but there was no resolution, other than pointing the blame at CMA.
https://lists.freedesktop.org/archives/dri-devel/2019-June/thread.html#223516
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Signature · 2 lines
Sincerely yours, Mike.
Am Donnerstag, den 03.10.2019, 14:30 +0300 schrieb Mike Rapoport:
Quoted 30 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
Quoted 21 lines
(trimmed the CC)
Quoted 17 lines · Adam Ford
On Wed, Oct 2, 2019 at 2:36 AM Mike Rapoport <[email protected]> wrote:
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffffQuoted 6 lines
Quoted 4 lines
I'm still not convinced that the memblock refactoring didn't uncovered an issue in etnaviv driver.
Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
Quoted 7 lines
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at
0x80000000and does not work when it is at0x30000000.He also sent logs a few days ago [1], they also confirm that.
[1] https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/
To clarify: Etnaviv needs to know where the CMA area is in order to move a aperture window to cover the CMA area so the command buffers allocated in contig memory can be mapped through this aperture. Now the issue is that there is currently there is no good API for a driver to know where the CMA area is located, so we are trying to infer this from dma_get_required_mask. Unfortunately this can overshoot the real DRAM area by a bit, so combined with the fixed 2GB size of the GPU aperture this means we are no longer able to map the command buffers through the required aperture if the CMA area moves too far down in the physical memory.
It's really a bad interaction between etnaviv and CMA area placement, due to insufficient APIs to communicate some crucial information. There is nothing in the etnaviv driver or the hardware which requires the CMA area to be at a certain place, we just need to know where it is located exactly. So my try at fixing this [1] was by adding a API to get the required information, but the first attempt was shot down and I hadn't had time to follow up on this yet.
Regards,
Lucas
Russell King - ARM Linux admin
maintainerQuoted 31 lines · Mike Rapoport
Quoted 23 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 18 lines · Adam Ford
Quoted 1 line · Mike Rapoport
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffffQuoted 6 lines
Quoted 4 lines
I'm still not convinced that the memblock refactoring didn't uncovered an issue in etnaviv driver.
Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
Quoted 7 lines
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at
0x80000000and does not work when it is at0x30000000.He also sent logs a few days ago [1], they also confirm that.
[1] https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/
Sorry, yes, you're right. Still, I've reported this same regression a while back, and it's never gone away.
Quoted 33 lines
Quoted 10 lines
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory window" has been removed by the commit
17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Could be that recent changes to MMU management of etnaviv resolve the issue?
The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical RAM.
I've mentioned that patch because it removed the check for cmdbuf address for MMUv1:
(quoted diff) +1
-9@@ -785,15 +768,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) PAGE_SIZE); if (ret) { dev_err(gpu->dev, "could not create command buffer\n"); - goto unmap_suballoc; - } - - if (!(gpu->identity.minor_features1 & chipMinorFeatures1_MMU_VERSION) && - etnaviv_cmdbuf_get_va(&gpu->buffer, &gpu->cmdbuf_mapping) > 0x80000000) { - ret = -EINVAL; - dev_err(gpu->dev, - "command buffer outside valid memory window\n"); - goto free_buffer; + goto fail; } /* Setup event management */
Quoted 2 lines
I really don't know how etnaviv works, so I hoped that people who understand it would help.
From what I can see, removing that check is a completely insane thing to do, and I note that these changes are _not_ described in the commit message. The problem was known about _before_ (June 22) the patch was created (July 5).
Lucas, please can you explain why removing the above check, which is well known to correctly trigger on various platforms to prevent incorrect GPU behaviour, is safe?
Thanks.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Am Freitag, den 04.10.2019, 10:27 +0100 schrieb Russell King - ARM Linux admin:
Quoted 100 lines · Mike Rapoport
Quoted 39 lines
Quoted 23 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 18 lines · Adam Ford
On Wed, Oct 2, 2019 at 2:36 AM Mike Rapoport <
[email protected]> wrote:Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffffQuoted 8 lines
Quoted 6 lines
I'm still not convinced that the memblock refactoring didn't uncovered an
issue in etnaviv driver.Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at
0x80000000and does not
work when it is at0x30000000.Quoted 4 lines
He also sent logs a few days ago [1], they also confirm that.
[1]
https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/Sorry, yes, you're right. Still, I've reported this same regression a while back, and it's never gone away.
Quoted 42 lines
Quoted 6 lines
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory
window" has been removed by the commit17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Quoted 8 lines
Quoted 3 lines
Could be that recent changes to MMU management of etnaviv resolve the
issue?The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical
RAM.I've mentioned that patch because it removed the check for cmdbuf address
for MMUv1:(quoted diff) +0
-4@@ -785,15 +768,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) PAGE_SIZE); if (ret) { dev_err(gpu->dev, "could not create command buffer\n"); - goto unmap_suballoc; - } - - if (!(gpu->identity.minor_features1 &
chipMinorFeatures1_MMU_VERSION) &&
- etnaviv_cmdbuf_get_va(&gpu->buffer, &gpu-Quoted 1 line
cmdbuf_mapping) >0x80000000) {(quoted diff) +0
-3- ret = -EINVAL; - dev_err(gpu->dev, - "command buffer outside valid memorywindow\n");
(quoted diff) +1
-1- goto free_buffer; + goto fail; } /* Setup event management */Quoted 2 lines
I really don't know how etnaviv works, so I hoped that people who understand it would help.
From what I can see, removing that check is a completely insane thing to do, and I note that these changes are _not_ described in the commit
message. The problem was known about _before_ (June 22) the patch was
created (July 5).
Quoted 3 lines
Lucas, please can you explain why removing the above check, which is well known to correctly trigger on various platforms to prevent incorrect GPU behaviour, is safe?
It isn't. It's a pretty big oversight in this commit to remove this check. It can't be done at the same spot in the code anymore, as we don't have a mapping context at this time anymore, but it should have moved into etnaviv_iommu_context_init(). I'll send a patch to fix this up.
Regards,
Lucas
Quoted 107 lines · Lucas Stach
Am Freitag, den 04.10.2019, 10:27 +0100 schrieb Russell King - ARM Linux admin:
Quoted 100 lines · Mike Rapoport
Quoted 39 lines
Quoted 23 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 18 lines · Adam Ford
On Wed, Oct 2, 2019 at 2:36 AM Mike Rapoport <
[email protected]> wrote:Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffffQuoted 8 lines
Quoted 6 lines
I'm still not convinced that the memblock refactoring didn't uncovered an
issue in etnaviv driver.Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at
0x80000000and does not
work when it is at0x30000000.Quoted 4 lines
He also sent logs a few days ago [1], they also confirm that.
[1]
https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/Sorry, yes, you're right. Still, I've reported this same regression a while back, and it's never gone away.
Quoted 42 lines
Quoted 6 lines
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory
window" has been removed by the commit17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Quoted 8 lines
Quoted 3 lines
Could be that recent changes to MMU management of etnaviv resolve the
issue?The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical
RAM.I've mentioned that patch because it removed the check for cmdbuf address
for MMUv1:(quoted diff) +0
-4@@ -785,15 +768,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) PAGE_SIZE); if (ret) { dev_err(gpu->dev, "could not create command buffer\n"); - goto unmap_suballoc; - } - - if (!(gpu->identity.minor_features1 &
chipMinorFeatures1_MMU_VERSION) &&
- etnaviv_cmdbuf_get_va(&gpu->buffer, &gpu-Quoted 1 line
cmdbuf_mapping) >0x80000000) {(quoted diff) +0
-3- ret = -EINVAL; - dev_err(gpu->dev, - "command buffer outside valid memorywindow\n");
(quoted diff) +1
-1- goto free_buffer; + goto fail; } /* Setup event management */Quoted 2 lines
I really don't know how etnaviv works, so I hoped that people who understand it would help.
From what I can see, removing that check is a completely insane thing to do, and I note that these changes are _not_ described in the commit
message. The problem was known about _before_ (June 22) the patch was
created (July 5).Quoted 3 lines
Lucas, please can you explain why removing the above check, which is well known to correctly trigger on various platforms to prevent incorrect GPU behaviour, is safe?
Quoted 5 lines
It isn't. It's a pretty big oversight in this commit to remove this check. It can't be done at the same spot in the code anymore, as we don't have a mapping context at this time anymore, but it should have moved into
etnaviv_iommu_context_init(). I'll send a patch to fix this up.
If you CC me, I will test it and report my findings.
adam
Quoted 4 lines
Regards,
Lucas
Quoted 106 lines · Lucas Stach
Am Freitag, den 04.10.2019, 10:27 +0100 schrieb Russell King - ARM Linux admin:
Quoted 100 lines · Mike Rapoport
Quoted 39 lines
Quoted 23 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 18 lines · Adam Ford
On Wed, Oct 2, 2019 at 2:36 AM Mike Rapoport <
[email protected]> wrote:Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffffQuoted 8 lines
Quoted 6 lines
I'm still not convinced that the memblock refactoring didn't uncovered an
issue in etnaviv driver.Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at
0x80000000and does not
work when it is at0x30000000.Quoted 4 lines
He also sent logs a few days ago [1], they also confirm that.
[1]
https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/Sorry, yes, you're right. Still, I've reported this same regression a while back, and it's never gone away.
Quoted 42 lines
Quoted 6 lines
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory
window" has been removed by the commit17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Quoted 8 lines
Quoted 3 lines
Could be that recent changes to MMU management of etnaviv resolve the
issue?The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical
RAM.I've mentioned that patch because it removed the check for cmdbuf address
for MMUv1:(quoted diff) +0
-4@@ -785,15 +768,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) PAGE_SIZE); if (ret) { dev_err(gpu->dev, "could not create command buffer\n"); - goto unmap_suballoc; - } - - if (!(gpu->identity.minor_features1 &
chipMinorFeatures1_MMU_VERSION) &&
- etnaviv_cmdbuf_get_va(&gpu->buffer, &gpu-Quoted 1 line
cmdbuf_mapping) >0x80000000) {(quoted diff) +0
-3- ret = -EINVAL; - dev_err(gpu->dev, - "command buffer outside valid memorywindow\n");
(quoted diff) +1
-1- goto free_buffer; + goto fail; } /* Setup event management */Quoted 2 lines
I really don't know how etnaviv works, so I hoped that people who understand it would help.
From what I can see, removing that check is a completely insane thing to do, and I note that these changes are _not_ described in the commit
message. The problem was known about _before_ (June 22) the patch was
created (July 5).Quoted 3 lines
Lucas, please can you explain why removing the above check, which is well known to correctly trigger on various platforms to prevent incorrect GPU behaviour, is safe?
Quoted 5 lines
It isn't. It's a pretty big oversight in this commit to remove this check. It can't be done at the same spot in the code anymore, as we don't have a mapping context at this time anymore, but it should have moved into
etnaviv_iommu_context_init(). I'll send a patch to fix this up.
Lucas, can you make the check use SZ_2G instead of 0x80000000 and add a comment about 2G limitation of the aperture window?
Quoted 3 lines
Regards,
Lucas
Signature · 2 lines
Sincerely yours, Mike.
Quoted 76 lines · Russell King - ARM Linux admin
Quoted 31 lines · Mike Rapoport
Quoted 23 lines · Russell King - ARM Linux admin
Quoted 22 lines · Mike Rapoport
(trimmed the CC)
Quoted 18 lines · Adam Ford
Quoted 1 line · Mike Rapoport
Before the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 34: 0x2fffff88..0x3fffffffAfter the patch:
# cat /sys/kernel/debug/memblock/memory 0: 0x10000000..0x8fffffff # cat /sys/kernel/debug/memblock/reserved 0: 0x10004000..0x10007fff 36: 0x80000000..0x8fffffffQuoted 6 lines
Quoted 4 lines
I'm still not convinced that the memblock refactoring didn't uncovered an issue in etnaviv driver.
Why moving the CMA area from
0x80000000to0x30000000makes it fail?I think you have that the wrong way round.
Quoted 7 lines
I'm relying on Adam's reports of working and non-working versions. According to that etnaviv works when CMA area is at
0x80000000and does not work when it is at0x30000000.He also sent logs a few days ago [1], they also confirm that.
[1] https://lore.kernel.org/linux-mm/CAHCN7xJEvS2Si=M+BYtz+kY0M4NxmqDjiX9Nwq6_3GGBh3yg=w@mail.gmail.com/
Sorry, yes, you're right. Still, I've reported this same regression a while back, and it's never gone away.
Quoted 33 lines
Quoted 10 lines
Quoted 6 lines
BTW, the code that complained about "command buffer outside valid memory window" has been removed by the commit
17e4660ae3d7("drm/etnaviv:
implement per-process address spaces on MMUv2").Could be that recent changes to MMU management of etnaviv resolve the issue?
The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical RAM.
I've mentioned that patch because it removed the check for cmdbuf address for MMUv1:
(quoted diff) +1
-9@@ -785,15 +768,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) PAGE_SIZE); if (ret) { dev_err(gpu->dev, "could not create command buffer\n"); - goto unmap_suballoc; - } - - if (!(gpu->identity.minor_features1 & chipMinorFeatures1_MMU_VERSION) && - etnaviv_cmdbuf_get_va(&gpu->buffer, &gpu->cmdbuf_mapping) > 0x80000000) { - ret = -EINVAL; - dev_err(gpu->dev, - "command buffer outside valid memory window\n"); - goto free_buffer; + goto fail; } /* Setup event management */
Quoted 7 lines
Quoted 2 lines
I really don't know how etnaviv works, so I hoped that people who understand it would help.
From what I can see, removing that check is a completely insane thing to do, and I note that these changes are _not_ described in the commit message. The problem was known about _before_ (June 22) the patch was created (July 5).
The memblock refactoring went in in 5.1 which was May 5, and likely it caused the regression.
Unless I'm missing something, before the memblock refactoring the CMA reservation could use the entire physical memory because memblock_phys_alloc() didn't enforce memblock.current_limit.
Since memblock default is to allocate from top, cma_declare_contiguous() could grab the memory close to the end of DRAM and thus have physical address close enough to the virtual address to fit in the 2G limit.
When I've made memblock_phys* limit the memblock allocations to memblock.current_limit the CMA area moved too far away down and the gap became larger than 2G.
It does not seem like dealing with this in etnaviv driver and DMA and CMA APIs would happen fast and the "revert" of the memblock changes I've sent earlier in this thread does fix the problem.
Andrew, would you like me to resend the patch in a separate e-mail?
Quoted 6 lines
Lucas, please can you explain why removing the above check, which is well known to correctly trigger on various platforms to prevent incorrect GPU behaviour, is safe?
Thanks.
Signature · 2 lines
Sincerely yours, Mike.
Quoted 5 lines
The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical RAM.
I thought that the i.MX6q has the MMUv1 and GC2000 GPU while the i.MX6qp has the MMUv2 and GC3000? Meaning the i.MX6 has both MMUv1 and MMUv2 depending on which i.MX6 part we are talking about.
Russell King - ARM Linux admin
maintainerQuoted 8 lines · Chris Healy
Quoted 5 lines
The iMX6 does not have MMUv2 hardware, it has MMUv1. With MMUv1 hardware requires command buffers within the first 2GiB of physical RAM.
I thought that the i.MX6q has the MMUv1 and GC2000 GPU while the i.MX6qp has the MMUv2 and GC3000? Meaning the i.MX6 has both MMUv1 and MMUv2 depending on which i.MX6 part we are talking about.
The report says iMX6Q with GC2000 - which is what I was referring to here. I'm not aware of what the later SoCs use, since I've never used them.
Thanks.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up