Skip to contentSkip to conversation

Use CXL regions in daxctl-create unit test

PATCH In review [email protected] 3 participants 7 messages Aug 28, 2024 – Sep 4, 2024 libnvdimm: non-volatile memory device

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover Use CXL regions in daxctl-create unit test

From: Alison Schofield <[email protected]>

efi_fake_mem support was removed from the kernel in v6.11 making this unit test SKIP, unable to find the hmem regions that relied upon the fake devices.

Pivoting to use the already available CXL regions seems like a good fit. The setup changes but the same DAX test functionality remains unchanged.

Please take a look.

Alison Schofield (2):
test/daxctl-create.sh: use bash math syntax to find available size test/daxctl-create.sh: use CXL DAX regions instead of efi_fake_mem

 test/daxctl-create.sh | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.37.3
author maintainer
#1 lore raw

PATCH 1/2 test/daxctl-create.sh: use bash math syntax to find available size

From: Alison Schofield <[email protected]>

The check for 1GB of available space in a DAX region always returned true due to being wrapped inside a [[ ... ]] test, even when space wasn't available. That caused set size to fail.

Update to use bash arithmetic evaluation instead.

This issue likely went unnoticed because users allocated >= 1GB of efi_fake_mem. This fix is part of the transition to use CXL regions in this test as efi_fake_mem support is being removed from the kernel.

---
 test/daxctl-create.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/daxctl-create.sh +1 -1
index c093cb9e306a..d968e7bedd82 100755
@@ -363,7 +363,7 @@ daxctl_test6()
 
 	# Use 2M by default or 1G if supported
 	align=2097152
-	if [[ $((available >= 1073741824 )) ]]; then
+	if (( available >= 1073741824 )); then
 		align=1073741824
 		size=$align
 	fi
Signature · 1 line
2.37.3
author maintainer
#3 lore raw

PATCH 2/2 test/daxctl-create.sh: use CXL DAX regions instead of efi_fake_mem

In reply to [email protected]

From: Alison Schofield <[email protected]>

This test tries to use DAX regions created from efi_fake_mem devices. A recent kernel change removed efi_fake_mem support causing this test to SKIP because no DAX regions can be found.

Alas, a new source of DAX regions is available: CXL. Use that now. Other than selecting a different region provider, the functionality of the test remains the same.

---
 test/daxctl-create.sh | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
test/daxctl-create.sh +7 -11
index d968e7bedd82..1ef70f2ff186 100755
@@ -7,6 +7,9 @@ rc=77
 
 trap 'cleanup $LINENO' ERR
 
