From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Baoquan he <bhe@redhat.com>,
Hari Bathini <hbathini@linux.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 6/7] powerpc: insert System RAM resource to prevent crashkernel conflict
Date: Fri, 31 Jan 2025 17:08:29 +0530 [thread overview]
Message-ID: <20250131113830.925179-7-sourabhjain@linux.ibm.com> (raw)
In-Reply-To: <20250131113830.925179-1-sourabhjain@linux.ibm.com>
The next patch in the series with title "powerpc/crash: use generic
crashkernel reservation" enables powerpc to use generic crashkernel
reservation instead of custom implementation. This leads to exporting
of `Crash Kernel` memory to iomem_resource (/proc/iomem) via
insert_crashkernel_resources():kernel/crash_reserve.c or at another
place in the same file if
HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY is set.
The add_system_ram_resources():arch/powerpc/mm/mem.c adds `System RAM`
to iomem_resource using request_resource(). This creates a conflict with
`Crash Kernel`, which is added by the generic crashkernel reservation
code. As a result, the kernel ultimately fails to add `System RAM` to
iomem_resource. Consequently, it does not appear in /proc/iomem.
There are multiple approches tried to avoid this:
1. Don't add Crash Kernel to iomem_resource:
- This has two issues.
First, it requires adding an architecture-specific hook in the
generic code. There are already two code paths to choose when to
add `Crash Kernel` to iomem_resource. This adds one more code path
to skip it.
Second, what if `Crash Kernel` is required in /proc/iomem in the
future? Many architectures do export it.
2. Don't add `System RAM` to iomem_resource by reverting commit
c40dd2f766440 ("powerpc: Add System RAM to /proc/iomem"):
- It's not ideal to export `System RAM` via /proc/iomem, but since
it already done ealier and userspace tools like kdump and
kdump-utils rely on `System RAM` from /proc/iomem, removing it
will break userspace.
3. Add Crash Kernel along with System RAM to /proc/iomem:
This patch takes the third approach by updating
add_system_ram_resources() to use insert_resource() instead of the
request_resource() API to add the `System RAM` resource to
iomem_resource. insert_resource() allows inserting resources even if
they overlap with existing ones. Since `Crash Kernel` and `System RAM`
resources are added to iomem_resource early in the boot, any other
conflict is not expected.
With the changes introduced here and in the next patch, "powerpc/crash:
use generic crashkernel reservation," /proc/iomem now exports
`System RAM` and `Crash Kernel` as shown below:
$ cat /proc/iomem
00000000-3ffffffff : System RAM
10000000-4fffffff : Crash kernel
The kdump script is capable of handling `System RAM` and `Crash Kernel`
in the above format. The same format is used in other architectures.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baoquan he <bhe@redhat.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
CC: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: kexec@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
arch/powerpc/mm/mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index c7708c8fad29..615966d71425 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -376,7 +376,7 @@ static int __init add_system_ram_resources(void)
*/
res->end = end - 1;
res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
- WARN_ON(request_resource(&iomem_resource, res) < 0);
+ WARN_ON(insert_resource(&iomem_resource, res) < 0);
}
}
--
2.48.1
next prev parent reply other threads:[~2025-01-31 11:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 11:38 [PATCH v3 0/7] powerpc/crash: use generic crashkernel reservation Sourabh Jain
2025-01-31 11:38 ` [PATCH v3 1/7] kexec: Initialize ELF lowest address to ULONG_MAX Sourabh Jain
2025-01-31 11:38 ` [PATCH v3 2/7] crash: remove an unused argument from reserve_crashkernel_generic() Sourabh Jain
2025-01-31 11:38 ` [PATCH v3 3/7] crash: Let arch decide usable memory range in reserved area Sourabh Jain
2025-02-01 4:22 ` Baoquan he
2025-02-01 7:16 ` Sourabh Jain
2025-01-31 11:38 ` [PATCH v3 4/7] powerpc/crash: Use generic APIs to locate memory hole for kdump Sourabh Jain
2025-01-31 11:38 ` [PATCH v3 5/7] powerpc/crash: preserve user-specified memory limit Sourabh Jain
2025-01-31 11:38 ` Sourabh Jain [this message]
2025-01-31 11:38 ` [PATCH v3 7/7] powerpc/crash: use generic crashkernel reservation Sourabh Jain
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=20250131113830.925179-7-sourabhjain@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=hbathini@linux.ibm.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
/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