[3/3] mm/memory_hotplug: fix unpaired mem_hotplug_begin/done
diff mbox series

Message ID 20200706011947.184166-4-justin.he@arm.com
State New
Headers show
Series
  • Fix and enable pmem as RAM on arm64
Related show

Commit Message

Justin He July 6, 2020, 1:19 a.m. UTC
When check_memblock_offlined_cb() returns failed rc(e.g. the memblock is
online at that time), mem_hotplug_begin/done is unpaired in such case.

Therefore a warning:
 Call Trace:
  percpu_up_write+0x33/0x40
  try_remove_memory+0x66/0x120
  ? _cond_resched+0x19/0x30
  remove_memory+0x2b/0x40
  dev_dax_kmem_remove+0x36/0x72 [kmem]
  device_release_driver_internal+0xf0/0x1c0
  device_release_driver+0x12/0x20
  bus_remove_device+0xe1/0x150
  device_del+0x17b/0x3e0
  unregister_dev_dax+0x29/0x60
  devm_action_release+0x15/0x20
  release_nodes+0x19a/0x1e0
  devres_release_all+0x3f/0x50
  device_release_driver_internal+0x100/0x1c0
  driver_detach+0x4c/0x8f
  bus_remove_driver+0x5c/0xd0
  driver_unregister+0x31/0x50
  dax_pmem_exit+0x10/0xfe0 [dax_pmem]

This fixes it by moving mem_hotplug_done ahead of "done"

Signed-off-by: Jia He <justin.he@arm.com>
---
 mm/memory_hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Hildenbrand July 6, 2020, 7:49 a.m. UTC | #1
On 06.07.20 03:19, Jia He wrote:
> When check_memblock_offlined_cb() returns failed rc(e.g. the memblock is
> online at that time), mem_hotplug_begin/done is unpaired in such case.
> 
> Therefore a warning:
>  Call Trace:
>   percpu_up_write+0x33/0x40
>   try_remove_memory+0x66/0x120
>   ? _cond_resched+0x19/0x30
>   remove_memory+0x2b/0x40
>   dev_dax_kmem_remove+0x36/0x72 [kmem]
>   device_release_driver_internal+0xf0/0x1c0
>   device_release_driver+0x12/0x20
>   bus_remove_device+0xe1/0x150
>   device_del+0x17b/0x3e0
>   unregister_dev_dax+0x29/0x60
>   devm_action_release+0x15/0x20
>   release_nodes+0x19a/0x1e0
>   devres_release_all+0x3f/0x50
>   device_release_driver_internal+0x100/0x1c0
>   driver_detach+0x4c/0x8f
>   bus_remove_driver+0x5c/0xd0
>   driver_unregister+0x31/0x50
>   dax_pmem_exit+0x10/0xfe0 [dax_pmem]
> 
> This fixes it by moving mem_hotplug_done ahead of "done"
> 
> Signed-off-by: Jia He <justin.he@arm.com>
> ---
>  mm/memory_hotplug.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index e1e290577b45..86b36714342b 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1769,8 +1769,8 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size)
>  
>  	try_offline_node(nid);
>  
> -done:
>  	mem_hotplug_done();
> +done:
>  	return rc;
>  }
>  
> 

Just drop the "done" label, use "return rc;" directly instead of the
goto, and "return 0;" at the end.

Also, please add

Fixes: f1037ec0cc8a ("mm/memory_hotplug: fix remove_memory() lockdep splat")

and

Cc: stable@vger.kernel.org # v5.6+

Thanks!
Dan Williams July 7, 2020, 10:10 p.m. UTC | #2
On Mon, Jul 6, 2020 at 12:50 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 06.07.20 03:19, Jia He wrote:
> > When check_memblock_offlined_cb() returns failed rc(e.g. the memblock is
> > online at that time), mem_hotplug_begin/done is unpaired in such case.
> >
> > Therefore a warning:
> >  Call Trace:
> >   percpu_up_write+0x33/0x40
> >   try_remove_memory+0x66/0x120
> >   ? _cond_resched+0x19/0x30
> >   remove_memory+0x2b/0x40
> >   dev_dax_kmem_remove+0x36/0x72 [kmem]
> >   device_release_driver_internal+0xf0/0x1c0
> >   device_release_driver+0x12/0x20
> >   bus_remove_device+0xe1/0x150
> >   device_del+0x17b/0x3e0
> >   unregister_dev_dax+0x29/0x60
> >   devm_action_release+0x15/0x20
> >   release_nodes+0x19a/0x1e0
> >   devres_release_all+0x3f/0x50
> >   device_release_driver_internal+0x100/0x1c0
> >   driver_detach+0x4c/0x8f
> >   bus_remove_driver+0x5c/0xd0
> >   driver_unregister+0x31/0x50
> >   dax_pmem_exit+0x10/0xfe0 [dax_pmem]
> >
> > This fixes it by moving mem_hotplug_done ahead of "done"
> >
> > Signed-off-by: Jia He <justin.he@arm.com>
> > ---
> >  mm/memory_hotplug.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > index e1e290577b45..86b36714342b 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -1769,8 +1769,8 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size)
> >
> >       try_offline_node(nid);
> >
> > -done:
> >       mem_hotplug_done();
> > +done:
> >       return rc;
> >  }
> >
> >
>
> Just drop the "done" label, use "return rc;" directly instead of the
> goto, and "return 0;" at the end.
>
> Also, please add
>
> Fixes: f1037ec0cc8a ("mm/memory_hotplug: fix remove_memory() lockdep splat")
>
> and
>
> Cc: stable@vger.kernel.org # v5.6+
>
> Thanks!

Yes, thanks, you can also add:

Acked-by: Dan Williams <dan.j.williams@intel.com>

Patch
diff mbox series

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index e1e290577b45..86b36714342b 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1769,8 +1769,8 @@  static int __ref try_remove_memory(int nid, u64 start, u64 size)
 
 	try_offline_node(nid);
 
-done:
 	mem_hotplug_done();
+done:
 	return rc;
 }