-
Notifications
You must be signed in to change notification settings - Fork 21
Maximize the reserved size in osbuild case #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0021378
37d35f6
b78a909
015e0f9
1ef61a6
532ad21
7602d66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1210,6 +1210,53 @@ prepare_luks() | |||||||
| done | ||||||||
| } | ||||||||
|
|
||||||||
| get_crashkernel_bounce_buffer_size() | ||||||||
| { | ||||||||
| local lines first_line start_hex end_hex start_dec end_dec size_bytes | ||||||||
|
|
||||||||
| mapfile -t lines < <(grep "Crash kernel" /proc/iomem) | ||||||||
|
|
||||||||
| if [ ${#lines[@]} -le 1 ]; then | ||||||||
| echo 0 | ||||||||
| return | ||||||||
| fi | ||||||||
|
|
||||||||
| first_line=${lines[0]} | ||||||||
| # Extract start and end addresses | ||||||||
| start_hex=$(echo "$first_line" | awk '{split($1, a, "-"); print a[1]}') | ||||||||
| end_hex=$(echo "$first_line" | awk '{split($1, a, "-"); print a[2]}') | ||||||||
pfliu marked this conversation as resolved.
Show resolved
Hide resolved
coiby marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+1226
to
+1227
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two lines invoke
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @pfliu this suggestion from Gemini seems to make sense, what do you think? |
||||||||
| # Convert hex to decimal | ||||||||
| start_dec=$((0x$start_hex)) | ||||||||
| end_dec=$((0x$end_hex)) | ||||||||
| # Calculate size in bytes | ||||||||
| size_bytes=$((end_dec - start_dec + 1)) | ||||||||
| echo "$size_bytes" | ||||||||
| } | ||||||||
|
|
||||||||
| suggest_crashkernel_reset() | ||||||||
| { | ||||||||
| local _crashkernel _recommend_value _actual_value _bounce_buff_size | ||||||||
|
|
||||||||
| _crashkernel=$(sed -n 's/.*crashkernel=\([^ ]*\).*/\1/p' /proc/cmdline) | ||||||||
| [[ $(kdump_get_conf_val auto_reset_crashkernel) == no ]] && return | ||||||||
| # At present, the crashkernel value for fadump is not dynamic | ||||||||
| is_fadump_capable && return | ||||||||
|
|
||||||||
| _recommend_value=$(kdump_get_arch_recommend_size) | ||||||||
| # The crashkernel formula does not account for DMA-bounce buffers, | ||||||||
| # unlike kexec_crash_size which does. Systems using DMA-bounce buffers | ||||||||
| # should factor this into the calculation. | ||||||||
| _bounce_buff_size=$(get_crashkernel_bounce_buffer_size) | ||||||||
| _recommend_value=$(memsize_add "$_recommend_value" "$_bounce_buff_size") | ||||||||
| _recommend_value=$(to_bytes "$_recommend_value") | ||||||||
| _actual_value=$(cat /sys/kernel/kexec_crash_size) | ||||||||
|
|
||||||||
| if [ "$_recommend_value" -lt "$_actual_value" ]; then | ||||||||
| dwarn "The reserved crashkernel is abundant. Using 'kdumpctl reset-crashkernel' to reset kernel cmdline. It will take effect in the next boot" | ||||||||
| dwarn "To release the abundant memory immediately, you can run: 'kdumpctl stop; echo $_recommend_value >/sys/kernel/kexec_crash_size; kdumpctl start'" | ||||||||
| fi | ||||||||
| } | ||||||||
|
|
||||||||
| start() | ||||||||
| { | ||||||||
| check_dump_feasibility || return | ||||||||
|
|
@@ -1243,6 +1290,7 @@ start() | |||||||
| start_dump || return | ||||||||
|
|
||||||||
| dinfo "Starting kdump: [OK]" | ||||||||
| suggest_crashkernel_reset | ||||||||
| return 0 | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -1970,25 +2018,6 @@ reset_crashkernel_after_update() | |||||||
| done | ||||||||
| } | ||||||||
|
|
||||||||
| # read the value of an environ variable from given environ file path | ||||||||
| # | ||||||||
| # The environment variable entries in /proc/[pid]/environ are separated | ||||||||
| # by null bytes instead of by spaces. | ||||||||
| # | ||||||||
| # $1: environment variable | ||||||||
| # $2: environ file path | ||||||||
| read_proc_environ_var() | ||||||||
| { | ||||||||
| local _var=$1 _environ_path=$2 | ||||||||
| sed -n -E "s/.*(^|\x00)${_var}=([^\x00]*).*/\2/p" < "$_environ_path" | ||||||||
| } | ||||||||
|
|
||||||||
| _OSBUILD_ENVIRON_PATH='/proc/1/environ' | ||||||||
| _is_osbuild() | ||||||||
| { | ||||||||
| [[ $(read_proc_environ_var container "$_OSBUILD_ENVIRON_PATH") == bwrap-osbuild ]] | ||||||||
| } | ||||||||
|
|
||||||||
| reset_crashkernel_for_installed_kernel() | ||||||||
| { | ||||||||
| local _installed_kernel _grub_entry_index _kernel _old_ck _old_fadump | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.