From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: linux-mm@kvack.org, Sourabh Jain <sourabhjain@linux.ibm.com>,
Hari Bathini <hbathini@linux.ibm.com>, Zi Yan <ziy@nvidia.com>,
David Hildenbrand <david@redhat.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
Donet Tom <donettom@linux.vnet.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
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 [thread overview]
Message-ID: <7950c20ae9f771a39eb0c0d568beb8681fee0209.1728386179.git.ritesh.list@gmail.com> (raw)
In-Reply-To: <c1e66d3e69c8d90988c02b84c79db5d9dd93f053.1728386179.git.ritesh.list@gmail.com>
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 <sourabhjain@linux.ibm.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/kernel/fadump.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
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);
}
}
--
2.46.0
next prev parent reply other threads:[~2024-10-08 13:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 13:27 [RFC 1/2] cma: Fix CMA_MIN_ALIGNMENT_BYTES during early_init Ritesh Harjani (IBM)
2024-10-08 13:27 ` Ritesh Harjani (IBM) [this message]
2024-10-08 13:50 ` David Hildenbrand
2024-10-10 3:19 ` Ritesh Harjani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7950c20ae9f771a39eb0c0d568beb8681fee0209.1728386179.git.ritesh.list@gmail.com \
--to=ritesh.list@gmail.com \
--cc=aneesh.kumar@kernel.org \
--cc=david@redhat.com \
--cc=donettom@linux.vnet.ibm.com \
--cc=hbathini@linux.ibm.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=sourabhjain@linux.ibm.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).