From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp.subspace.kernel.org (Postfix) with ESMTPS id BE51E210C11 for ; Fri, 11 Oct 2024 10:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728643895; cv=none; b=l2QpNuVYj+D2PWto3IzSQNf+bsW/R1ZCoTltdcasS+nE3XkjLjxTzgQ9/Y3yms45xOxtwaJzPLp7SvMPOm/lPSUkU7J9GP0+3WTErCbRKYoip9nMHWxPUm0DAiGN7Psuu9xACtgVEdwlCULmr/g54QRsKnlWhbwO4hMjDH94Sww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728643895; c=relaxed/simple; bh=fNhyI6ymc6rJ1kwU8KUBeH8/VwjHky8J3lzfen6Qfyo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l2lmi01wZUSOUoF2P91o53mLOZVIu+RPNYWKQ0Ee2hVY/YlfZkI82GROuds0Uew3+XqbHG5AS0oA2r7n0OL6UtBMcnPz0PLw2Tk4k8kBQT8vusesTf5LKq2b7M1cly+O+5RBzS5alSSzgFzun12pUfNppQu5nU1BZIJs7xUeA5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=DMRcghGn; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="DMRcghGn" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49BAfdpF024450; Fri, 11 Oct 2024 10:51:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s=pp1; bh=8 eHmySt2v8x+g0bchETYaHvtXRQ86U1s8qdg2O3ls68=; b=DMRcghGnWEAHJc2sI aw9j7SdWtf5M0leg2AKI3hT2vVml/82nUHhOFT0LQDzQwlNFdY3FMg7jGtc4riTA eefBFYJYfxENjWrH9H/rRlncZA9aZBOcIjt6uT71gIx1sXflCTGnLTgZgX21TKdR IzbRlD3gY8J+HTTKLKJer5DY+txleze023JeCaOBr+rx0zi4FnF7f55i5ApxCHli qE+iGKKtiI7B3dTCQldSVfv2NGZJdexSipfsh4i4PDV05Ym0x/AAfmRBXLDM01BD 7tajdCj9VxHiaaK1qB1fZ12ECMCY6iXiOuCtXbjFZa9zi9Vi+uNMM/8nVAJPrjoq tYlEg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4272g201kt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2024 10:51:18 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 49BApH2Y018293; Fri, 11 Oct 2024 10:51:17 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4272g201kf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2024 10:51:17 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49B8sCRO022671; Fri, 11 Oct 2024 10:51:16 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 423h9kcub4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Oct 2024 10:51:16 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49BApCiL20578890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Oct 2024 10:51:12 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A8222004B; Fri, 11 Oct 2024 10:51:12 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 579EA20043; Fri, 11 Oct 2024 10:51:09 +0000 (GMT) Received: from [9.43.15.249] (unknown [9.43.15.249]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Oct 2024 10:51:09 +0000 (GMT) Message-ID: <5438c185-37ef-467c-8e92-528cf57d30e0@linux.ibm.com> Date: Fri, 11 Oct 2024 16:21:08 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC v2 3/4] fadump: Reserve page-aligned boot_memory_size during fadump_reserve_mem To: "Ritesh Harjani (IBM)" , linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Sourabh Jain , Zi Yan , David Hildenbrand , "Kirill A . Shutemov" , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , Sachin P Bappalige References: <4cea3a03fb0a9f52dbd6b62ec21209abf14fb7bf.1728585512.git.ritesh.list@gmail.com> Content-Language: en-US From: Hari Bathini In-Reply-To: <4cea3a03fb0a9f52dbd6b62ec21209abf14fb7bf.1728585512.git.ritesh.list@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: nqiSRij2h5kps6ABDn2ZFzJEFI8kx6-j X-Proofpoint-GUID: 4N4onGlyq2D23RRKyjAMKVtP74AVfPyX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-11_08,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 clxscore=1011 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410110074 On 11/10/24 12:53 pm, Ritesh Harjani (IBM) wrote: > This patch refactors all CMA related initialization and alignment code > to within fadump_cma_init() which gets called in the end. This also means > that we keep [reserve_dump_area_start, boot_memory_size] page aligned > during fadump_reserve_mem(). Then later in fadump_cma_init() we extract the > aligned chunk and provide it to CMA. This inherently also fixes an issue in > the current code where the reserve_dump_area_start is not aligned > when the physical memory can have holes and the suitable chunk starts at > an unaligned boundary. > > After this we should be able to call fadump_cma_init() independently > later in setup_arch() where pageblock_order is non-zero. > > Suggested-by: Sourabh Jain > Signed-off-by: Ritesh Harjani (IBM) > --- > arch/powerpc/kernel/fadump.c | 34 ++++++++++++++++++++++------------ > 1 file changed, 22 insertions(+), 12 deletions(-) > > diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c > index 162327d66982..ffaec625b7a8 100644 > --- a/arch/powerpc/kernel/fadump.c > +++ b/arch/powerpc/kernel/fadump.c > @@ -80,7 +80,7 @@ static struct cma *fadump_cma; > */ > static void __init fadump_cma_init(void) > { > - unsigned long long base, size; > + unsigned long long base, size, end; > int rc; > > if (!fw_dump.fadump_supported || !fw_dump.fadump_enabled || > @@ -92,8 +92,24 @@ static void __init fadump_cma_init(void) > if (fw_dump.nocma || !fw_dump.boot_memory_size) > return; > > + /* > + * [base, end) should be reserved during early init in > + * fadump_reserve_mem(). No need to check this here as > + * cma_init_reserved_mem() already checks for overlap. > + * Here we give the aligned chunk of this reserved memory to CMA. > + */ > base = fw_dump.reserve_dump_area_start; > size = fw_dump.boot_memory_size; > + end = base + size; > + > + base = ALIGN(base, CMA_MIN_ALIGNMENT_BYTES); > + end = ALIGN_DOWN(end, CMA_MIN_ALIGNMENT_BYTES); > + size = end - base; > + > + if (end <= base) { > + pr_warn("%s: Too less memory to give to CMA\n", __func__); > + return; > + } > > rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma); > if (rc) { > @@ -116,11 +132,12 @@ static void __init fadump_cma_init(void) > /* > * So we now have successfully initialized cma area for fadump. > */ > - pr_info("Initialized 0x%lx bytes cma area at %ldMB from 0x%lx " > + pr_info("Initialized [0x%llx, %luMB] cma area from [0x%lx, %luMB] " > "bytes of memory reserved for firmware-assisted dump\n", > - cma_get_size(fadump_cma), > - (unsigned long)cma_get_base(fadump_cma) >> 20, > - fw_dump.reserve_dump_area_size); > + cma_get_base(fadump_cma), cma_get_size(fadump_cma) >> 20, > + fw_dump.reserve_dump_area_start, > + fw_dump.boot_memory_size >> 20); The changes look good. Thanks for looking into it. For patches 2, 3 & 4 Acked-by: Hari Bathini > + return; > } > #else > static void __init fadump_cma_init(void) { } > @@ -553,13 +570,6 @@ int __init fadump_reserve_mem(void) > if (!fw_dump.dump_active) { > fw_dump.boot_memory_size = > PAGE_ALIGN(fadump_calculate_reserve_size()); > -#ifdef CONFIG_CMA > - if (!fw_dump.nocma) { > - fw_dump.boot_memory_size = > - ALIGN(fw_dump.boot_memory_size, > - CMA_MIN_ALIGNMENT_BYTES); > - } > -#endif > > bootmem_min = fw_dump.ops->fadump_get_bootmem_min(); > if (fw_dump.boot_memory_size < bootmem_min) {