+modprobe -r cxl_test
+modprobe cxl_test
+
 cleanup()
 {
 	printf "Error at line %d\n" "$1"
@@ -18,18 +21,10 @@ find_testdev()
 {
 	local rc=77
 
-	# The hmem driver is needed to change the device mode, only
-	# kernels >= v5.6 might have it available. Skip if not.
-	if ! modinfo dax_hmem; then
-		# check if dax_hmem is builtin
-		if [ ! -d "/sys/module/device_hmem" ]; then
-			printf "Unable to find hmem module\n"
-			exit $rc
-		fi
-	fi
+	# find a victim region provided by cxl_test
+	bus="$("$CXL" list -b "$CXL_TEST_BUS" | jq -r '.[] | .bus')"
+	region_id="$("$DAXCTL" list -R | jq -r ".[] | select(.path | contains(\"$bus\")) | .id")"
 
-	# find a victim region provided by dax_hmem
-	region_id="$("$DAXCTL" list -R | jq -r '.[] | select(.path | contains("hmem")) | .id')"
 	if [[ ! "$region_id" ]]; then
 		printf "Unable to find a victim region\n"
 		exit "$rc"
@@ -413,4 +408,5 @@ daxctl_test5
 daxctl_test6
 daxctl_test7
 reset_dev
+modprobe -r cxl_test
 exit 0
Signature · 1 line
2.37.3
Reviewed-by on v1 2/2
#4 lore raw

Re: [ndctl PATCH 2/2] test/daxctl-create.sh: use CXL DAX regions instead of efi_fake_mem

Quoted 9 lines · alison.schofield@ wrote:

From: Alison Schofield <[email protected]>

This test tries to use DAX regions created from efi_fake_mem devices. A recent kernel change removed efi_fake_mem support causing this test to SKIP because no DAX regions can be found.

Alas, a new source of DAX regions is available: CXL. Use that now. Other than selecting a different region provider, the functionality of the test remains the same.

CXL looks like a useful replacement.

Quoted 25 lines
---
 test/daxctl-create.sh | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
test/daxctl-create.sh +3 -2
index d968e7bedd82..1ef70f2ff186 100755
@@ -7,6 +7,9 @@ rc=77
 
 trap 'cleanup $LINENO' ERR
 
+modprobe -r cxl_test
+modprobe cxl_test
+
 cleanup()
 {
 	printf "Error at line %d\n" "$1"
@@ -18,18 +21,10 @@ find_testdev()
 {
 	local rc=77
 
-	# The hmem driver is needed to change the device mode, only
-	# kernels >= v5.6 might have it available. Skip if not.

test/daxctl-create.sh find_testdev() · line 26

Quoted 10 lines
test/daxctl-create.sh +3 -7
-	if ! modinfo dax_hmem; then
-		# check if dax_hmem is builtin
-		if [ ! -d "/sys/module/device_hmem" ]; then
-			printf "Unable to find hmem module\n"
-			exit $rc
-		fi
-	fi
+	# find a victim region provided by cxl_test
+	bus="$("$CXL" list -b "$CXL_TEST_BUS" | jq -r '.[] | .bus')"
+	region_id="$("$DAXCTL" list -R | jq -r ".[] | select(.path | contains(\"$bus\")) | .id")"

Might as well skip using cxl-list and instead use the known platform device hosting the cxl_test CXL topology: "cxl_acpi.0"

    region_id="$("$DAXCTL" list -R | jq -r ".[] | select(.path | contains(\"cxl_acpi.0\")) | .id")"

...other than that you can add:

author maintainer
#5 lore raw

Re: [ndctl PATCH 2/2] test/daxctl-create.sh: use CXL DAX regions instead of efi_fake_mem

Quoted 52 lines · Dan Williams
Quoted 9 lines · alison.schofield@ wrote:

From: Alison Schofield <[email protected]>

This test tries to use DAX regions created from efi_fake_mem devices. A recent kernel change removed efi_fake_mem support causing this test to SKIP because no DAX regions can be found.

Alas, a new source of DAX regions is available: CXL. Use that now. Other than selecting a different region provider, the functionality of the test remains the same.

CXL looks like a useful replacement.

Quoted 25 lines
---
 test/daxctl-create.sh | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
test/daxctl-create.sh +3 -2
index d968e7bedd82..1ef70f2ff186 100755
@@ -7,6 +7,9 @@ rc=77
 
 trap 'cleanup $LINENO' ERR
 
+modprobe -r cxl_test
+modprobe cxl_test
+
 cleanup()
 {
 	printf "Error at line %d\n" "$1"
@@ -18,18 +21,10 @@ find_testdev()
 {
 	local rc=77
 
-	# The hmem driver is needed to change the device mode, only
-	# kernels >= v5.6 might have it available. Skip if not.

test/daxctl-create.sh find_testdev() · line 26

Quoted 10 lines
test/daxctl-create.sh +3 -7
-	if ! modinfo dax_hmem; then
-		# check if dax_hmem is builtin
-		if [ ! -d "/sys/module/device_hmem" ]; then
-			printf "Unable to find hmem module\n"
-			exit $rc
-		fi
-	fi
+	# find a victim region provided by cxl_test
+	bus="$("$CXL" list -b "$CXL_TEST_BUS" | jq -r '.[] | .bus')"
+	region_id="$("$DAXCTL" list -R | jq -r ".[] | select(.path | contains(\"$bus\")) | .id")"

Might as well skip using cxl-list and instead use the known platform device hosting the cxl_test CXL topology: "cxl_acpi.0"

Quoted 1 line
    region_id="$("$DAXCTL" list -R | jq -r ".[] | select(.path | contains(\"cxl_acpi.0\")) | .id")"

Will do. Thanks for the review!

Quoted 4 lines

...other than that you can add:

maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [ndctl PATCH 1/2] test/daxctl-create.sh: use bash math syntax to find available size

In reply to [email protected]
Quoted 26 lines · On Tue, 2024-08-27 at 20:14 -0700, [email protected] wrote:

From: Alison Schofield <[email protected]>

The check for 1GB of available space in a DAX region always returned true due to being wrapped inside a [[ ... ]] test, even when space wasn't available. That caused set size to fail.

Update to use bash arithmetic evaluation instead.

This issue likely went unnoticed because users allocated >= 1GB of efi_fake_mem. This fix is part of the transition to use CXL regions in this test as efi_fake_mem support is being removed from the kernel.

---
 test/daxctl-create.sh | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
test/daxctl-create.sh +0 -0
index c093cb9e306a..d968e7bedd82 100755
@@ -363,7 +363,7 @@ daxctl_test6()


  # Use 2M by default or 1G if supported
  align=2097152

test/daxctl-create.sh daxctl_test6() · line 366

Quoted 2 lines
test/daxctl-create.sh +1 -1
-	if [[ $((available >= 1073741824 )) ]]; then
+	if (( available >= 1073741824 )); then

Yikes, good find!

Quoted 3 lines

  align=1073741824
  size=$align
  fi

maintainer Reviewed-by on v1 2/2
#6 lore raw

Re: [ndctl PATCH 2/2] test/daxctl-create.sh: use CXL DAX regions instead of efi_fake_mem

In reply to [email protected]
Quoted 11 lines · On Tue, 2024-08-27 at 20:14 -0700, [email protected] wrote:

From: Alison Schofield <[email protected]>

This test tries to use DAX regions created from efi_fake_mem devices. A recent kernel change removed efi_fake_mem support causing this test to SKIP because no DAX regions can be found.

Alas, a new source of DAX regions is available: CXL. Use that now. Other than selecting a different region provider, the functionality of the test remains the same.

Looks good,

Quoted 48 lines

---
 test/daxctl-create.sh | 18 +++++++-----------

 1 file changed, 7 insertions(+), 11 deletions(-)
test/daxctl-create.sh +0 -0
index d968e7bedd82..1ef70f2ff186 100755
@@ -7,6 +7,9 @@ rc=77


 trap 'cleanup $LINENO' ERR

test/daxctl-create.sh +3 -0
+modprobe -r cxl_test
+modprobe cxl_test
+

 cleanup()
 {
  printf "Error at line %d\n" "$1"

test/daxctl-create.sh +0 -0
@@ -18,18 +21,10 @@ find_testdev()
  {

  local rc=77

test/daxctl-create.sh +3 -9
-	# The hmem driver is needed to change the device mode, only
-	# kernels >= v5.6 might have it available. Skip if not.
-	if ! modinfo dax_hmem; then
-		# check if dax_hmem is builtin
-		if [ ! -d "/sys/module/device_hmem" ]; then
-			printf "Unable to find hmem module\n"
-			exit $rc
-		fi
-	fi
+	# find a victim region provided by cxl_test
+	bus="$("$CXL" list -b "$CXL_TEST_BUS" | jq -r '.[] | .bus')"
+	region_id="$("$DAXCTL" list -R | jq -r ".[] | select(.path |

contains(\"$bus\")) | .id")"

test/daxctl-create.sh +0 -2
-	# find a victim region provided by dax_hmem
-	region_id="$("$DAXCTL" list -R | jq -r '.[] | select(.path |

contains("hmem")) | .id')"
  if [[ ! "$region_id" ]]; then
  printf "Unable to find a victim region\n" exit "$rc"

test/daxctl-create.sh +0 -0
@@ -413,4 +408,5 @@ daxctl_test5

 daxctl_test6
 daxctl_test7
 reset_dev
+modprobe -r cxl_test
 exit 0