Currently _crashkernel_add can't deal with a terabyte memory range e.g. _crashkernel_add "128G-1T:4G" "0" actually returns empty result.
Fixes: 64f2827a ("kdump-lib: Harden _crashkernel_add") Signed-off-by: Coiby Xu coxu@redhat.com --- kdump-lib.sh | 11 +++++++++-- spec/kdump-lib_spec.sh | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c236..c7fa6c16 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 }
-is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[BbKkMmGgTt]?$ ]]; }
# range defined for crashkernel parameter # i.e. <start>-[<end>] @@ -881,6 +881,9 @@ to_bytes() is_memsize "$_s" || return 1
case "${_s: -1}" in + B|b) + _s=${_s::-1} + ;; K|k) _s=${_s::-1} _s="$((_s * 1024))" @@ -893,6 +896,10 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;; + T|t) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024))" + ;; *) ;; esac @@ -901,7 +908,7 @@ to_bytes()
memsize_add() { - local -a units=("" "K" "M" "G") + local -a units=("" "K" "M" "G" "T") local i a b
a=$(to_bytes "$1") || return 1 diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f9618..ae94e609 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,18 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M" + "1G-4G:256M" "100B" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low" + "128G-1T:4G" "0" "128G-1T:4G" + "10T-100T:1T" "0" "10T-100T:1T" + "128G-1T:4G" "0M" "128G-1T:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G" - "1099511627776" "0" "1024G" + "1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2"
On 11/03/23 at 11:42am, Coiby Xu wrote:
Currently _crashkernel_add can't deal with a terabyte memory range e.g. _crashkernel_add "128G-1T:4G" "0" actually returns empty result.
If the missing units are found out, do we need consider Peta Bytes in advance? Now several ARCH-es have taken PB memory into support. Just a minor concern because the system with PB memory board is very rare.
Fixes: 64f2827a ("kdump-lib: Harden _crashkernel_add") Signed-off-by: Coiby Xu coxu@redhat.com
kdump-lib.sh | 11 +++++++++-- spec/kdump-lib_spec.sh | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c236..c7fa6c16 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 }
-is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[BbKkMmGgTt]?$ ]]; }
# range defined for crashkernel parameter # i.e. <start>-[<end>] @@ -881,6 +881,9 @@ to_bytes() is_memsize "$_s" || return 1
case "${_s: -1}" in
B|b)
_s=${_s::-1}
K|k) _s=${_s::-1} _s="$((_s * 1024))";;
@@ -893,6 +896,10 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;;
T|t)
_s=${_s::-1}
_s="$((_s * 1024 * 1024 * 1024 * 1024))"
*) ;; esac;;
@@ -901,7 +908,7 @@ to_bytes()
memsize_add() {
- local -a units=("" "K" "M" "G")
local -a units=("" "K" "M" "G" "T") local i a b
a=$(to_bytes "$1") || return 1
diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f9618..ae94e609 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,18 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M"
"1G-4G:256M" "100B" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low"
"128G-1T:4G" "0" "128G-1T:4G"
"10T-100T:1T" "0" "10T-100T:1T"
"128G-1T:4G" "0M" "128G-1T:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G"
"1099511627776" "0" "1024G"
"1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2"
-- 2.41.0
On Fri, 3 Nov 2023 17:09:10 +0800 Baoquan He bhe@redhat.com wrote:
On 11/03/23 at 11:42am, Coiby Xu wrote:
Currently _crashkernel_add can't deal with a terabyte memory range e.g. _crashkernel_add "128G-1T:4G" "0" actually returns empty result.
If the missing units are found out, do we need consider Peta Bytes in advance? Now several ARCH-es have taken PB memory into support. Just a minor concern because the system with PB memory board is very rare.
Makes sense, when we want to copy the behavior of the kernels memparse function, which is used to parse the crashkernel value. But then we should also Exa Bytes (E). Even when it's pretty unlikely to be used any time soon.
Furthermore, this patch silently also adds the Bb for Bytes. Which personally I don't think is necessary. But I don't have a very strong opinion on it. So if you prefer to have it we can keep it.
Thanks Philipp
Fixes: 64f2827a ("kdump-lib: Harden _crashkernel_add") Signed-off-by: Coiby Xu coxu@redhat.com
kdump-lib.sh | 11 +++++++++-- spec/kdump-lib_spec.sh | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c236..c7fa6c16 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 }
-is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[BbKkMmGgTt]?$ ]]; }
# range defined for crashkernel parameter # i.e. <start>-[<end>] @@ -881,6 +881,9 @@ to_bytes() is_memsize "$_s" || return 1
case "${_s: -1}" in
B|b)
_s=${_s::-1}
K|k) _s=${_s::-1} _s="$((_s * 1024))";;
@@ -893,6 +896,10 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;;
T|t)
_s=${_s::-1}
_s="$((_s * 1024 * 1024 * 1024 * 1024))"
*) ;; esac;;
@@ -901,7 +908,7 @@ to_bytes()
memsize_add() {
- local -a units=("" "K" "M" "G")
local -a units=("" "K" "M" "G" "T") local i a b
a=$(to_bytes "$1") || return 1
diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f9618..ae94e609 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,18 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M"
"1G-4G:256M" "100B" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low"
"128G-1T:4G" "0" "128G-1T:4G"
"10T-100T:1T" "0" "10T-100T:1T"
"128G-1T:4G" "0M" "128G-1T:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G"
"1099511627776" "0" "1024G"
"1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2"
-- 2.41.0
Currently _crashkernel_add can't deal with larger memory ranges like terabyte. For example, '_crashkernel_add "128G-1T:4G" "0"' actually returns empty result. This patch allows _crashkernel_add to address terabyte, petabyte and exabyte memory ranges.
Fixes: 64f2827a ("kdump-lib: Harden _crashkernel_add") Signed-off-by: Coiby Xu coxu@redhat.com --- v2 - add petabyte and exabyte support [Baoquan, Philipp] - remove Bb [Philipp] --- kdump-lib.sh | 16 ++++++++++++++-- spec/kdump-lib_spec.sh | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c236..9c1d9e1c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 }
-is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGgTtPbEe]?$ ]]; }
# range defined for crashkernel parameter # i.e. <start>-[<end>] @@ -893,6 +893,18 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;; + T|t) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024))" + ;; + P|p) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024))" + ;; + E|e) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024 * 1024))" + ;; *) ;; esac @@ -901,7 +913,7 @@ to_bytes()
memsize_add() { - local -a units=("" "K" "M" "G") + local -a units=("" "K" "M" "G" "T" "P" "E") local i a b
a=$(to_bytes "$1") || return 1 diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f9618..f13372c7 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,20 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M" + "1G-4G:256M" "100" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low" + "128G-1T:4G" "0" "128G-1T:4G" + "10T-100T:1T" "0" "10T-100T:1T" + "128G-1T:4G" "0M" "128G-1T:4G" + "128G-1P:4G" "0M" "128G-1P:4G" + "128G-1E:4G" "0M" "128G-1E:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G" - "1099511627776" "0" "1024G" + "1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2"
On 11/06/23 at 11:14am, Coiby Xu wrote:
Currently _crashkernel_add can't deal with larger memory ranges like terabyte. For example, '_crashkernel_add "128G-1T:4G" "0"' actually returns empty result. This patch allows _crashkernel_add to address terabyte, petabyte and exabyte memory ranges.
Fixes: 64f2827a ("kdump-lib: Harden _crashkernel_add") Signed-off-by: Coiby Xu coxu@redhat.com
v2
- add petabyte and exabyte support [Baoquan, Philipp]
- remove Bb [Philipp]
kdump-lib.sh | 16 ++++++++++++++-- spec/kdump-lib_spec.sh | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-)
LGTM,
Acked-by: Baoquan He bhe@redhat.com
diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c236..9c1d9e1c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 }
-is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGgTtPbEe]?$ ]]; }
# range defined for crashkernel parameter # i.e. <start>-[<end>] @@ -893,6 +893,18 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;;
T|t)
_s=${_s::-1}
_s="$((_s * 1024 * 1024 * 1024 * 1024))"
;;
P|p)
_s=${_s::-1}
_s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024))"
;;
E|e)
_s=${_s::-1}
_s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024 * 1024))"
*) ;; esac;;
@@ -901,7 +913,7 @@ to_bytes()
memsize_add() {
- local -a units=("" "K" "M" "G")
local -a units=("" "K" "M" "G" "T" "P" "E") local i a b
a=$(to_bytes "$1") || return 1
diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f9618..f13372c7 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,20 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M"
"1G-4G:256M" "100" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low"
"128G-1T:4G" "0" "128G-1T:4G"
"10T-100T:1T" "0" "10T-100T:1T"
"128G-1T:4G" "0M" "128G-1T:4G"
"128G-1P:4G" "0M" "128G-1P:4G"
"128G-1E:4G" "0M" "128G-1E:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G"
"1099511627776" "0" "1024G"
"1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2"
-- 2.41.0 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue