public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] kexec: enable kexec_crash_size to support two crash kernel regions
@ 2023-05-27 12:34 Zhen Lei
  2023-05-27 12:34 ` [PATCH 1/6] kexec: fix a memory leak in crash_shrink_memory() Zhen Lei
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Zhen Lei @ 2023-05-27 12:34 UTC (permalink / raw)
  To: Eric Biederman, Baoquan He, kexec, linux-kernel
  Cc: Zhen Lei, Michael Holzheu, Andrew Morton, Amerigo Wang

When crashkernel=X fails to reserve region under 4G, it will fall back to
reserve region above 4G and a region of the default size will also be reserved
under 4G. Unfortunately, /sys/kernel/kexec_crash_size only supports one crash
kernel region now, the user cannot sense the low memory reserved by reading
/sys/kernel/kexec_crash_size. Also, low memory cannot be freed by writing this
file.

For example:
resource_size(crashk_res) = 512M
resource_size(crashk_low_res) = 256M

The result of 'cat /sys/kernel/kexec_crash_size' is 512M, but it should be 768M.
When we execute 'echo 0 > /sys/kernel/kexec_crash_size', the size of crashk_res
becomes 0 and resource_size(crashk_low_res) is still 256 MB, which is incorrect.

Since crashk_res manages the memory with high address and crashk_low_res manages
the memory with low address, crashk_low_res is shrunken only when all crashk_res
is shrunken. And because when there is only one crash kernel region, crashk_res
is always used. Therefore, if all crashk_res is shrunken and crashk_low_res still
exists, swap them.


Zhen Lei (6):
  kexec: fix a memory leak in crash_shrink_memory()
  kexec: delete a useless check in crash_shrink_memory()
  kexec: clear crashk_res if all its memory has been released
  kexec: improve the readability of crash_shrink_memory()
  kexec: add helper __crash_shrink_memory()
  kexec: enable kexec_crash_size to support two crash kernel regions

 kernel/kexec_core.c | 92 +++++++++++++++++++++++++++++++--------------
 1 file changed, 64 insertions(+), 28 deletions(-)

-- 
2.25.1


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

end of thread, other threads:[~2023-05-31 14:25 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-27 12:34 [PATCH 0/6] kexec: enable kexec_crash_size to support two crash kernel regions Zhen Lei
2023-05-27 12:34 ` [PATCH 1/6] kexec: fix a memory leak in crash_shrink_memory() Zhen Lei
2023-05-31  0:13   ` Baoquan He
2023-05-31  1:16     ` Leizhen (ThunderTown)
2023-05-31  7:31       ` Baoquan He
2023-05-27 12:34 ` [PATCH 2/6] kexec: delete a useless check " Zhen Lei
2023-05-31  0:17   ` Baoquan He
2023-05-31  2:19     ` Leizhen (ThunderTown)
2023-05-31  7:41       ` Baoquan He
2023-05-31  8:26         ` Leizhen (ThunderTown)
2023-05-27 12:34 ` [PATCH 3/6] kexec: clear crashk_res if all its memory has been released Zhen Lei
2023-05-31  0:33   ` Baoquan He
2023-05-27 12:34 ` [PATCH 4/6] kexec: improve the readability of crash_shrink_memory() Zhen Lei
2023-05-31  7:48   ` Baoquan He
2023-05-27 12:34 ` [PATCH 5/6] kexec: add helper __crash_shrink_memory() Zhen Lei
2023-05-28  0:08   ` kernel test robot
2023-05-29  0:37     ` Leizhen (ThunderTown)
2023-05-28  1:44   ` kernel test robot
2023-05-28  6:26   ` kernel test robot
2023-05-31  7:50   ` Baoquan He
2023-05-27 12:34 ` [PATCH 6/6] kexec: enable kexec_crash_size to support two crash kernel regions Zhen Lei
2023-05-31  9:53   ` Baoquan He
2023-05-31 14:25     ` Leizhen (ThunderTown)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox