Skip to content

Commit 4765600

Browse files
David HildenbrandVasily Gorbik
authored andcommitted
s390: simplify memory notifier for protecting kdump crash kernel area
Assume we have a crashkernel area of 256MB reserved: root@vm0:~# cat /proc/iomem 00000000-6fffffff : System RAM 0f258000-0fcfffff : Kernel code 0fd00000-101d10e3 : Kernel data 105b3000-1068dfff : Kernel bss 70000000-7fffffff : Crash kernel This exactly corresponds to memory block 7 (memory block size is 256MB). Trying to offline that memory block results in: root@vm0:~# echo "offline" > /sys/devices/system/memory/memory7/state -bash: echo: write error: Device or resource busy [ 128.458762] page:000003d081c00000 refcount:1 mapcount:0 mapping:00000000d01cecd4 index:0x0 [ 128.458773] flags: 0x1ffff00000001000(reserved) [ 128.458781] raw: 1ffff00000001000 000003d081c00008 000003d081c00008 0000000000000000 [ 128.458781] raw: 0000000000000000 0000000000000000 ffffffff00000001 0000000000000000 [ 128.458783] page dumped because: unmovable page The craskernel area is marked reserved in the bootmem allocator. This results in the memmap getting initialized (refcount=1, PG_reserved), but the pages are never freed to the page allocator. So these pages look like allocated pages that are unmovable (esp. PG_reserved), and therefore, memory offlining fails early, when trying to isolate the page range. We only have to care about the exchange area, make that clear. Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Philipp Rudo <prudo@linux.ibm.com> Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Michal Hocko <mhocko@kernel.org> Link: https://lore.kernel.org/r/20200424083904.8587-1-david@redhat.com Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent e5794cf commit 4765600

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎arch/s390/kernel/setup.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,10 @@ static void __init setup_memory_end(void)
597597
#ifdef CONFIG_CRASH_DUMP
598598

599599
/*
600-
* When kdump is enabled, we have to ensure that no memory from
601-
* the area [0 - crashkernel memory size] and
602-
* [crashk_res.start - crashk_res.end] is set offline.
600+
* When kdump is enabled, we have to ensure that no memory from the area
601+
* [0 - crashkernel memory size] is set offline - it will be exchanged with
602+
* the crashkernel memory region when kdump is triggered. The crashkernel
603+
* memory region can never get offlined (pages are unmovable).
603604
*/
604605
static int kdump_mem_notifier(struct notifier_block *nb,
605606
unsigned long action, void *data)
@@ -610,11 +611,7 @@ static int kdump_mem_notifier(struct notifier_block *nb,
610611
return NOTIFY_OK;
611612
if (arg->start_pfn < PFN_DOWN(resource_size(&crashk_res)))
612613
return NOTIFY_BAD;
613-
if (arg->start_pfn > PFN_DOWN(crashk_res.end))
614-
return NOTIFY_OK;
615-
if (arg->start_pfn + arg->nr_pages - 1 < PFN_DOWN(crashk_res.start))
616-
return NOTIFY_OK;
617-
return NOTIFY_BAD;
614+
return NOTIFY_OK;
618615
}
619616

620617
static struct notifier_block kdump_mem_nb = {

0 commit comments

Comments
 (0)