linux/drivers/base
David Hildenbrand 928130532e drivers/base/memory: fix trying offlining memory blocks with memory holes on aarch64
offline_pages() properly checks for memory holes and bails out.
However, we do a page_zone(pfn_to_page(start_pfn)) before calling
offline_pages() when offlining a memory block.

We should not unconditionally call page_zone(pfn_to_page(start_pfn)) on
aarch64 in offlining code, otherwise we can trigger a BUG when hitting a
memory hole:

   kernel BUG at include/linux/mm.h:1383!
   Internal error: Oops - BUG: 0 [#1] SMP
   Modules linked in: loop processor efivarfs ip_tables x_tables ext4 mbcache jbd2 dm_mod igb nvme i2c_algo_bit mlx5_core i2c_core nvme_core firmware_class
   CPU: 13 PID: 1694 Comm: ranbug Not tainted 5.12.0-next-20210524+ #4
   Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
   pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
   pc : memory_subsys_offline+0x1f8/0x250
   lr : memory_subsys_offline+0x1f8/0x250
   Call trace:
     memory_subsys_offline+0x1f8/0x250
     device_offline+0x154/0x1d8
     online_store+0xa4/0x118
     dev_attr_store+0x44/0x78
     sysfs_kf_write+0xe8/0x138
     kernfs_fop_write_iter+0x26c/0x3d0
     new_sync_write+0x2bc/0x4f8
     vfs_write+0x718/0xc88
     ksys_write+0xf8/0x1e0
     __arm64_sys_write+0x74/0xa8
     invoke_syscall.constprop.0+0x78/0x1e8
     do_el0_svc+0xe4/0x298
     el0_svc+0x20/0x30
     el0_sync_handler+0xb0/0xb8
     el0_sync+0x178/0x180
   Kernel panic - not syncing: Oops - BUG: Fatal exception
   SMP: stopping secondary CPUs
   Kernel Offset: disabled
   CPU features: 0x00000251,20000846
   Memory Limit: none

If nr_vmemmap_pages is set, we know that we are dealing with hotplugged
memory that doesn't have any holes.  So call
page_zone(pfn_to_page(start_pfn)) only when really necessary -- when
nr_vmemmap_pages is set and we actually adjust the present pages.

Link: https://lkml.kernel.org/r/20210526075226.5572-1-david@redhat.com
Fixes: a08a2ae346 ("mm,memory_hotplug: allocate memmap from the added memory range")
Signed-off-by: David Hildenbrand <david@redhat.com>
Reported-by: Qian Cai (QUIC) <quic_qiancai@quicinc.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Mike Rapoport <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-06-05 08:58:11 -07:00
..
firmware_loader init/initramfs.c: do unpacking asynchronously 2021-05-07 00:26:33 -07:00
power PM: runtime: Fix unpaired parent child_count for force_resume 2021-05-10 19:14:01 +02:00
regmap regmap-irq: Fix dereference of a potentially null d->virt_buf 2021-04-07 16:58:33 +01:00
test kunit: software node: adhear to KUNIT formatting standard 2021-04-15 08:56:27 +02:00
arch_numa.c arch_numa: fix common code printing of phys_addr_t 2021-02-18 23:18:04 -08:00
arch_topology.c arch_topology: Export arch_freq_scale and helpers 2021-03-12 10:35:57 +05:30
attribute_container.c driver core: attribute_container: remove kernel-doc warnings 2021-04-02 16:40:07 +02:00
auxiliary.c driver core: auxiliary bus: Remove unneeded module bits 2021-03-23 10:47:55 +01:00
base.h driver core: Improve fw_devlink & deferred_probe_timeout interaction 2021-04-05 09:17:56 +02:00
bus.c drivers: base: change 'driver_create_groups' to 'driver_add_groups' in printk 2021-01-27 14:35:09 +01:00
cacheinfo.c drivers core: Use sysfs_emit for shared_cpu_map_show and shared_cpu_list_show 2020-10-02 13:24:40 +02:00
class.c drivers: base: fix some kernel-doc markups 2020-11-09 18:56:49 +01:00
component.c driver core: component: remove dentry pointer in "struct master" 2021-03-23 10:49:02 +01:00
container.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
core.c drivers: base: Reduce device link removal code duplication 2021-05-21 22:12:14 +02:00
cpu.c drivers/base/cpu: remove redundant assignment of variable retval 2021-03-23 14:56:50 +01:00
dd.c Linux 5.12-rc7 2021-04-14 19:53:39 +02:00
devcoredump.c devcoredump: fix kernel-doc warning 2021-04-02 16:40:08 +02:00
devres.c driver core: Replace printf() specifier and drop unneeded casting 2021-04-02 17:02:45 +02:00
devtmpfs.c devtmpfs: actually reclaim some init memory 2021-03-23 14:57:35 +01:00
driver.c drivers: base: Convert to printk alias functions 2020-07-10 14:16:44 +02:00
firmware.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
hypervisor.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
init.c driver core: auxiliary bus: Fix calling stage for auxiliary bus init 2021-02-11 08:43:03 +01:00
isa.c isa: Make the remove callback for isa drivers return void 2021-01-26 07:42:27 +01:00
Kconfig RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
Makefile numa: Move numa implementation to common code 2021-01-14 15:08:55 -08:00
map.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
memory.c drivers/base/memory: fix trying offlining memory blocks with memory holes on aarch64 2021-06-05 08:58:11 -07:00
module.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
node.c node: fix device cleanups in error handling code 2021-04-10 11:10:21 +02:00
pinctrl.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
platform-msi.c platform-msi: fix kernel-doc warnings 2021-04-02 16:40:08 +02:00
platform.c Revert "driver core: platform: Make platform_get_irq_optional() optional" 2021-04-07 11:47:56 +02:00
property.c media: device property: Call fwnode_graph_get_endpoint_by_id() for fwnode->secondary 2021-01-26 19:24:18 +01:00
soc.c soc: fix comment for freeing soc_dev_attr 2020-12-09 19:46:31 +01:00
swnode.c software node: Allow node addition to already existing device 2021-04-15 10:36:07 +02:00
syscore.c syscore: Use pm_pr_dbg() for syscore_{suspend,resume}() 2020-09-08 13:32:06 +02:00
topology.c drivers core: Miscellaneous changes for sysfs_emit 2020-10-02 13:12:07 +02:00
transport_class.c scsi: drivers: base: Propagate errors through the transport component 2020-01-15 22:55:37 -05:00