From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40Fkrz2qDVzF24B for ; Tue, 3 Apr 2018 19:52:03 +1000 (AEST) Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40Fkrz1XTtz8tSn for ; Tue, 3 Apr 2018 19:52:03 +1000 (AEST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Fkry4B2Qz9s1p for ; Tue, 3 Apr 2018 19:52:02 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w339nUxS101033 for ; Tue, 3 Apr 2018 05:52:00 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h45mcn9k7-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 03 Apr 2018 05:51:59 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Apr 2018 10:51:57 +0100 Subject: Re: [PATCH v3 4/7] powerpc/fadump: exclude memory holes while reserving memory in second kernel. To: Mahesh J Salgaonkar , linuxppc-dev Cc: Srikar Dronamraju , kernelfans@gmail.com, "Aneesh Kumar K.V" , Ananth Narayan , Nathan Fontenot , Anshuman Khandual References: <152265046485.23251.1392824827444770657.stgit@jupiter.in.ibm.com> <152265062142.23251.2863873644423472277.stgit@jupiter.in.ibm.com> From: Hari Bathini Date: Tue, 3 Apr 2018 15:21:52 +0530 MIME-Version: 1.0 In-Reply-To: <152265062142.23251.2863873644423472277.stgit@jupiter.in.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Message-Id: <04e18a87-2882-b656-8fed-800c6d0bc835@linux.vnet.ibm.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Monday 02 April 2018 12:00 PM, Mahesh J Salgaonkar wrote: > From: Mahesh Salgaonkar > > The second kernel, during early boot after the crash, reserves rest of > the memory above boot memory size to make sure it does not touch any of the > dump memory area. It uses memblock_reserve() that reserves the specified > memory region irrespective of memory holes present within that region. > There are chances where previous kernel would have hot removed some of > its memory leaving memory holes behind. In such cases fadump kernel reports > incorrect number of reserved pages through arch_reserved_kernel_pages() > hook causing kernel to hang or panic. > > Fix this by excluding memory holes while reserving rest of the memory > above boot memory size during second kernel boot after crash. > > Signed-off-by: Mahesh Salgaonkar > --- > arch/powerpc/kernel/fadump.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c > index 011f1aa7abab..a497e9fb93fe 100644 > --- a/arch/powerpc/kernel/fadump.c > +++ b/arch/powerpc/kernel/fadump.c > @@ -433,6 +433,21 @@ static inline unsigned long get_fadump_metadata_base( > return be64_to_cpu(fdm->metadata_region.source_address); > } > > +static void fadump_memblock_reserve(unsigned long base, unsigned long size) > +{ > + struct memblock_region *reg; > + unsigned long start, end; > + > + for_each_memblock(memory, reg) { > + start = max(base, (unsigned long)reg->base); > + end = reg->base + reg->size; > + end = min(base + size, end); > + > + if (start < end) > + memblock_reserve(start, end - start); > + } > +} > + > int __init fadump_reserve_mem(void) > { > unsigned long base, size, memory_boundary; > @@ -487,7 +502,7 @@ int __init fadump_reserve_mem(void) > */ > base = fw_dump.boot_memory_size; > size = memory_boundary - base; > - memblock_reserve(base, size); > + fadump_memblock_reserve(base, size); > printk(KERN_INFO "Reserved %ldMB of memory at %ldMB " Mahesh, you may want to change this print as well as it would be misleading in case of holes in the memory. Thanks Hari > "for saving crash dump\n", > (unsigned long)(size >> 20), >