linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
       [not found]   ` <20170105091242.GA11021@dhcp-128-65.nay.redhat.com>
@ 2017-01-09 11:44     ` Matt Fleming
  2017-01-09 13:31       ` Mel Gorman
  2017-01-10  0:37       ` Dave Young
  0 siblings, 2 replies; 7+ messages in thread
From: Matt Fleming @ 2017-01-09 11:44 UTC (permalink / raw)
  To: Dave Young
  Cc: Nicolai Stange, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, linux-efi, linux-kernel, Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko,
	Mel Gorman

On Thu, 05 Jan, at 05:12:42PM, Dave Young wrote:
> On 12/22/16 at 11:23am, Nicolai Stange wrote:
> > Before invoking the arch specific handler, efi_mem_reserve() reserves
> > the given memory region through memblock.
> > 
> > efi_mem_reserve() can get called after mm_init() though -- through
> > efi_bgrt_init(), for example. After mm_init(), memblock is dead and should
> > not be used anymore.
> 
> It did not fail during previous test so we did not catch this bug, if memblock
> can not be used after mm_init(), IMHO it should fail instead of silently succeed.
 
This must literally be the fifth time or so that I've been caught out
by this over the years because there's no hard error if you call the
memblock code after slab and co. are up.

MM folks, is there some way to catch these errors without requiring
the sprinkling of slab_is_available() everywhere?

> Matt, can we move the efi_mem_reserve to earlier code for example in
> efi_memblock_x86_reserve_range just after reserving the memmap?
 
No, it *needs* to be callable from efi_bgrt_init(), because you only
want to reserve those regions if you have the BGRT driver available.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
  2017-01-09 11:44     ` [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init() Matt Fleming
@ 2017-01-09 13:31       ` Mel Gorman
  2017-01-09 13:45         ` Matt Fleming
  2017-02-27 21:57         ` Matt Fleming
  2017-01-10  0:37       ` Dave Young
  1 sibling, 2 replies; 7+ messages in thread
From: Mel Gorman @ 2017-01-09 13:31 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Dave Young, Nicolai Stange, Ard Biesheuvel, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86, linux-efi, linux-kernel,
	Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko

On Mon, Jan 09, 2017 at 11:44:00AM +0000, Matt Fleming wrote:
> On Thu, 05 Jan, at 05:12:42PM, Dave Young wrote:
> > On 12/22/16 at 11:23am, Nicolai Stange wrote:
> > > Before invoking the arch specific handler, efi_mem_reserve() reserves
> > > the given memory region through memblock.
> > > 
> > > efi_mem_reserve() can get called after mm_init() though -- through
> > > efi_bgrt_init(), for example. After mm_init(), memblock is dead and should
> > > not be used anymore.
> > 
> > It did not fail during previous test so we did not catch this bug, if memblock
> > can not be used after mm_init(), IMHO it should fail instead of silently succeed.
>  
> This must literally be the fifth time or so that I've been caught out
> by this over the years because there's no hard error if you call the
> memblock code after slab and co. are up.
> 
> MM folks, is there some way to catch these errors without requiring
> the sprinkling of slab_is_available() everywhere?
> 

Well, you could put in a __init global variable about availability into
mm/memblock.c and then check it in memblock APIs like memblock_reserve()
to BUG_ON? I know BUG_ON is frowned upon but this is not likely to be a
situation that can be sensibly recovered.

-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
  2017-01-09 13:31       ` Mel Gorman
@ 2017-01-09 13:45         ` Matt Fleming
  2017-02-27 21:57         ` Matt Fleming
  1 sibling, 0 replies; 7+ messages in thread
From: Matt Fleming @ 2017-01-09 13:45 UTC (permalink / raw)
  To: Mel Gorman
  Cc: Dave Young, Nicolai Stange, Ard Biesheuvel, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86, linux-efi, linux-kernel,
	Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko

On Mon, 09 Jan, at 01:31:52PM, Mel Gorman wrote:
> 
> Well, you could put in a __init global variable about availability into
> mm/memblock.c and then check it in memblock APIs like memblock_reserve()
> to BUG_ON? I know BUG_ON is frowned upon but this is not likely to be a
> situation that can be sensibly recovered.

Indeed. I've only ever seen this situation lead to silent memory
corruption and bitter tears.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
  2017-01-09 11:44     ` [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init() Matt Fleming
  2017-01-09 13:31       ` Mel Gorman
@ 2017-01-10  0:37       ` Dave Young
  2017-01-10 12:51         ` Matt Fleming
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Young @ 2017-01-10  0:37 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Nicolai Stange, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, linux-efi, linux-kernel, Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko,
	Mel Gorman

