cxl/test: use max_available_extent in cxl-destroy-region
[email protected]
maintainerPATCH 1/1 cxl/test: use max_available_extent in cxl-destroy-region
From: Alison Schofield <[email protected]>
Using .size in decoder selection can lead to a set_size failure with these error messages:
cxl region: create_region: region8: set_size failed: Numerical result out of range
[] cxl_core:alloc_hpa:555: cxl region8: HPA allocation error (-34) for size:0x0000000020000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags 0x200]
Use max_available_extent for decoder selection instead.
The test overlooked the region creation failure because it used a not 'null' comparison which always succeeds. Use the ! comparator after create-region and for the ramsize check so that the test fails or continues as expected.
--- test/cxl-destroy-region.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
test/cxl-destroy-region.sh +4 -4
@@ -22,7 +22,7 @@ check_destroy_ram() decoder=$2 region="$("$CXL" create-region -d "$decoder" -m "$mem" | jq -r ".region")" - if [ "$region" == "null" ]; then + if [[ ! $region ]]; then err "$LINENO" fi "$CXL" enable-region "$region"
@@ -38,7 +38,7 @@ check_destroy_devdax() decoder=$2 region="$("$CXL" create-region -d "$decoder" -m "$mem" | jq -r ".region")" - if [ "$region" == "null" ]; then + if [[ ! $region ]]; then err "$LINENO" fi "$CXL" enable-region "$region"
@@ -55,14 +55,14 @@ check_destroy_devdax() readarray -t mems < <("$CXL" list -b "$CXL_TEST_BUS" -M | jq -r '.[].memdev') for mem in "${mems[@]}"; do ramsize="$("$CXL" list -m "$mem" | jq -r '.[].ram_size')" - if [[ $ramsize == "null" ]]; then + if [[ ! $ramsize ]]; then continue fi decoder="$("$CXL" list -b "$CXL_TEST_BUS" -D -d root -m "$mem" | jq -r ".[] | select(.volatile_capable == true) | select(.nr_targets == 1) | - select(.size >= ${ramsize}) | + select(.max_available_extent >= ${ramsize}) | .decoder")" if [[ $decoder ]]; then check_destroy_ram "$mem" "$decoder"
base-commit: e0d0680bd3e554bd5f211e989480c5a13a023b2d
Signature · 1 line
2.37.3
Verma, Vishal L
maintainerQuoted 38 lines · On Wed, 2024-03-27 at 11:46 -0700, [email protected] wrote:
From: Alison Schofield <[email protected]>
Using .size in decoder selection can lead to a
set_sizefailure with these error messages:cxl region:
create_region: region8:set_sizefailed: Numerical result out of range[] cxl_core:alloc_hpa:555: cxl region8: HPA allocation error (-34) for size:0x0000000020000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags
0x200]Use
max_available_extentfor decoder selection instead.The test overlooked the region creation failure because it used a not 'null' comparison which always succeeds. Use the ! comparator after create-region and for the ramsize check so that the test fails or continues as expected.
Signed-off-by Alison Schofield <[email protected]>---
test/cxl-destroy-region.sh | 8 ++++----1 file changed, 4 insertions(+), 4 deletions(-)test/cxl-destroy-region.sh +0
-0@@ -22,7 +22,7 @@ check_destroy_ram()decoder=$2
region="$("$CXL" create-region -d "$decoder" -m "$mem" | jq -r ".region")"test/cxl-destroy-region.sh +1
-1- if [ "$region" == "null" ]; then + if [[ ! $region ]]; thenerr "$LINENO"
fi
"$CXL" enable-region "$region"test/cxl-destroy-region.sh +0
-0@@ -38,7 +38,7 @@ check_destroy_devdax()decoder=$2
region="$("$CXL" create-region -d "$decoder" -m "$mem" | jq -r ".region")"
test/cxl-destroy-region.sh
Quoted 2 lines
test/cxl-destroy-region.sh +1
-1- if [ "$region" == "null" ]; then + if [[ ! $region ]]; then
While these ! $region changes are correct (because cxl create-region) doesn't output any json if creation fails)..
Quoted 9 lines
err "$LINENO"
fi
"$CXL" enable-region "$region"test/cxl-destroy-region.sh +0
-0@@ -55,14 +55,14 @@ check_destroy_devdax() readarray -t mems < <("$CXL" list -b "$CXL_TEST_BUS" -M | jq -r '.[].memdev')for mem in "${mems[@]}"; do
ramsize="$("$CXL" list -m "$mem" | jq -r '.[].ram_size')" - if [[ $ramsize == "null" ]]; then
+ if [[ ! $ramsize ]]; then
.. I think this check needs to check for both empty and "null" - a memdev that doesn't have ram_size but otherwise emits valid json will result in "null" here. e.g.:
$ echo "" | jq -r ".region"
$ echo "{ }" | jq -r ".region"
nullSo this probably wants to be:
if [[ $ramsize == "null" || ! $ram_size ]]; then ...
Quoted 13 lines
continue
fi
decoder="$("$CXL" list -b "$CXL_TEST_BUS" -D -d root -m "$mem" | jq -r ".[] |
select(.volatile_capable == true)|select(.nr_targets == 1)|
- select(.size >= ${ramsize}) |
+select(.max_available_extent >= ${ramsize})| .decoder")"
if [[ $decoder ]]; then
check_destroy_ram"$mem" "$decoder"base-commit:
e0d0680bd3e554bd5f211e989480c5a13a023b2d
Alison Schofield
maintainerQuoted 61 lines · Vishal Verma
Quoted 35 lines · On Wed, 2024-03-27 at 11:46 -0700, [email protected] wrote:
From: Alison Schofield <[email protected]>
Using .size in decoder selection can lead to a
set_sizefailure with these error messages:cxl region:
create_region: region8:set_sizefailed: Numerical result out of range[] cxl_core:alloc_hpa:555: cxl region8: HPA allocation error (-34) for size:0x0000000020000000 in CXL Window 0 [mem 0xf010000000-0xf04fffffff flags
0x200]Use
max_available_extentfor decoder selection instead.The test overlooked the region creation failure because it used a not 'null' comparison which always succeeds. Use the ! comparator after create-region and for the ramsize check so that the test fails or continues as expected.
Signed-off-by Alison Schofield <[email protected]>--- test/cxl-destroy-region.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)test/cxl-destroy-region.sh +1
-1@@ -22,7 +22,7 @@ check_destroy_ram() decoder=$2 region="$("$CXL" create-region -d "$decoder" -m "$mem" | jq -r ".region")" - if [ "$region" == "null" ]; then + if [[ ! $region ]]; then err "$LINENO" fi "$CXL" enable-region "$region"test/cxl-destroy-region.sh check_destroy_devdax() · line 41
Quoted 5 lines
test/cxl-destroy-region.sh +1
-1@@ -38,7 +38,7 @@ check_destroy_devdax() decoder=$2 region="$("$CXL" create-region -d "$decoder" -m "$mem" | jq -r ".region")" - if [ "$region" == "null" ]; then + if [[ ! $region ]]; thenWhile these ! $region changes are correct (because cxl create-region) doesn't output any json if creation fails)..
test/cxl-destroy-region.sh check_destroy_devdax() · line 58
Quoted 9 lines
test/cxl-destroy-region.sh +1
-1err "$LINENO" fi "$CXL" enable-region "$region"@@ -55,14 +55,14 @@ check_destroy_devdax() readarray -t mems < <("$CXL" list -b "$CXL_TEST_BUS" -M | jq -r '.[].memdev') for mem in "${mems[@]}"; do ramsize="$("$CXL" list -m "$mem" | jq -r '.[].ram_size')" - if [[ $ramsize == "null" ]]; then + if [[ ! $ramsize ]]; then.. I think this check needs to check for both empty and "null" - a memdev that doesn't have
ram_sizebut otherwise emits valid json will result in "null" here. e.g.:$ echo "" | jq -r ".region"
Quoted 8 lines
$ echo "{ }" | jq -r ".region" nullSo this probably wants to be:
if [[ $ramsize == "null" || ! $ram_size ]]; then ...
I see now! Thanks Vishal.
-- Alison