linux_dsm_epyc7002/arch/powerpc/platforms
David Hildenbrand 8df1d0e4a2 mm/memory_hotplug: make add_memory() take the device_hotplug_lock
add_memory() currently does not take the device_hotplug_lock, however
is aleady called under the lock from
	arch/powerpc/platforms/pseries/hotplug-memory.c
	drivers/acpi/acpi_memhotplug.c
to synchronize against CPU hot-remove and similar.

In general, we should hold the device_hotplug_lock when adding memory to
synchronize against online/offline request (e.g.  from user space) - which
already resulted in lock inversions due to device_lock() and
mem_hotplug_lock - see 30467e0b3b ("mm, hotplug: fix concurrent memory
hot-add deadlock").  add_memory()/add_memory_resource() will create memory
block devices, so this really feels like the right thing to do.

Holding the device_hotplug_lock makes sure that a memory block device
can really only be accessed (e.g. via .online/.state) from user space,
once the memory has been fully added to the system.

The lock is not held yet in
	drivers/xen/balloon.c
	arch/powerpc/platforms/powernv/memtrace.c
	drivers/s390/char/sclp_cmd.c
	drivers/hv/hv_balloon.c
So, let's either use the locked variants or take the lock.

Don't export add_memory_resource(), as it once was exported to be used by
XEN, which is never built as a module.  If somebody requires it, we also
have to export a locked variant (as device_hotplug_lock is never
exported).

Link: http://lkml.kernel.org/r/20180925091457.28651-3-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Pavel Tatashin <pavel.tatashin@microsoft.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Cc: John Allen <jallen@linux.vnet.ibm.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Mathieu Malaterre <malat@debian.org>
Cc: Pavel Tatashin <pavel.tatashin@microsoft.com>
Cc: YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-31 08:54:17 -07:00
..
4xx powerpc updates for 4.20 2018-10-26 14:36:21 -07:00
8xx powerpc updates for 4.20 2018-10-26 14:36:21 -07:00
40x powerpc: remove redundant 'default n' from Kconfig-s 2018-10-13 22:21:25 +11:00
44x powerpc: remove redundant 'default n' from Kconfig-s 2018-10-13 22:21:25 +11:00
52xx powerpc/Makefiles: Convert ifeq to ifdef where possible 2018-08-08 00:32:36 +10:00
82xx powerpc: remove redundant 'default n' from Kconfig-s 2018-10-13 22:21:25 +11:00
83xx powerpc: remove retired sbc834x support 2018-05-03 22:32:30 +10:00
85xx powerpc: don't use ioremap_prot() nor __ioremap() unless really needed. 2018-10-14 18:04:09 +11:00
86xx powerpc: Use pr_warn instead of pr_warning 2017-12-04 11:54:34 +11:00
512x powerpc: Use pr_warn instead of pr_warning 2017-12-04 11:54:34 +11:00
amigaone License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cell Merge branch 'akpm' (patches from Andrew) 2018-10-26 19:33:41 -07:00
chrp chrp/nvram.c: add MODULE_LICENSE() 2018-07-19 14:38:46 +10:00
embedded6xx powerpc: Convert to using %pOFn instead of device_node.name 2018-10-03 15:40:01 +10:00
maple powerpc: remove redundant 'default n' from Kconfig-s 2018-10-13 22:21:25 +11:00
pasemi memblock: rename memblock_alloc{_nid,_try_nid} to memblock_phys_alloc* 2018-10-31 08:54:15 -07:00
powermac memblock: stop using implicit alignment to SMP_CACHE_BYTES 2018-10-31 08:54:16 -07:00
powernv mm/memory_hotplug: make remove_memory() take the device_hotplug_lock 2018-10-31 08:54:17 -07:00
ps3 mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
pseries mm/memory_hotplug: make add_memory() take the device_hotplug_lock 2018-10-31 08:54:17 -07:00
fsl_uli1575.c of/irq: Refactor interrupt-map parsing 2013-10-24 11:43:04 +01:00
Kconfig powerpc: remove redundant 'default n' from Kconfig-s 2018-10-13 22:21:25 +11:00
Kconfig.cputype powerpc: remove redundant 'default n' from Kconfig-s 2018-10-13 22:21:25 +11:00
Makefile powerpc: Add -Werror at arch/powerpc level 2018-10-19 00:56:17 +11:00