On 01/09/17 at 11:44am, Matt Fleming wrote:
> On Thu, 05 Jan, at 05:12:42PM, Dave Young wrote:
> > On 12/22/16 at 11:23am, Nicolai Stange wrote:
> > > Before invoking the arch specific handler, efi_mem_reserve() reserves
> > > the given memory region through memblock.
> > > 
> > > efi_mem_reserve() can get called after mm_init() though -- through
> > > efi_bgrt_init(), for example. After mm_init(), memblock is dead and should
> > > not be used anymore.
> > 
> > It did not fail during previous test so we did not catch this bug, if memblock
> > can not be used after mm_init(), IMHO it should fail instead of silently succeed.
>  
> This must literally be the fifth time or so that I've been caught out
> by this over the years because there's no hard error if you call the
> memblock code after slab and co. are up.
> 
> MM folks, is there some way to catch these errors without requiring
> the sprinkling of slab_is_available() everywhere?
> 
> > Matt, can we move the efi_mem_reserve to earlier code for example in
> > efi_memblock_x86_reserve_range just after reserving the memmap?
>  
> No, it *needs* to be callable from efi_bgrt_init(), because you only
> want to reserve those regions if you have the BGRT driver available.

It is true that it depends on acpi init, I was wondering if bgrt parsing can
be moved to early acpi code. But anyway I'm not sure it is doable and
worth.

Thanks
Dave 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
  2017-01-10  0:37       ` Dave Young
@ 2017-01-10 12:51         ` Matt Fleming
  2017-01-11  8:04           ` Dave Young
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2017-01-10 12:51 UTC (permalink / raw)
  To: Dave Young
  Cc: Nicolai Stange, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, linux-efi, linux-kernel, Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko,
	Mel Gorman

On Tue, 10 Jan, at 08:37:35AM, Dave Young wrote:
> 
> It is true that it depends on acpi init, I was wondering if bgrt parsing can
> be moved to early acpi code. But anyway I'm not sure it is doable and
> worth.

That's a good question. I think I gave up last time I tried to move
the BGRT code to early boot because of the dependencies involved with
having the ACPI table parsing code initialised.

But if you want to take a crack at it, I'd be happy to review the
patches.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
  2017-01-10 12:51         ` Matt Fleming
@ 2017-01-11  8:04           ` Dave Young
  0 siblings, 0 replies; 7+ messages in thread
From: Dave Young @ 2017-01-11  8:04 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Nicolai Stange, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, linux-efi, linux-kernel, Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko,
	Mel Gorman

On 01/10/17 at 12:51pm, Matt Fleming wrote:
> On Tue, 10 Jan, at 08:37:35AM, Dave Young wrote:
> > 
> > It is true that it depends on acpi init, I was wondering if bgrt parsing can
> > be moved to early acpi code. But anyway I'm not sure it is doable and
> > worth.
> 
> That's a good question. I think I gave up last time I tried to move
> the BGRT code to early boot because of the dependencies involved with
> having the ACPI table parsing code initialised.
> 
> But if you want to take a crack at it, I'd be happy to review the
> patches.

Ok, I will have a try. 

Thanks
Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init()
  2017-01-09 13:31       ` Mel Gorman
  2017-01-09 13:45         ` Matt Fleming
@ 2017-02-27 21:57         ` Matt Fleming
  1 sibling, 0 replies; 7+ messages in thread
From: Matt Fleming @ 2017-02-27 21:57 UTC (permalink / raw)
  To: Mel Gorman
  Cc: Dave Young, Nicolai Stange, Ard Biesheuvel, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86, linux-efi, linux-kernel,
	Mika Penttilä,
	Andrew Morton, linux-mm, Vlastimil Babka, Michal Hocko

On Mon, 09 Jan, at 01:31:52PM, Mel Gorman wrote:
> 
> Well, you could put in a __init global variable about availability into
> mm/memblock.c and then check it in memblock APIs like memblock_reserve()
> to BUG_ON? I know BUG_ON is frowned upon but this is not likely to be a
> situation that can be sensibly recovered.

What about something like this?

BUG_ON() shouldn't actually be necessary because I couldn't think of a
situation where A) memblock would be unavailable and B) returning an
error would prevent us from making progress.

---->8----

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

end of thread, other threads:[~2017-02-27 21:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20161222102340.2689-1-nicstange@gmail.com>
     [not found] ` <20161222102340.2689-2-nicstange@gmail.com>
     [not found]   ` <20170105091242.GA11021@dhcp-128-65.nay.redhat.com>
2017-01-09 11:44     ` [PATCH v2 2/2] efi: efi_mem_reserve(): don't reserve through memblock after mm_init() Matt Fleming
2017-01-09 13:31       ` Mel Gorman
2017-01-09 13:45         ` Matt Fleming
2017-02-27 21:57         ` Matt Fleming
2017-01-10  0:37       ` Dave Young
2017-01-10 12:51         ` Matt Fleming
2017-01-11  8:04           ` Dave Young

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