One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. This reserved
memory is used for saving the contents of old crashed kernel's memory before
fadump capture kernel uses old kernel's memory area to boot. However, This
reserved memory area stays unused until system crash and isn't available
for production kernel to use.
Instead of setting aside a significant chunk of memory that nobody can use,
take advantage ZONE_MOVABLE to mark a significant chunk of reserved memory
as ZONE_MOVABLE, so that the kernel is prevented from using, but
applications are free to use it.
Patch 1 introduces an interface to mark reserved memory as ZONE_MOVABLE.
Patch 2 uses the above interface to mark reserved memory movable so that
it can be used for applications usage, making fadump reservationless.
Patch 3 and 4 fixes minor issues.
Changes in V6:
- Introduce an interface to mark reserved memory as ZONE_MOVABLE. Hence
sending this series as RFC again.
- Mark reserved area as ZONE_MOVABLE instead of CMA.
- Add fadump=nonmovable parameter for user who don't want to use ZONE_MOVABLE.
Changes in V5:
- Drop the patch that does metadata movement.
- Move the kexec fix patch to top (patch 1)
- Fold CMA documenation patch into patch 2
- Fix the compilation issues when CONFIG_CMA is not set reported by Hari.
- Use the approach of using boot memory size for CMA as suggested by Hari
except the movement of sections. Thanks to Hari.
Changes in V4:
- patch 1: Make fadump compatible irrespective of kernel versions.
- patch 4: moved out of the series and been posted seperatly at
http://patchwork.ozlabs.org/patch/896716/
- Documentation update about CMA reservation.
Changes in V3:
- patch 1 & 2: move metadata region and documentation update.
- patch 7: Un-register the faudmp on kexec path
---
Mahesh Salgaonkar (4):
mm/page_alloc: Introduce an interface to mark reserved memory as ZONE_MOVABLE
powerpc/fadump: Reservationless firmware assisted dump
powerpc/fadump: throw proper error message on fadump registration failure.
powerpc/fadump: Do not allow hot-remove memory from fadump reserved area.
Documentation/powerpc/firmware-assisted-dump.txt | 18 +++
arch/powerpc/include/asm/fadump.h | 7 +
arch/powerpc/kernel/fadump.c | 123 +++++++++++++++++--
arch/powerpc/platforms/pseries/hotplug-memory.c | 7 +
include/linux/mmzone.h | 2
mm/page_alloc.c | 146 ++++++++++++++++++++++
6 files changed, 290 insertions(+), 13 deletions(-)
--
Signature
From: Mahesh Salgaonkar <redacted>
Add an interface to allow a custom reserved memory to be marked as
ZONE_MOVABLE. This will help some subsystem's to convert their reserved
memory region into ZONE_MOVABLE so that the memory can still be available
to user applications.
The approach is based on Joonsoo Kim's commit bad8c6c0
(https://github.com/torvalds/linux/commit/bad8c6c0) that
uses ZONE_MOVABLE to manage CMA area. Majority of the code has been taken
from the Joonsoo Kim's commit mentioned above. But I see above commit
has been reverted due to some issues reported on i386. I believe this
patch is being reworked and re-posted soon.
Like CMA, the other user of ZONE_MOVABLE can be fadump on powerpc, which
reserves significant chunk of memory that is used only after system
is crashed. Until then the reserved memory is unused. By marking that
memory to ZONE_MOVABLE, it can be at least utilized by user applications.
This patch proposes a RFC implementation of an interface to mark
specified reserved area as ZONE_MOVABLE. Comments are welcome.
Signed-off-by: Mahesh Salgaonkar <redacted>
---
include/linux/mmzone.h | 2 +
mm/page_alloc.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 148 insertions(+)
@@ -7687,6 +7687,152 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,returntrue;}+static__initvoidmark_zone_movable(structpage*page)+{+unsignedi=pageblock_nr_pages;+structpage*p=page;+structzone*zone;+unsignedlongpfn=page_to_pfn(page);+intnid=page_to_nid(page);++zone=page_zone(page);+zone->present_pages-=pageblock_nr_pages;++do{+__ClearPageReserved(p);+set_page_count(p,0);++/* Steal pages from other zones */+set_page_links(p,ZONE_MOVABLE,nid,pfn);+}while(++p,++pfn,--i);++zone=page_zone(page);+zone->present_pages+=pageblock_nr_pages;++set_pageblock_migratetype(page,MIGRATE_MOVABLE);++if(pageblock_order>=MAX_ORDER){+i=pageblock_nr_pages;+p=page;+do{+set_page_refcounted(p);+__free_pages(p,MAX_ORDER-1);+p+=MAX_ORDER_NR_PAGES;+}while(i-=MAX_ORDER_NR_PAGES);+}else{+set_page_refcounted(page);+__free_pages(page,pageblock_order);+}++adjust_managed_page_count(page,pageblock_nr_pages);+}++staticint__initzone_movable_activate_area(unsignedlongstart_pfn,+unsignedlongend_pfn)+{+unsignedlongbase_pfn=start_pfn,pfn=start_pfn;+structzone*zone;+unsignedi=(end_pfn-start_pfn)>>pageblock_order;++zone=page_zone(pfn_to_page(base_pfn));+while(pfn<end_pfn){+if(!pfn_valid(pfn))+gotoerr;++if(page_zone(pfn_to_page(pfn))!=zone)+gotoerr;+pfn++;+}++do{+mark_zone_movable(pfn_to_page(base_pfn));+base_pfn+=pageblock_nr_pages;+}while(--i);++return0;+err:+pr_err("Zone movable could not be activated\n");+return-EINVAL;+}++/**+*zone_movable_init_reserved_mem()-createcustomzonemovableareafrom+*reservedmemory+*@base:Baseaddressofthereservedarea+*@size:Sizeofthereservedarea(inbytes),+*+*Thisfunctioncreatescustomzonemovableareafromalreadyreservedmemory.+*/+int__initzone_movable_init_reserved_mem(phys_addr_tbase,phys_addr_tsize)+{+structzone*zone;+pg_data_t*pgdat;+unsignedlongstart_pfn=PHYS_PFN(base);+unsignedlongend_pfn=PHYS_PFN(base+size);+phys_addr_talignment;+intret;++if(!size||!memblock_is_region_reserved(base,size))+return-EINVAL;++/* ensure minimal alignment required by mm core */+alignment=PAGE_SIZE<<+max_t(unsignedlong,MAX_ORDER-1,pageblock_order);++if(ALIGN(base,alignment)!=base||ALIGN(size,alignment)!=size)+return-EINVAL;++for_each_online_pgdat(pgdat){+zone=&pgdat->node_zones[ZONE_MOVABLE];++/*+*Continueifzoneisalreadypopulated.+*Shouldweatleastbumpupthezone->spanned_pages+*forexistingpopulatedzone?+*/+if(populated_zone(zone))+continue;++/*+*Isitpossibletoallowmemoryregionacrossnodesto+*bemarkedasZONE_MOVABLE?+*/+if(pfn_to_nid(start_pfn)!=pgdat->node_id)+continue;++/* Not sure if this is a right place to init empty zone. */+if(zone_is_empty(zone)){+init_currently_empty_zone(zone,start_pfn,+end_pfn-start_pfn);+zone->spanned_pages=end_pfn-start_pfn;+}+}++ret=zone_movable_activate_area(start_pfn,end_pfn);++if(ret)+returnret;++/*+*ReservedpagesforZONE_MOVABLEarenowactivatedand+*thiswouldchangeZONE_MOVABLE'smanagedpagecounterand+*theotherzones'presentcounter.Weneedtore-calculate+*variouszoneinformationthatdependsonthisinitialization.+*/+build_all_zonelists(NULL);+for_each_populated_zone(zone){+if(zone_idx(zone)==ZONE_MOVABLE){+zone_pcp_reset(zone);+setup_zone_pageset(zone);+}else+zone_pcp_update(zone);++set_zone_contiguous(zone);+}++return0;+}+#if (defined(CONFIG_MEMORY_ISOLATION) && defined(CONFIG_COMPACTION)) || defined(CONFIG_CMA)staticunsignedlongpfn_max_align_down(unsignedlongpfn)
From: Mahesh Salgaonkar <redacted>
One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. On large
systems with TeraBytes of memory, this reservation can be quite
significant.
In some cases, fadump fails if the memory reserved is insufficient, or
if the reserved memory was DLPAR hot-removed.
In the normal case, post reboot, the preserved memory is filtered to
extract only relevant areas of interest using the makedumpfile tool.
While the tool provides flexibility to determine what needs to be part
of the dump and what memory to filter out, all supported distributions
default this to "Capture only kernel data and nothing else".
We take advantage of this default and the Linux kernel's zone movable
feature to fundamentally change the memory reservation model for fadump.
Instead of setting aside a significant chunk of memory nobody can use,
this patch marks a significant chunk of reserved memory as ZONE_MOVABLE
that the kernel is prevented from using (due to MIGRATE_MOVABLE),
but applications are free to use it. With this fadump will still be able
to capture all of the kernel memory and most of the user space memory
except the user pages that were present in ZONE_MOVABLE zone. But if
someone wants to capture all of user space memory and ok with reserved
memory not available to production system, then 'fadump=nonmovable' kernel
parameter can be used to fallback to old behaviour.
Essentially, on a P9 LPAR with 2 cores, 8GB RAM and current upstream:
[root@zzxx-yy10 ~]# free -m
total used free shared buff/cache available
Mem: 7557 193 6822 12 541 6725
Swap: 4095 0 4095
With this patch:
[root@zzxx-yy10 ~]# free -m
total used free shared buff/cache available
Mem: 8133 194 7464 12 475 7338
Swap: 4095 0 4095
Changes made here are completely transparent to how fadump has
traditionally worked.
Signed-off-by: Ananth N Mavinakayanahalli <redacted>
Signed-off-by: Mahesh Salgaonkar <redacted>
Signed-off-by: Hari Bathini <redacted>
---
Documentation/powerpc/firmware-assisted-dump.txt | 18 +++++
arch/powerpc/include/asm/fadump.h | 5 +
arch/powerpc/kernel/fadump.c | 80 ++++++++++++++++++++--
3 files changed, 95 insertions(+), 8 deletions(-)
@@ -113,7 +113,16 @@ header, is usually reserved at an offset greater than boot memory size (see Fig. 1). This area is *not* released: this region will be kept permanently reserved, so that it can act as a receptacle for a copy of the boot memory content in addition to CPU state-and HPTE region, in the case a crash does occur.+and HPTE region, in the case a crash does occur. Since this reserved+memory area is used only after the system crash, there is no point in+blocking this significant chunk of memory from production kernel.+Hence, the implementation marks the memory reserved for fadump as+ZONE_MOVABLE. With ZONE_MOVABLE this memory will be available for+applications to use it, while kernel is prevented from using it. With+this fadump will still be able to capture all of the kernel memory and+most of the user space memory except the user pages that were present+in ZONE_MOVABLE region.+ o Memory Reservation during first kernel
@@ -162,6 +171,9 @@ How to enable firmware-assisted dump (fadump): 1. Set config option CONFIG_FA_DUMP=y and build kernel. 2. Boot into linux kernel with 'fadump=on' kernel cmdline option.+ By default, the reserved memory will be marked as zone movable.+ Alternatively, user can boot linux kernel with 'fadump=nonmovable' to+ prevent fadump to mark reserved memory as zone movable. 3. Optionally, user can also set 'crashkernel=' kernel cmdline to specify size of the memory to reserve for boot memory dump preservation.
@@ -172,6 +184,10 @@ NOTE: 1. 'fadump_reserve_mem=' parameter has been deprecated. Instead 2. If firmware-assisted dump fails to reserve memory then it will fallback to existing kdump mechanism if 'crashkernel=' option is set at kernel cmdline.+ 3. if user wants to capture all of user space memory and ok with+ reserved memory not available to production system, then+ 'fadump=nonmovable' kernel parameter can be used to fallback to+ old behaviour. Sysfs/debugfs files: ------------
@@ -474,6 +477,10 @@ static int __init early_fadump_param(char *p)fw_dump.fadump_enabled=1;elseif(strncmp(p,"off",3)==0)fw_dump.fadump_enabled=0;+elseif(strncmp(p,"nonmovable",10)==0){+fw_dump.fadump_enabled=1;+fw_dump.nonmovable=1;+}return0;}
@@ -1146,7 +1153,7 @@ static int fadump_unregister_dump(struct fadump_mem_struct *fdm)return0;}-staticintfadump_invalidate_dump(structfadump_mem_struct*fdm)+staticintfadump_invalidate_dump(conststructfadump_mem_struct*fdm){intrc=0;unsignedintwait_time;
@@ -1177,9 +1184,8 @@ void fadump_cleanup(void){/* Invalidate the registration only if dump is active. */if(fw_dump.dump_active){-init_fadump_mem_struct(&fdm,-be64_to_cpu(fdm_active->cpu_state_data.destination_address));-fadump_invalidate_dump(&fdm);+/* pass the same memory dump structure provided by platform */+fadump_invalidate_dump(fdm_active);}elseif(fw_dump.dump_registered){/* Un-register Firmware-assisted dump if it was registered. */fadump_unregister_dump(&fdm);
@@ -1525,3 +1531,63 @@ int __init setup_fadump(void)return1;}subsys_initcall(setup_fadump);++/*+*MarkthefadumpreservedareaasZONE_MOVABLE.+*Thetotalsizeoffadumpreservedmemorycoversforbootmemorysize+*+cpudatasize+hptesizeandmetadata.Initializeonlythearea+*equivalenttobootmemorysizeaszonemovable.Thereaminingportion+*offadumpreservedmemorywillbenotgiventomovablezoneandpages+*forthoeswillstayreserved.bootmemorysizeisalignedpercoremm+*requirementtosatisyzone_movable_init_reserved_mem()call.+*Butforsomereasonevenifitfailswestillhavethememoryreservation+*withusandwecanstillcontinuedoingfadump.+*/+staticint__initfadump_init_reserved_mem(void)+{+unsignedlonglongbase,size;+intrc;++if(!fw_dump.fadump_enabled)+return0;++/* Ignore if booted with fadump=nonmovable */+if(fw_dump.nonmovable)+return0;++if(fw_dump.dump_active)+return0;++/*+*Markonlythesizeequivalenttobootmemorysizeasmovable+*zone.+*/+base=fw_dump.reserve_dump_area_start;+size=fw_dump.boot_memory_size;++if(!size)+return0;++rc=zone_movable_init_reserved_mem(base,size);+if(rc){+pr_err("Failed to init zone movable area for firmware-assisted dump,%d\n",rc);+/*+*Thoughthezonemovableinithasfailed,westillhavememory+*reservationwithus.Thereservedmemorywillbe+*blockedfromproductionsystemusage.Hencereturn1,+*sothatwecancontinuewithfadump.+*/+return1;+}++/*+*Sowenowhavesuccessfullyinitializedreservedareaas+*ZONE_MOVABLEforfadump.+*/+pr_info("Initialized 0x%llx bytes as zone movable area at %ldMB from "+"0x%lx bytes of memory reserved for firmware-assisted dump\n",+size,(unsignedlong)base>>20,+fw_dump.reserve_dump_area_size);+return1;+}+core_initcall(fadump_init_reserved_mem);
From: Mahesh Salgaonkar <redacted>
fadump fails to register when there are holes in reserved memory area.
This can happen if user has hot-removed a memory that falls in the fadump
reserved memory area. Throw a meaningful error message to the user in
such case.
Signed-off-by: Mahesh Salgaonkar <redacted>
---
arch/powerpc/kernel/fadump.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
@@ -170,6 +170,36 @@ static int is_boot_memory_area_contiguous(void)returnret;}+/*+*Returns1,iftherearenoholesinreservedmemoryarea,+*0otherwise.+*/+staticintis_reserved_memory_area_contiguous(void)+{+structmemblock_region*reg;+unsignedlongstart,end;+unsignedlongd_start=fw_dump.reserve_dump_area_start;+unsignedlongd_end=d_start+fw_dump.reserve_dump_area_size;+intret=0;++for_each_memblock(memory,reg){+start=max(d_start,(unsignedlong)reg->base);+end=min(d_end,(unsignedlong)(reg->base+reg->size));+if(d_start<end){+/* Memory hole from d_start to start */+if(start>d_start)+break;++if(end==d_end){+ret=1;+break;+}+d_start=end+1;+}+}+returnret;+}+/* Print firmware assisted dump configurations for debugging purpose. */staticvoidfadump_show_config(void){
@@ -531,6 +561,9 @@ static int register_fw_dump(struct fadump_mem_struct *fdm)if(!is_boot_memory_area_contiguous())pr_err("Can't have holes in boot memory area while ""registering fadump\n");+elseif(!is_reserved_memory_area_contiguous())+pr_err("Can't have holes in reserved memory area while"+" registering fadump\n");printk(KERN_ERR"Failed to register firmware-assisted kernel"" dump. Parameter Error(%d).\n",rc);
From: Mahesh Salgaonkar <redacted>
For fadump to work successfully there should not be any holes in reserved
memory ranges where kernel has asked firmware to move the content of old
kernel memory in event of crash. Now that fadump reserved memory is marked
as movable zone, this memory area is now not protected from hot-remove
operations. Hence, fadump service can fail to re-register after the
hot-remove operation, if hot-removed memory belongs to fadump reserved
region. To avoid this make sure that memory from fadump reserved area is
not hot-removable if fadump is registered.
However, if user still wants to remove that memory, he can do so by
manually stopping fadump service before hot-remove operation.
Signed-off-by: Mahesh Salgaonkar <redacted>
---
arch/powerpc/include/asm/fadump.h | 2 +-
arch/powerpc/kernel/fadump.c | 10 ++++++++--
arch/powerpc/platforms/pseries/hotplug-memory.c | 7 +++++--
3 files changed, 14 insertions(+), 5 deletions(-)
@@ -116,13 +116,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,/**Iffadumpisregistered,checkifthememoryprovided-*fallswithinbootmemoryarea.+*fallswithinbootmemoryareaandreservedmemoryarea.*/-intis_fadump_boot_memory_area(u64addr,ulongsize)+intis_fadump_memory_area(u64addr,ulongsize){+u64d_start=fw_dump.reserve_dump_area_start;+u64d_end=d_start+fw_dump.reserve_dump_area_size;+if(!fw_dump.dump_registered)return0;+if(((addr+size)>d_start)&&(addr<=d_end))+return1;+return(addr+size)>RMA_START&&addr<=fw_dump.boot_memory_size;}
From: Michal Hocko <mhocko@kernel.org> Date: 2018-07-16 08:26:54
On Mon 16-07-18 11:32:56, Mahesh J Salgaonkar wrote:
One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. This reserved
memory is used for saving the contents of old crashed kernel's memory before
fadump capture kernel uses old kernel's memory area to boot. However, This
reserved memory area stays unused until system crash and isn't available
for production kernel to use.
How much memory are we talking about. Regular kernel dump process needs
some reserved memory as well. Why that is not a big problem?
Instead of setting aside a significant chunk of memory that nobody can use,
take advantage ZONE_MOVABLE to mark a significant chunk of reserved memory
as ZONE_MOVABLE, so that the kernel is prevented from using, but
applications are free to use it.
Why kernel cannot use that memory while userspace can?
[...]
On Mon 16-07-18 11:32:56, Mahesh J Salgaonkar wrote:
quoted
One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. This reserved
memory is used for saving the contents of old crashed kernel's memory before
fadump capture kernel uses old kernel's memory area to boot. However, This
reserved memory area stays unused until system crash and isn't available
for production kernel to use.
How much memory are we talking about. Regular kernel dump process needs
some reserved memory as well. Why that is not a big problem?
We reserve around 5% of total system RAM. On large systems with
TeraBytes of memory, this reservation can be quite significant.
The regular kernel dump uses the kexec method to boot into capture
kernel and it can control the parameters that are being passed to
capture kernel. This allows a capability to strip down the parameters
that can help lowering down the memory requirement for capture kernel to
boot. This allows regular kdump to reserve less memory to start with.
Where as fadump depends on power firmware (pHyp) to load the capture
kernel after full reset and boots like a regular kernel. It needs same
amount of memory to boot as the production kernel. On large systems
production kernel needs significant amount of memory to boot. Hence
fadump needs to reserve enough memory for capture kernel to boot
successfully and execute dump capturing operations. By default fadump
reserves 5% of total system RAM and in most cases this has worked
flawlessly on variety of system configurations. Optionally,
'crashkernel=X' can also be used to specify more fine-tuned memory size
for reservation.
quoted
Instead of setting aside a significant chunk of memory that nobody can use,
take advantage ZONE_MOVABLE to mark a significant chunk of reserved memory
as ZONE_MOVABLE, so that the kernel is prevented from using, but
applications are free to use it.
Why kernel cannot use that memory while userspace can?
fadump needs to reserve memory to be able to save crashing kernel's
memory, with help from power firmware, before the capture kernel loads
into crashing kernel's memory area. Any contents present in this
reserved memory will be over-written. If kernel is allowed to use this
memory, then we loose that kernel data and won't be part of captured
dump, which could be critical to debug root cause of system crash.
Kdump and fadump both uses same infrastructure/tool (makedumpfile) to
capture the memory dump. While the tool provides flexibility to
determine what needs to be part of the dump and what memory to filter
out, all supported distributions defaults to "Capture only kernel data
and nothing else". Taking advantage of this default we can at least make
the reserved memory available for userspace to use.
If someone wants to capture userspace data as well then
'fadump=nonmovable' option can be used where reserved pages won't be
marked zone movable.
Advantage of movable method is the reserved memory chunk is also
available for use.
This is quite a large change and you didn't seem to explain why we need
it.
In fadump case, the reserved memory stays unused until system is
crashed. fadump uses very small portion of this reserved memory, few
KBs, for storing fadump metadata. Otherwise, the significant chunk of
memory is completely unused. Hence, instead of blocking a memory that is
un-utilized through out the lifetime of system, it's better to give it
back to production kernel to use. But at the same time we don't want
kernel to use that memory. While exploring we found 1) Linux kernel's
Contiguous Memory Allocator (CMA) feature and 2) ZONE_MOVABLE, that
suites the requirement. Initial 5 revisions of this patchset () was
using CMA feature. However, fadump does not do any cma allocations,
hence it will be more appropriate to use zone movable to achieve the same.
But unlike CMA, there is no interface available to mark a custom
reserved memory area as ZONE_MOVABLE. Hence patch 1/4 proposes the same.
Thanks,
-Mahesh.
From: Michal Hocko <mhocko@kernel.org> Date: 2018-07-17 11:52:39
On Tue 17-07-18 16:58:10, Mahesh Jagannath Salgaonkar wrote:
On 07/16/2018 01:56 PM, Michal Hocko wrote:
quoted
On Mon 16-07-18 11:32:56, Mahesh J Salgaonkar wrote:
quoted
One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. This reserved
memory is used for saving the contents of old crashed kernel's memory before
fadump capture kernel uses old kernel's memory area to boot. However, This
reserved memory area stays unused until system crash and isn't available
for production kernel to use.
How much memory are we talking about. Regular kernel dump process needs
some reserved memory as well. Why that is not a big problem?
We reserve around 5% of total system RAM. On large systems with
TeraBytes of memory, this reservation can be quite significant.
The regular kernel dump uses the kexec method to boot into capture
kernel and it can control the parameters that are being passed to
capture kernel. This allows a capability to strip down the parameters
that can help lowering down the memory requirement for capture kernel to
boot. This allows regular kdump to reserve less memory to start with.
Where as fadump depends on power firmware (pHyp) to load the capture
kernel after full reset and boots like a regular kernel. It needs same
amount of memory to boot as the production kernel. On large systems
production kernel needs significant amount of memory to boot. Hence
fadump needs to reserve enough memory for capture kernel to boot
successfully and execute dump capturing operations. By default fadump
reserves 5% of total system RAM and in most cases this has worked
flawlessly on variety of system configurations. Optionally,
'crashkernel=X' can also be used to specify more fine-tuned memory size
for reservation.
So why do we even care about fadump when regular kexec provides
(presumably) same functionality with a smaller memory footprint? Or is
there any reason why kexec doesn't work well on ppc?
quoted
quoted
Instead of setting aside a significant chunk of memory that nobody can use,
take advantage ZONE_MOVABLE to mark a significant chunk of reserved memory
as ZONE_MOVABLE, so that the kernel is prevented from using, but
applications are free to use it.
Why kernel cannot use that memory while userspace can?
fadump needs to reserve memory to be able to save crashing kernel's
memory, with help from power firmware, before the capture kernel loads
into crashing kernel's memory area. Any contents present in this
reserved memory will be over-written. If kernel is allowed to use this
memory, then we loose that kernel data and won't be part of captured
dump, which could be critical to debug root cause of system crash.
But then you simply screw user memory sitting there. This might be not
so critical as the kernel memory but still it sounds like you are
reducing the usefulness of the dump just because of inherent limitations
of fadump.
Kdump and fadump both uses same infrastructure/tool (makedumpfile) to
capture the memory dump. While the tool provides flexibility to
determine what needs to be part of the dump and what memory to filter
out, all supported distributions defaults to "Capture only kernel data
and nothing else". Taking advantage of this default we can at least make
the reserved memory available for userspace to use.
If someone wants to capture userspace data as well then
'fadump=nonmovable' option can be used where reserved pages won't be
marked zone movable.
Ohh, so you have an unclutter thing to support the case above.
Advantage of movable method is the reserved memory chunk is also
available for use.
This is quite a large change and you didn't seem to explain why we need
it.
In fadump case, the reserved memory stays unused until system is
crashed. fadump uses very small portion of this reserved memory, few
KBs, for storing fadump metadata. Otherwise, the significant chunk of
memory is completely unused. Hence, instead of blocking a memory that is
un-utilized through out the lifetime of system, it's better to give it
back to production kernel to use. But at the same time we don't want
kernel to use that memory. While exploring we found 1) Linux kernel's
Contiguous Memory Allocator (CMA) feature and 2) ZONE_MOVABLE, that
suites the requirement. Initial 5 revisions of this patchset () was
using CMA feature. However, fadump does not do any cma allocations,
hence it will be more appropriate to use zone movable to achieve the same.
But unlike CMA, there is no interface available to mark a custom
reserved memory area as ZONE_MOVABLE. Hence patch 1/4 proposes the same.
Well, you are adding a significant amount of code so you should be much
better in explaining why does the generic code care about a ppc specific
kdump method.
--
Michal Hocko
SUSE Labs
On Tue 17-07-18 16:58:10, Mahesh Jagannath Salgaonkar wrote:
quoted
On 07/16/2018 01:56 PM, Michal Hocko wrote:
quoted
On Mon 16-07-18 11:32:56, Mahesh J Salgaonkar wrote:
quoted
One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. This reserved
memory is used for saving the contents of old crashed kernel's memory before
fadump capture kernel uses old kernel's memory area to boot. However, This
reserved memory area stays unused until system crash and isn't available
for production kernel to use.
How much memory are we talking about. Regular kernel dump process needs
some reserved memory as well. Why that is not a big problem?
We reserve around 5% of total system RAM. On large systems with
TeraBytes of memory, this reservation can be quite significant.
The regular kernel dump uses the kexec method to boot into capture
kernel and it can control the parameters that are being passed to
capture kernel. This allows a capability to strip down the parameters
that can help lowering down the memory requirement for capture kernel to
boot. This allows regular kdump to reserve less memory to start with.
Where as fadump depends on power firmware (pHyp) to load the capture
kernel after full reset and boots like a regular kernel. It needs same
amount of memory to boot as the production kernel. On large systems
production kernel needs significant amount of memory to boot. Hence
fadump needs to reserve enough memory for capture kernel to boot
successfully and execute dump capturing operations. By default fadump
reserves 5% of total system RAM and in most cases this has worked
flawlessly on variety of system configurations. Optionally,
'crashkernel=X' can also be used to specify more fine-tuned memory size
for reservation.
So why do we even care about fadump when regular kexec provides
(presumably) same functionality with a smaller memory footprint? Or is
there any reason why kexec doesn't work well on ppc?
Kexec based kdump is loaded by crashing kernel. When OS crashes, the
system is in an inconsistent state, especially the devices. In some
cases, a rogue DMA or ill-behaving device drivers can cause the kdump
capture to fail.
On power platform, fadump solves these issues by taking help from power
firmware, to fully-reset the system, load the fresh copy of same kernel
to capture the dump with PCI and I/O devices reinitialized, making it
more reliable.
Fadump does full system reset, booting system through the regular boot
options i.e the dump capture kernel is booted in the same fashion and
doesn't have specialized kernel command line option. This implies, we
need to give more memory for the system boot. Since the new kernel boots
from the same memory location as crashed kernel, we reserve 5% of memory
where power firmware moves the crashed kernel's memory content. This
reserved memory is completely removed from the available memory. For
large memory systems like 64TB systems, this account to ~ 3TB, which is
a significant chunk of memory production kernel is deprived of. Hence,
this patch adds an improvement to exiting fadump feature to make the
reserved memory available to system for use, using zone movable.
Thanks,
-Mahesh.
quoted
quoted
quoted
Instead of setting aside a significant chunk of memory that nobody can use,
take advantage ZONE_MOVABLE to mark a significant chunk of reserved memory
as ZONE_MOVABLE, so that the kernel is prevented from using, but
applications are free to use it.
Why kernel cannot use that memory while userspace can?
fadump needs to reserve memory to be able to save crashing kernel's
memory, with help from power firmware, before the capture kernel loads
into crashing kernel's memory area. Any contents present in this
reserved memory will be over-written. If kernel is allowed to use this
memory, then we loose that kernel data and won't be part of captured
dump, which could be critical to debug root cause of system crash.
But then you simply screw user memory sitting there. This might be not
so critical as the kernel memory but still it sounds like you are
reducing the usefulness of the dump just because of inherent limitations
of fadump.
quoted
Kdump and fadump both uses same infrastructure/tool (makedumpfile) to
capture the memory dump. While the tool provides flexibility to
determine what needs to be part of the dump and what memory to filter
out, all supported distributions defaults to "Capture only kernel data
and nothing else". Taking advantage of this default we can at least make
the reserved memory available for userspace to use.
If someone wants to capture userspace data as well then
'fadump=nonmovable' option can be used where reserved pages won't be
marked zone movable.
Ohh, so you have an unclutter thing to support the case above.
quoted
Advantage of movable method is the reserved memory chunk is also
available for use.
This is quite a large change and you didn't seem to explain why we need
it.
In fadump case, the reserved memory stays unused until system is
crashed. fadump uses very small portion of this reserved memory, few
KBs, for storing fadump metadata. Otherwise, the significant chunk of
memory is completely unused. Hence, instead of blocking a memory that is
un-utilized through out the lifetime of system, it's better to give it
back to production kernel to use. But at the same time we don't want
kernel to use that memory. While exploring we found 1) Linux kernel's
Contiguous Memory Allocator (CMA) feature and 2) ZONE_MOVABLE, that
suites the requirement. Initial 5 revisions of this patchset () was
using CMA feature. However, fadump does not do any cma allocations,
hence it will be more appropriate to use zone movable to achieve the same.
But unlike CMA, there is no interface available to mark a custom
reserved memory area as ZONE_MOVABLE. Hence patch 1/4 proposes the same.
Well, you are adding a significant amount of code so you should be much
better in explaining why does the generic code care about a ppc specific
kdump method.
From: Michal Hocko <mhocko@kernel.org> Date: 2018-07-19 08:08:11
On Wed 18-07-18 21:52:17, Mahesh Jagannath Salgaonkar wrote:
On 07/17/2018 05:22 PM, Michal Hocko wrote:
quoted
On Tue 17-07-18 16:58:10, Mahesh Jagannath Salgaonkar wrote:
quoted
On 07/16/2018 01:56 PM, Michal Hocko wrote:
quoted
On Mon 16-07-18 11:32:56, Mahesh J Salgaonkar wrote:
quoted
One of the primary issues with Firmware Assisted Dump (fadump) on Power
is that it needs a large amount of memory to be reserved. This reserved
memory is used for saving the contents of old crashed kernel's memory before
fadump capture kernel uses old kernel's memory area to boot. However, This
reserved memory area stays unused until system crash and isn't available
for production kernel to use.
How much memory are we talking about. Regular kernel dump process needs
some reserved memory as well. Why that is not a big problem?
We reserve around 5% of total system RAM. On large systems with
TeraBytes of memory, this reservation can be quite significant.
The regular kernel dump uses the kexec method to boot into capture
kernel and it can control the parameters that are being passed to
capture kernel. This allows a capability to strip down the parameters
that can help lowering down the memory requirement for capture kernel to
boot. This allows regular kdump to reserve less memory to start with.
Where as fadump depends on power firmware (pHyp) to load the capture
kernel after full reset and boots like a regular kernel. It needs same
amount of memory to boot as the production kernel. On large systems
production kernel needs significant amount of memory to boot. Hence
fadump needs to reserve enough memory for capture kernel to boot
successfully and execute dump capturing operations. By default fadump
reserves 5% of total system RAM and in most cases this has worked
flawlessly on variety of system configurations. Optionally,
'crashkernel=X' can also be used to specify more fine-tuned memory size
for reservation.
So why do we even care about fadump when regular kexec provides
(presumably) same functionality with a smaller memory footprint? Or is
there any reason why kexec doesn't work well on ppc?
Kexec based kdump is loaded by crashing kernel. When OS crashes, the
system is in an inconsistent state, especially the devices. In some
cases, a rogue DMA or ill-behaving device drivers can cause the kdump
capture to fail.
On power platform, fadump solves these issues by taking help from power
firmware, to fully-reset the system, load the fresh copy of same kernel
to capture the dump with PCI and I/O devices reinitialized, making it
more reliable.
Thanks for the clarification.
Fadump does full system reset, booting system through the regular boot
options i.e the dump capture kernel is booted in the same fashion and
doesn't have specialized kernel command line option. This implies, we
need to give more memory for the system boot. Since the new kernel boots
from the same memory location as crashed kernel, we reserve 5% of memory
where power firmware moves the crashed kernel's memory content. This
reserved memory is completely removed from the available memory. For
large memory systems like 64TB systems, this account to ~ 3TB, which is
a significant chunk of memory production kernel is deprived of. Hence,
this patch adds an improvement to exiting fadump feature to make the
reserved memory available to system for use, using zone movable.
Is the 5% a reasonable estimate or more a ballpark number? I find it a
bit strange to require 3TB of memory to boot a kernel just to dump the
crashed kernel image. Shouldn't you rather look into this estimate than
spreading ZONE_MOVABLE abuse? Larger systems need more memory to dump
even with the regular kexec kdump but I have never seen any to use more
than 1G or something like that.
--
Michal Hocko
SUSE Labs