From patchwork Tue Oct 8 13:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13826482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1148CEF172 for ; Tue, 8 Oct 2024 13:27:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46FCA6B0088; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 420416B0089; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2983A6B008A; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 09E686B0088 for ; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B465E160C6D for ; Tue, 8 Oct 2024 13:27:46 +0000 (UTC) X-FDA: 82650512574.16.28E9D46 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf11.hostedemail.com (Postfix) with ESMTP id BA15640016 for ; Tue, 8 Oct 2024 13:27:45 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Qktk4Alp; spf=pass (imf11.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728393997; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iORC/3+gFiV4oQN4Aw7kbFgz84yNOuZ0Gq1M6ocZ+00=; b=EXrIPW3pgICk2LtzkTwSYks29h8pSEh70VfQM8efFygg2O7hD5ryBk4ycAgq98LAFin0YS Y53coVJs+G06OQiO/5r60tOMuUBBQFPKyyRRES8xUOK2ocsp/OvA2QILdcvc//PtrjrI3G XhvMekGKRmrNBxigkO+8yg1GJ299Oi4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Qktk4Alp; spf=pass (imf11.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728393997; a=rsa-sha256; cv=none; b=XrN5dNkNf/8OKLvxxPgxGjVF/S3de4Os+CKpbt3ZwvUkb8k9u1j3VxvL63z5q95Ax+Bji7 rO2TD7ERxy/doUAZh4S+/uCzJ2TvNYG/XBIhVGZ20itWR7+zpVDlwCkPV6vmyxFNiBnGsr Vx+EdS1GAqSMfR8U2dwyCMoj9gIGKUQ= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7ea03ecf191so2025922a12.0 for ; Tue, 08 Oct 2024 06:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728394064; x=1728998864; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iORC/3+gFiV4oQN4Aw7kbFgz84yNOuZ0Gq1M6ocZ+00=; b=Qktk4Alp8VFPmnvU6WeQScqkwf8PBR2k5uLIGFFH16b0QMJWRnSVnaRLnBUSip9TJa td0GoZpbzuHrXjzUmyzdr3EvNzOQv+LA/WeEkq/8beuxa/p36lREDHu6TIVfaTRHd/t7 YJuxLwYjn6EdfWsEgXFuNt2S2k4Zn9PtjgVoJW8rFVPGXquC9sEIslyeCfst5YbPG472 QRtqjtOGt6IKj/KQ+d9LTQx1F+S22fiuKQB1WUJvvxzy03t0EC2nkBdzlHAj/zgcdHZM 7sCftUr2PThx/L41VRc8u2WNx2MW5e+5CX0pAMpu8dk8FqolP7gPqsUbgl85kt6OgxSJ NFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728394064; x=1728998864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iORC/3+gFiV4oQN4Aw7kbFgz84yNOuZ0Gq1M6ocZ+00=; b=Hr0I9dz59sHnLIflwMCSQH8UmX/ihZZYuUAZbxsEtPjKijGY2mDD0gUn2Df7f/WTCb B+WwQkhASEPW3gHsugS8gGzjG69j9rg8Kh73BwQ193+CCsIBNDmszxd+i97e6VcamBvq dEDqqyGlUgJKU4mxNROSY34bA7QPLiElP9VLhs8/eHnjNcDWFR+jwcZ1mQbV3mu1SI97 SvdUWQSn7vjiTJCXR9/2L6KMprVshe8bPKuE2i4XqiMktI5EQTm/dM1SxA6VfSnZQak6 v2JLZaKYeNVdVfRdfprgaGeJ6NgLuxLQEK9h1sA9AqcLAUjAEYDZejWCD7L+ArhiFcQS ZzfQ== X-Gm-Message-State: AOJu0YyZeh3UNljp6astMVVoA9aXTBrUs1x0Z1d3kBd/bIZxUeocTx6o 1GU1x6/T8dDoT1GWG91f+el/PYxhLjF9+e8aoUO4GnhZCXYotXfK X-Google-Smtp-Source: AGHT+IFUSmB5qj013ukPWcd2PnqbxEbtyk9xGORICVlDGwgM/Alk+7OzaNIs/iU7kZlzw9YIiIXvNQ== X-Received: by 2002:a17:90b:360f:b0:2d8:8175:38c9 with SMTP id 98e67ed59e1d1-2e1e626c076mr18806026a91.20.1728394064555; Tue, 08 Oct 2024 06:27:44 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.87.188]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20af4655dsm7628992a91.27.2024.10.08.06.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 06:27:43 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Sourabh Jain , Hari Bathini , Zi Yan , David Hildenbrand , "Kirill A . Shutemov" , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , "Ritesh Harjani (IBM)" Subject: [RFC 2/2] fadump: Make fadump reserve_dump_area_start CMA aligned in case of holes Date: Tue, 8 Oct 2024 18:57:19 +0530 Message-ID: <7950c20ae9f771a39eb0c0d568beb8681fee0209.1728386179.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: BA15640016 X-Stat-Signature: nqeftae6kwftp8ic4u9ic89sa1nsns4n X-HE-Tag: 1728394065-43924 X-HE-Meta: U2FsdGVkX18aUD73BA3+VehW4k1qPlN/exbbTRRwAv6NPb3+Ciq/Ph6jfiY5SaDde7XgCvr6qkD7iCPr/kNnWHkNhltA7n/TqDu1xfbZKe/w32Raa2o+3SOa0ok9anWNksFsrxNZmb1f+5U/qrsqGLuwF3ovluCA2urT+Q82fWCRRb2aCrybQHk6OejFZVzdMmg49IlAUWEJC4ZZPD621kPNFKiHxnO88H2QtHW7OuMFEQ+bib0ergngMq7aCSzz2wDFjdudCmAQ/x6jI8EKIVuBS2S/Rnno4SLR0RJWgqwGNG84KlCqP/Mwl7KVRIVs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4L0MhiNUGBPOIiAxU7St7H+RbR0KMtaBlZjNyOyZwoiDmwRfDJizE0Zd44i6WxBioTJmgvx/AWX0A4yJ55nxO4dip+KQl/EJE5iu812YOZD55Gp5tPfAbfbZf9qLxfS8PBf2JDQIPoVJdf1AUumIqgo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Consider cma alignment into account while calculating base address for fadump memory allocation. Physical memory ranges can have holes and fadump_locate_reserve_mem() tries to find a suitable base address. If CMA is enabled and fadump nocma is false then we need to consider CMA_MIN_ALIGNMENT_BYTES for reserve_dump_area_start. For e.g. in case of below memory layout, the most suitable base address is 0x00000501000000 for crashkernel=4097M which is 16M (order 8) aligned as expected by CMA_MIN_ALIGNMENT_BYTES on PPC64 during early boot (when pageblock_order is still not initialized) ~ # cat /proc/iomem 00000000-1fffffff : System RAM 100000000-1ffffffff : System RAM 300000000-3ffffffff : System RAM 500200000-9001fffff : System RAM ~ # dmesg |grep -Ei "fadump|cma" fadump: Reserved 4112MB of memory at 0x00000501000000 (System RAM: 25088MB) fadump: Initialized 0x101000000 bytes cma area at 20496MB from 0x1010002a8 bytes of memory reserved for firmware-assisted dump Kernel command line: root=/dev/vda1 console=ttyS0 nokaslr slub_max_order=0 norandmaps noreboot crashkernel=4097M fadump=on disable_radix=no debug_pagealloc=off Memory: 21246656K/25690112K available (31872K kernel code, 4544K rwdata, 17280K rodata, 9216K init, 2212K bss, 218432K reserved, 4210688K cma-reserved) Reported-by: Sourabh Jain Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/kernel/fadump.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index a612e7513a4f..15ea9c80bc03 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -512,6 +512,10 @@ static u64 __init fadump_locate_reserve_mem(u64 base, u64 size) phys_addr_t mstart, mend; int idx = 0; u64 i, ret = 0; + unsigned long align = PAGE_SIZE; + + if (IS_ENABLED(CONFIG_CMA) && !fw_dump.nocma) + align = CMA_MIN_ALIGNMENT_BYTES; mrngs = reserved_mrange_info.mem_ranges; for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, @@ -520,7 +524,7 @@ static u64 __init fadump_locate_reserve_mem(u64 base, u64 size) i, mstart, mend, base); if (mstart > base) - base = PAGE_ALIGN(mstart); + base = ALIGN(mstart, align); while ((mend > base) && ((mend - base) >= size)) { if (!overlaps_reserved_ranges(base, base+size, &idx)) { @@ -529,7 +533,7 @@ static u64 __init fadump_locate_reserve_mem(u64 base, u64 size) } base = mrngs[idx].base + mrngs[idx].size; - base = PAGE_ALIGN(base); + base = ALIGN(base, align); } }