Linux USB
 help / color / mirror / Atom feed
* [v2,06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
@ 2019-01-29  9:58 Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2019-01-29  9:58 UTC (permalink / raw)
  To: Mike Rapoport, linux-mm
  Cc: Andrew Morton, Catalin Marinas, Christoph Hellwig,
	David S. Miller, Dennis Zhou, Geert Uytterhoeven, Greentime Hu,
	Greg Kroah-Hartman, Guan Xuetao, Guo Ren, Heiko Carstens,
	Mark Salter, Matt Turner, Max Filippov, Michal Simek, Paul Burton,
	Petr Mladek, Rich Felker, Richard Weinberger, Rob Herring,
	Russell King, Stafford Horne, Tony Luck, Vineet Gupta,
	Yoshinori Sato, devicetree, kasan-dev, linux-alpha,
	linux-arm-kernel, linux-c6x-dev, linux-ia64, linux-kernel,
	linux-m68k, linux-mips, linux-s390, linux-sh, linux-snps-arc,
	linux-um, linux-usb, linux-xtensa, linuxppc-dev, openrisc,
	sparclinux, uclinux-h8-devel, x86, xen-devel

Michael Ellerman <mpe@ellerman.id.au> writes:

> Mike Rapoport <rppt@linux.ibm.com> writes:
>
>> diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
>> index ae34e3a..2c61ea4 100644
>> --- a/arch/arm64/mm/numa.c
>> +++ b/arch/arm64/mm/numa.c
>> @@ -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);

Wrong hunk, O_o

> Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

You know what I mean though :)

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [v2,06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
@ 2019-01-29  9:56 Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2019-01-29  9:56 UTC (permalink / raw)
  To: Mike Rapoport, linux-mm
  Cc: Andrew Morton, Catalin Marinas, Christoph Hellwig,
	David S. Miller, Dennis Zhou, Geert Uytterhoeven, Greentime Hu,
	Greg Kroah-Hartman, Guan Xuetao, Guo Ren, Heiko Carstens,
	Mark Salter, Matt Turner, Max Filippov, Michal Simek, Paul Burton,
	Petr Mladek, Rich Felker, Richard Weinberger, Rob Herring,
	Russell King, Stafford Horne, Tony Luck, Vineet Gupta,
	Yoshinori Sato, devicetree, kasan-dev, linux-alpha,
	linux-arm-kernel, linux-c6x-dev, linux-ia64, linux-kernel,
	linux-m68k, linux-mips, linux-s390, linux-sh, linux-snps-arc,
	linux-um, linux-usb, linux-xtensa, linuxppc-dev, openrisc,
	sparclinux, uclinux-h8-devel, x86, xen-devel

Mike Rapoport <rppt@linux.ibm.com> writes:

> diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
> index ae34e3a..2c61ea4 100644
> --- a/arch/arm64/mm/numa.c
> +++ b/arch/arm64/mm/numa.c
> @@ -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);

Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [v2,06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
@ 2019-01-25 19:32 Mike Rapoport
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2019-01-25 19:32 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-mm, Andrew Morton, Christoph Hellwig, David S. Miller,
	Dennis Zhou, Geert Uytterhoeven, Greentime Hu, Greg Kroah-Hartman,
	Guan Xuetao, Guo Ren, Heiko Carstens, Mark Salter, Matt Turner,
	Max Filippov, Michael Ellerman, Michal Simek, Paul Burton,
	Petr Mladek, Rich Felker, Richard Weinberger, Rob Herring,
	Russell King, Stafford Horne, Tony Luck, Vineet Gupta,
	Yoshinori Sato, devicetree, kasan-dev, linux-alpha,
	linux-arm-kernel, linux-c6x-dev, linux-ia64, linux-kernel,
	linux-m68k, linux-mips, linux-s390, linux-sh, linux-snps-arc,
	linux-um, linux-usb, linux-xtensa, linuxppc-dev, openrisc,
	sparclinux, uclinux-h8-devel, x86, xen-devel

On Fri, Jan 25, 2019 at 05:45:02PM +0000, Catalin Marinas wrote:
> On Mon, Jan 21, 2019 at 10:03:53AM +0200, Mike Rapoport wrote:
> > diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
> > index ae34e3a..2c61ea4 100644
> > --- a/arch/arm64/mm/numa.c
> > +++ b/arch/arm64/mm/numa.c
> > @@ -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?

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

> -- 
> Catalin
>

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [v2,06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
@ 2019-01-25 17:45 Catalin Marinas
  0 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2019-01-25 17:45 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: linux-mm, Andrew Morton, Christoph Hellwig, David S. Miller,
	Dennis Zhou, Geert Uytterhoeven, Greentime Hu, Greg Kroah-Hartman,
	Guan Xuetao, Guo Ren, Heiko Carstens, Mark Salter, Matt Turner,
	Max Filippov, Michael Ellerman, Michal Simek, Paul Burton,
	Petr Mladek, Rich Felker, Richard Weinberger, Rob Herring,
	Russell King, Stafford Horne, Tony Luck, Vineet Gupta,
	Yoshinori Sato, devicetree, kasan-dev, linux-alpha,
	linux-arm-kernel, linux-c6x-dev, linux-ia64, linux-kernel,
	linux-m68k, linux-mips, linux-s390, linux-sh, linux-snps-arc,
	linux-um, linux-usb, linux-xtensa, linuxppc-dev, openrisc,
	sparclinux, uclinux-h8-devel, x86, xen-devel

On Mon, Jan 21, 2019 at 10:03:53AM +0200, Mike Rapoport wrote:
> diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
> index ae34e3a..2c61ea4 100644
> --- a/arch/arm64/mm/numa.c
> +++ b/arch/arm64/mm/numa.c
> @@ -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?

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [v2,06/21] memblock: memblock_phys_alloc_try_nid(): don't panic
@ 2019-01-21  8:03 Mike Rapoport
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2019-01-21  8:03 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, Catalin Marinas, Christoph Hellwig,
	David S. Miller, Dennis Zhou, Geert Uytterhoeven, Greentime Hu,
	Greg Kroah-Hartman, Guan Xuetao, Guo Ren, Heiko Carstens,
	Mark Salter, Matt Turner, Max Filippov, Michael Ellerman,
	Michal Simek, Paul Burton, Petr Mladek, Rich Felker,
	Richard Weinberger, Rob Herring, Russell King, Stafford Horne,
	Tony Luck, Vineet Gupta, Yoshinori Sato, devicetree, kasan-dev,
	linux-alpha, linux-arm-kernel, linux-c6x-dev, linux-ia64,
	linux-kernel, linux-m68k, linux-mips, linux-s390, linux-sh,
	linux-snps-arc, linux-um, linux-usb, linux-xtensa, linuxppc-dev,
	openrisc, sparclinux, uclinux-h8-devel, x86, xen-devel,
	Mike Rapoport

The 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.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/arm64/mm/numa.c   | 4 ++++
 arch/powerpc/mm/numa.c | 4 ++++
 mm/memblock.c          | 4 +++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index ae34e3a..2c61ea4 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -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 */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 270cefb..8f2bbe1 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -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 */
diff --git a/mm/memblock.c b/mm/memblock.c
index f019aee..8aabb1b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1393,7 +1393,9 @@ phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t ali
 
 	if (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);
 }
 
 /**

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-29  9:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-29  9:58 [v2,06/21] memblock: memblock_phys_alloc_try_nid(): don't panic Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2019-01-29  9:56 Michael Ellerman
2019-01-25 19:32 Mike Rapoport
2019-01-25 17:45 Catalin Marinas
2019-01-21  8:03 Mike Rapoport

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox