* [ndctl PATCH] cxl/test: Use interleave arithmetic to sort memdevs for a region
@ 2022-08-24 23:09 alison.schofield
2022-08-24 23:28 ` Verma, Vishal L
0 siblings, 1 reply; 2+ messages in thread
From: alison.schofield @ 2022-08-24 23:09 UTC (permalink / raw)
To: Vishal Verma, Dan Williams; +Cc: Alison Schofield, nvdimm, linux-cxl
From: Alison Schofield <alison.schofield@intel.com>
Test cxl-region-sysfs.sh assumes Modulo arithmetic. XOR arithmetic
is being introduced and requires a different ordering of the memdevs
in the region.
Update the test to sort the memdevs based on interleave arithmetic.
If the interleave arithmetic attribute for the root decoder is not
visible in sysfs, driver support for XOR math is not present. Default
to Modulo sorting order.
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
test/cxl-region-sysfs.sh | 44 ++++++++++++++++++++++++++++++++--------
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh
index ae0f55653814..1af0ae7e632c 100644
--- a/test/cxl-region-sysfs.sh
+++ b/test/cxl-region-sysfs.sh
@@ -58,15 +58,43 @@ readarray -t mem_sort1 < <($CXL list -M -p $port_dev1 | jq -r ".[] | .memdev")
# TODO: add a cxl list option to list memdevs in valid region provisioning
# order, hardcode for now.
+
+# Sort based on root decoder interleave arithmetic.
+# Default to Modulo if the sysfs attribute is not emitted.
+if [ ! -e /sys/bus/cxl/devices/$decoder/interleave_arithmetic ]; then
+ ia="0"
+else
+ ia=$(cat /sys/bus/cxl/devices/$decoder/interleave_arithmetic)
+fi
+
mem_sort=()
-mem_sort[0]=${mem_sort0[0]}
-mem_sort[1]=${mem_sort1[0]}
-mem_sort[2]=${mem_sort0[2]}
-mem_sort[3]=${mem_sort1[2]}
-mem_sort[4]=${mem_sort0[1]}
-mem_sort[5]=${mem_sort1[1]}
-mem_sort[6]=${mem_sort0[3]}
-mem_sort[7]=${mem_sort1[3]}
+if [ $ia == "0" ]; then
+ # Modulo Arithmetic
+ mem_sort[0]=${mem_sort0[0]}
+ mem_sort[1]=${mem_sort1[0]}
+ mem_sort[2]=${mem_sort0[2]}
+ mem_sort[3]=${mem_sort1[2]}
+ mem_sort[4]=${mem_sort0[1]}
+ mem_sort[5]=${mem_sort1[1]}
+ mem_sort[6]=${mem_sort0[3]}
+ mem_sort[7]=${mem_sort1[3]}
+
+elif [ $ia == "1" ]; then
+ # XOR Arithmetic
+ mem_sort[0]=${mem_sort1[0]}
+ mem_sort[1]=${mem_sort0[0]}
+ mem_sort[2]=${mem_sort1[2]}
+ mem_sort[3]=${mem_sort0[2]}
+ mem_sort[4]=${mem_sort1[1]}
+ mem_sort[5]=${mem_sort0[1]}
+ mem_sort[6]=${mem_sort1[3]}
+ mem_sort[7]=${mem_sort0[3]}
+else
+ # Unknown Arithmetic
+ echo "Unknown interleave arithmetic: $ia for $decoder"
+ modprobe -r cxl-test
+ exit 1
+fi
# TODO: use this alternative memdev ordering to validate a negative test for
# specifying invalid positions of memdevs
base-commit: c9c9db39354ea0c3f737378186318e9b7908e3a7
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [ndctl PATCH] cxl/test: Use interleave arithmetic to sort memdevs for a region
2022-08-24 23:09 [ndctl PATCH] cxl/test: Use interleave arithmetic to sort memdevs for a region alison.schofield
@ 2022-08-24 23:28 ` Verma, Vishal L
0 siblings, 0 replies; 2+ messages in thread
From: Verma, Vishal L @ 2022-08-24 23:28 UTC (permalink / raw)
To: Williams, Dan J, Schofield, Alison
Cc: linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev
On Wed, 2022-08-24 at 16:09 -0700, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> Test cxl-region-sysfs.sh assumes Modulo arithmetic. XOR arithmetic
> is being introduced and requires a different ordering of the memdevs
> in the region.
Instead of 'is being introduced', maybe something like:
"In preparation for introduction of XOR arithmetic, allow for a
different ordering of memdevs in the region."
>
> Update the test to sort the memdevs based on interleave arithmetic.
..and then this sentence can be dropped.
> If the interleave arithmetic attribute for the root decoder is not
> visible in sysfs, driver support for XOR math is not present. Default
> to Modulo sorting order.
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
> test/cxl-region-sysfs.sh | 44 ++++++++++++++++++++++++++++++++--------
> 1 file changed, 36 insertions(+), 8 deletions(-)
>
> diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh
> index ae0f55653814..1af0ae7e632c 100644
> --- a/test/cxl-region-sysfs.sh
> +++ b/test/cxl-region-sysfs.sh
> @@ -58,15 +58,43 @@ readarray -t mem_sort1 < <($CXL list -M -p $port_dev1 | jq -r ".[] | .memdev")
>
> # TODO: add a cxl list option to list memdevs in valid region provisioning
> # order, hardcode for now.
> +
> +# Sort based on root decoder interleave arithmetic.
> +# Default to Modulo if the sysfs attribute is not emitted.
> +if [ ! -e /sys/bus/cxl/devices/$decoder/interleave_arithmetic ]; then
> + ia="0"
> +else
> + ia=$(cat /sys/bus/cxl/devices/$decoder/interleave_arithmetic)
> +fi
> +
> mem_sort=()
> -mem_sort[0]=${mem_sort0[0]}
> -mem_sort[1]=${mem_sort1[0]}
> -mem_sort[2]=${mem_sort0[2]}
> -mem_sort[3]=${mem_sort1[2]}
> -mem_sort[4]=${mem_sort0[1]}
> -mem_sort[5]=${mem_sort1[1]}
> -mem_sort[6]=${mem_sort0[3]}
> -mem_sort[7]=${mem_sort1[3]}
> +if [ $ia == "0" ]; then
If using '==' this should use the 'if [[' bash-style check, otherwise
with a single '[', the test should use '-eq' (and quote the variable in
this case).
i.e. either
if [[ $ia == "0" ]]; then ...
or
if [ "$ia" -eq "0" ]; then ...
We have bash assumptions (i.e. not restricted to posix sh) everywhere
already, so the first one is preferable.
> + # Modulo Arithmetic
> + mem_sort[0]=${mem_sort0[0]}
> + mem_sort[1]=${mem_sort1[0]}
> + mem_sort[2]=${mem_sort0[2]}
> + mem_sort[3]=${mem_sort1[2]}
> + mem_sort[4]=${mem_sort0[1]}
> + mem_sort[5]=${mem_sort1[1]}
> + mem_sort[6]=${mem_sort0[3]}
> + mem_sort[7]=${mem_sort1[3]}
> +
> +elif [ $ia == "1" ]; then
same here as above.
> + # XOR Arithmetic
> + mem_sort[0]=${mem_sort1[0]}
> + mem_sort[1]=${mem_sort0[0]}
> + mem_sort[2]=${mem_sort1[2]}
> + mem_sort[3]=${mem_sort0[2]}
> + mem_sort[4]=${mem_sort1[1]}
> + mem_sort[5]=${mem_sort0[1]}
> + mem_sort[6]=${mem_sort1[3]}
> + mem_sort[7]=${mem_sort0[3]}
> +else
> + # Unknown Arithmetic
> + echo "Unknown interleave arithmetic: $ia for $decoder"
> + modprobe -r cxl-test
> + exit 1
This should use the 'err "$LINENO: other-stuff"' pattern rather than
echo + exit.
> +fi
>
> # TODO: use this alternative memdev ordering to validate a negative test for
> # specifying invalid positions of memdevs
>
> base-commit: c9c9db39354ea0c3f737378186318e9b7908e3a7
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-24 23:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24 23:09 [ndctl PATCH] cxl/test: Use interleave arithmetic to sort memdevs for a region alison.schofield
2022-08-24 23:28 ` Verma, Vishal L
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox