linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] kexec_file: Load kernel at top of system RAM if required
@ 2023-11-14  9:16 Baoquan He
  2023-11-14  9:16 ` [PATCH 1/2] resource: add walk_system_ram_res_rev() Baoquan He
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Baoquan He @ 2023-11-14  9:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: kexec, x86, linux-parisc, linuxppc-dev, linux-riscv, linux-s390,
	akpm, ebiederm, takahiro.akashi, Baoquan He

Justification:
==============
Kexec_load interface has been doing top down searching and loading
kernel/initrd/purgtory etc to prepare for kexec reboot. In that way,
the benefits are that it avoids to consume and fragment limited low
memory which satisfy DMA buffer allocation and big chunk of continuous
memory during system init; and avoids to stir with BIOS/FW reserved
or occupied areas, or corner case handling/work around/quirk occupied
areas when doing system init. By the way, the top-down searching and
loading of kexec-ed kernel is done in user space utility code.

For kexec_file loading, even if kexec_buf.top_down is 'true', it's simply
ignored. It calls walk_system_ram_res() directly to go through all
resources of System RAM bottom up, to find an available memory region,
then call locate_mem_hole_callback() to allocate memory in that found
memory region from top to down. This is not expected and inconsistent
with kexec_load.

Implementation
===============
In patch 1, introduce a new function walk_system_ram_res_rev() which is
a variant of walk_system_ram_res(), it walks through a list of all the
resources of System RAM in reversed order, i.e., from higher to lower.

In patch 2, check if kexec_buf.top_down is 'true' in kexec_walk_resources(),
if yes, call walk_system_ram_res_rev() to find memory region of system RAM
from top to down to load kernel/initrd etc.

Background information:
=======================
And I ever tried this in the past in a different way, please see below
link. In the post, I tried to adjust struct sibling linking code,
replace the the singly linked list with list_head so that
walk_system_ram_res_rev() can be implemented in a much easier way.
Finally I failed.
https://lore.kernel.org/all/20180718024944.577-4-bhe@redhat.com/

This time, I picked up the patch from AKASHI Takahiro's old post and
made some change to take as the current patch 1:
https://lists.infradead.org/pipermail/linux-arm-kernel/2017-September/531456.html

Testing:
========
Only tried on x86_64

Baoquan He (2):
  resource: add walk_system_ram_res_rev()
  kexec_file: Load kernel at top of system RAM if required

 include/linux/ioport.h |  3 +++
 kernel/kexec_file.c    |  2 ++
 kernel/resource.c      | 61 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 19+ messages in thread
* [PATCH 0/2] Kexec_file: Load kernel at top of system ram
@ 2018-03-22  3:37 Baoquan He
  2018-03-22  3:37 ` [PATCH 1/2] resource: add walk_system_ram_res_rev() Baoquan He
  0 siblings, 1 reply; 19+ messages in thread
From: Baoquan He @ 2018-03-22  3:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: kexec, akpm, takahiro.akashi, ebiederm, vgoyal, dyoung, prudo,
	Baoquan He

The current kexec_file ignores kexec_buf.top_down value when call
arch_kexec_walk_mem() to allocate memory for loading kernel/initrd
stuffs. This is not supposed to be what kexec_buf.top_down is used
for.

In patch 0001, introduce a new function walk_system_ram_res_rev()
which is a variant of walk_system_ram_res(), walks through resources
of System RAM from top to down. And patch 0001 is picked from AKASHI's
patchset which adds arm64 kexec_file support. His next round of post
won't need walk_system_ram_res_rev any more, so I take it into this
patchset and use it in patch 0002.

In patch 0002, check kexec_buf.top_down in arch_kexec_walk_mem(),
if its value is 'true', call walk_system_ram_res_rev(). Otherwise
call walk_system_ram_res().

AKASHI Takahiro (1):
  resource: add walk_system_ram_res_rev()

Baoquan He (1):
  kexec_file: Load kernel at top of system RAM if required

 include/linux/ioport.h |  3 +++
 kernel/kexec_file.c    |  2 ++
 kernel/resource.c      | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-01-20 21:09 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-14  9:16 [PATCH 0/2] kexec_file: Load kernel at top of system RAM if required Baoquan He
2023-11-14  9:16 ` [PATCH 1/2] resource: add walk_system_ram_res_rev() Baoquan He
2023-11-14 23:17   ` Andrew Morton
2023-11-15  0:40     ` Baoquan He
2023-11-15 13:00   ` [PATCH v2 " Baoquan He
2023-11-23 13:27     ` Baoquan He
2024-01-20 21:09     ` patchwork-bot+linux-riscv
2023-11-14  9:16 ` [PATCH 2/2] kexec_file: Load kernel at top of system RAM if required Baoquan He
2024-01-20 21:09 ` [PATCH 0/2] " patchwork-bot+linux-riscv
  -- strict thread matches above, loose matches on Subject: below --
2018-03-22  3:37 [PATCH 0/2] Kexec_file: Load kernel at top of system ram Baoquan He
2018-03-22  3:37 ` [PATCH 1/2] resource: add walk_system_ram_res_rev() Baoquan He
2018-03-22 22:29   ` Andrew Morton
2018-03-23  0:58     ` Baoquan He
2018-03-23  2:06       ` Andrew Morton
2018-03-23  3:10         ` Baoquan He
2018-03-23 20:06           ` Andrew Morton
2018-03-24 13:33             ` Baoquan He
2018-03-24 16:13               ` Wei Yang
2018-03-26 14:30                 ` Baoquan He
2018-03-26 15:04                   ` Wei Yang

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).