* + kexec-add-helper-__crash_shrink_memory.patch added to mm-nonmm-unstable branch
@ 2023-05-30 22:04 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-05-30 22:04 UTC (permalink / raw)
To: mm-commits, holzheu, ebiederm, bhe, amwang, thunder.leizhen, akpm
The patch titled
Subject: kexec: add helper __crash_shrink_memory()
has been added to the -mm mm-nonmm-unstable branch. Its filename is
kexec-add-helper-__crash_shrink_memory.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kexec-add-helper-__crash_shrink_memory.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Zhen Lei <thunder.leizhen@huawei.com>
Subject: kexec: add helper __crash_shrink_memory()
Date: Sat, 27 May 2023 20:34:38 +0800
No functional change, in preparation for the next patch so that it is
easier to review.
Link: https://lkml.kernel.org/r/20230527123439.772-6-thunder.leizhen@huawei.com
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Cong Wang <amwang@redhat.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/kexec_core.c | 50 +++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 22 deletions(-)
--- a/kernel/kexec_core.c~kexec-add-helper-__crash_shrink_memory
+++ a/kernel/kexec_core.c
@@ -1105,11 +1105,37 @@ ssize_t crash_get_memory_size(void)
return size;
}
+int __crash_shrink_memory(struct resource *old_res, unsigned long new_size)
+{
+ struct resource *ram_res;
+
+ ram_res = kzalloc(sizeof(*ram_res), GFP_KERNEL);
+ if (!ram_res)
+ return -ENOMEM;
+
+ ram_res->start = old_res->start + new_size;
+ ram_res->end = old_res->end;
+ ram_res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM;
+ ram_res->name = "System RAM";
+
+ if (!new_size) {
+ release_resource(old_res);
+ old_res->start = 0;
+ old_res->end = 0;
+ } else {
+ crashk_res.end = ram_res->start - 1;
+ }
+
+ crash_free_reserved_phys_range(ram_res->start, ram_res->end);
+ insert_resource(&iomem_resource, ram_res);
+
+ return 0;
+}
+
int crash_shrink_memory(unsigned long new_size)
{
int ret = 0;
unsigned long old_size;
- struct resource *ram_res;
if (!kexec_trylock())
return -EBUSY;
@@ -1125,27 +1151,7 @@ int crash_shrink_memory(unsigned long ne
goto unlock;
}
- ram_res = kzalloc(sizeof(*ram_res), GFP_KERNEL);
- if (!ram_res) {
- ret = -ENOMEM;
- goto unlock;
- }
-
- ram_res->start = crashk_res.start + new_size;
- ram_res->end = crashk_res.end;
- ram_res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM;
- ram_res->name = "System RAM";
-
- if (!new_size) {
- release_resource(&crashk_res);
- crashk_res.start = 0;
- crashk_res.end = 0;
- } else {
- crashk_res.end = ram_res->start - 1;
- }
-
- crash_free_reserved_phys_range(ram_res->start, ram_res->end);
- insert_resource(&iomem_resource, ram_res);
+ ret = __crash_shrink_memory(&crashk_res, new_size);
unlock:
kexec_unlock();
_
Patches currently in -mm which might be from thunder.leizhen@huawei.com are
kexec-fix-a-memory-leak-in-crash_shrink_memory.patch
kexec-delete-a-useless-check-in-crash_shrink_memory.patch
kexec-clear-crashk_res-if-all-its-memory-has-been-released.patch
kexec-improve-the-readability-of-crash_shrink_memory.patch
kexec-add-helper-__crash_shrink_memory.patch
kexec-enable-kexec_crash_size-to-support-two-crash-kernel-regions.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-30 22:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 22:04 + kexec-add-helper-__crash_shrink_memory.patch added to mm-nonmm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.