Skip to contentSkip to conversation

test/cxl-poison.sh: test scanning past fully mapped partitions

PATCH In review Alison Schofield 2 participants 4 messages Jul 1 – Aug 31 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Alison Schofield

author maintainer
#0 lore raw

PATCH 1/1 test/cxl-poison.sh: test scanning past fully mapped partitions

Listing poison by memdev scans the unmapped tail of every partition. When an earlier partition is fully mapped, its tail is zero length, but the scan must continue to later partitions. A regression caused the scan to stop at the first fully-mapped partition, leaving later partitions unscanned.

Backstop that behavior with a test case that fully maps a memdev's RAM partition so its unmapped tail is zero length, then injects poison into the unmapped PMEM partition that follows. The PMEM poison is only reported if the scan continues past the fully-mapped RAM partition.

---
 test/cxl-poison.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
test/cxl-poison.sh +40 -0
index 49aa1b68c5c1..a03e08084eb4 100644
@@ -219,6 +219,45 @@ test_poison_by_region_offset_negative()
 	clear_poison "$region" "$large_offset" true
 }
 
+# Backstop a driver fix where a fully mapped partition prematurely
+# terminated the unmapped poison scan.
+test_poison_unmapped_later_partition()
+{
+	local decoder ram_size pmem_dpa
+
+	check_min_kver "7.3" || return 0
+
+	# Free the auto region to use the ram capacity
+	$CXL destroy-region -f -b "$CXL_TEST_BUS" all
+
+	find_memdev
+
+	# Fully map the ram partition so it has a zero-length unmapped tail
+	decoder=$($CXL list -b "$CXL_TEST_BUS" -D -d root -m "$memdev" |
+		  jq -r ".[] |
+		  select(.volatile_capable == true) |
+		  select(.nr_targets == 1) |
+		  .decoder")
+	[[ -n "$decoder" && "$decoder" != "null" ]] ||
+		do_skip "no x1 volatile decoder found"
+
+	ram_size=$($CXL list -m "$memdev" | jq -r ".[0].ram_size")
+	[[ -n "$ram_size" && "$ram_size" != "null" ]] || err "$LINENO"
+
+	region=$($CXL create-region -t ram -d "$decoder" -m "$memdev" \
+		 -s "$ram_size" | jq -r ".region")
+	[[ -n "$region" && "$region" != "null" ]] || err "$LINENO"
+
+	# Poison the unmapped pmem tail
+	pmem_dpa=$ram_size
+	inject_poison "$memdev" "$pmem_dpa"
+	validate_poison_found "-m $memdev" 1
+	clear_poison "$memdev" "$pmem_dpa"
+	validate_poison_found "-m $memdev" 0
+
+	$CXL destroy-region -f -b "$CXL_TEST_BUS" "$region"
+}
+
 is_unaligned() {
 	local region=$1
 	local hbiw=$2
@@ -332,6 +371,7 @@ run_poison_test()
 		do_skip "test cases requires inject by region kernel support"
 	test_poison_by_region_offset
 	test_poison_by_region_offset_negative
+	test_poison_unmapped_later_partition
 }
 
 modprobe -r cxl_test

base-commit: 15e932c4e1318a9608ad9b799ad83a32a8b5970d

Signature · 1 line
2.37.3
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alison Schofield

Listing poison by memdev scans the unmapped tail of every partition. When an earlier partition is fully mapped, its tail is zero length, but the scan must continue to later partitions. A regression caused the scan to stop at the first fully-mapped partition, leaving later partitions unscanned.

Backstop that behavior with a test case that fully maps a memdev's RAM partition so its unmapped tail is zero length, then injects poison into the unmapped PMEM partition that follows. The PMEM poison is only reported if the scan continues past the fully-mapped RAM partition.

Hi Alison,

Thanks for this ! I ran it against cxl_test in the following ways.

On a kernel with the fix [1], the test passes in both run_poison_test passes:
1 poison record found after inject at the first pmem DPA, 0 after clear.

On a kernel without the fix, it fails exactly at the "1 poison records expected, 0 found" assertion, so it catches the regression as intended.

Just one small thing below.

Quoted 10 lines
---
 test/cxl-poison.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
test/cxl-poison.sh +0 -0
index 49aa1b68c5c1..a03e08084eb4 100644

test/cxl-poison.sh test_poison_by_region_offset_negative() · line 227

Quoted 9 lines
test/cxl-poison.sh +6 -0
@@ -219,6 +219,45 @@ test_poison_by_region_offset_negative()
 	clear_poison "$region" "$large_offset" true
 }
 
+# Backstop a driver fix where a fully mapped partition prematurely
+# terminated the unmapped poison scan.
+test_poison_unmapped_later_partition()
+{
+	local decoder ram_size pmem_dpa
+

"region" is assigned below but not declared local like the others. Does it have any reason for it to not be local var?
It might be harmless today but tests added after this one will inherit a stale global region, if it ever uses one.

[1]:
https://lore.kernel.org/linux-cxl/[email protected]/

Best regards,
Richard Cheng.

Quoted 49 lines
test/cxl-poison.sh +34 -0
+	check_min_kver "7.3" || return 0
+
+	# Free the auto region to use the ram capacity
+	$CXL destroy-region -f -b "$CXL_TEST_BUS" all
+
+	find_memdev
+
+	# Fully map the ram partition so it has a zero-length unmapped tail
+	decoder=$($CXL list -b "$CXL_TEST_BUS" -D -d root -m "$memdev" |
+		  jq -r ".[] |
+		  select(.volatile_capable == true) |
+		  select(.nr_targets == 1) |
+		  .decoder")
+	[[ -n "$decoder" && "$decoder" != "null" ]] ||
+		do_skip "no x1 volatile decoder found"
+
+	ram_size=$($CXL list -m "$memdev" | jq -r ".[0].ram_size")
+	[[ -n "$ram_size" && "$ram_size" != "null" ]] || err "$LINENO"
+
+	region=$($CXL create-region -t ram -d "$decoder" -m "$memdev" \
+		 -s "$ram_size" | jq -r ".region")
+	[[ -n "$region" && "$region" != "null" ]] || err "$LINENO"
+
+	# Poison the unmapped pmem tail
+	pmem_dpa=$ram_size
+	inject_poison "$memdev" "$pmem_dpa"
+	validate_poison_found "-m $memdev" 1
+	clear_poison "$memdev" "$pmem_dpa"
+	validate_poison_found "-m $memdev" 0
+
+	$CXL destroy-region -f -b "$CXL_TEST_BUS" "$region"
+}
+
 is_unaligned() {
 	local region=$1
 	local hbiw=$2
@@ -332,6 +371,7 @@ run_poison_test()
 		do_skip "test cases requires inject by region kernel support"
 	test_poison_by_region_offset
 	test_poison_by_region_offset_negative
+	test_poison_unmapped_later_partition
 }
 
 modprobe -r cxl_test

base-commit: 15e932c4e1318a9608ad9b799ad83a32a8b5970d

Signature · 1 line
2.37.3
author maintainer Applied
#2 lore raw
Quoted 51 lines · Richard Cheng
Quoted 11 lines · Alison Schofield

Listing poison by memdev scans the unmapped tail of every partition. When an earlier partition is fully mapped, its tail is zero length, but the scan must continue to later partitions. A regression caused the scan to stop at the first fully-mapped partition, leaving later partitions unscanned.

Backstop that behavior with a test case that fully maps a memdev's RAM partition so its unmapped tail is zero length, then injects poison into the unmapped PMEM partition that follows. The PMEM poison is only reported if the scan continues past the fully-mapped RAM partition.

Hi Alison,

Thanks for this ! I ran it against cxl_test in the following ways.

On a kernel with the fix [1], the test passes in both run_poison_test passes:
1 poison record found after inject at the first pmem DPA, 0 after clear.

On a kernel without the fix, it fails exactly at the "1 poison records expected, 0 found" assertion, so it catches the regression as intended.

Just one small thing below.

Quoted 10 lines
---
 test/cxl-poison.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
test/cxl-poison.sh +0 -0
index 49aa1b68c5c1..a03e08084eb4 100644

test/cxl-poison.sh test_poison_by_region_offset_negative() · line 227

Quoted 9 lines
test/cxl-poison.sh +6 -0
@@ -219,6 +219,45 @@ test_poison_by_region_offset_negative()
 	clear_poison "$region" "$large_offset" true
 }
 
+# Backstop a driver fix where a fully mapped partition prematurely
+# terminated the unmapped poison scan.
+test_poison_unmapped_later_partition()
+{
+	local decoder ram_size pmem_dpa
+

"region" is assigned below but not declared local like the others. Does it have any reason for it to not be local var?
It might be harmless today but tests added after this one will inherit a stale global region, if it ever uses one.

Quoted 2 lines

Thanks!

I made region a local per your suggestion.

Applied to pending for NDCTL v86
https://github.com/pmem/ndctl/commits/pending/

author maintainer
#3 lore raw
In reply to Alison Schofield
Quoted 21 lines · Alison Schofield

Listing poison by memdev scans the unmapped tail of every partition. When an earlier partition is fully mapped, its tail is zero length, but the scan must continue to later partitions. A regression caused the scan to stop at the first fully-mapped partition, leaving later partitions unscanned.

Backstop that behavior with a test case that fully maps a memdev's RAM partition so its unmapped tail is zero length, then injects poison into the unmapped PMEM partition that follows. The PMEM poison is only reported if the scan continues past the fully-mapped RAM partition.

---
 test/cxl-poison.sh | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
test/cxl-poison.sh +0 -0
index 49aa1b68c5c1..a03e08084eb4 100644

test/cxl-poison.sh test_poison_by_region_offset_negative() · line 228

Quoted 10 lines
test/cxl-poison.sh +7 -0
@@ -219,6 +219,45 @@ test_poison_by_region_offset_negative()
 	clear_poison "$region" "$large_offset" true
 }
 
+# Backstop a driver fix where a fully mapped partition prematurely
+# terminated the unmapped poison scan.
+test_poison_unmapped_later_partition()
+{
+	local decoder ram_size pmem_dpa
+
+	check_min_kver "7.3" || return 0

DaveJ found this failing in 7.3-rc1.

It turns out the kernel fixup for this testcase is not yet merged. I have just pushed a new ndctl pending branch with this changed to 7.4.

The kernel fixup is in this patchset from RichardC:
https://lore.kernel.org/linux-cxl/[email protected]/

There is no issue with the patch, it's just bad luck that it is stuck in a Sashiko set of cleanups.

-- Alison

Quoted 48 lines
test/cxl-poison.sh +33 -0
+
+	# Free the auto region to use the ram capacity
+	$CXL destroy-region -f -b "$CXL_TEST_BUS" all
+
+	find_memdev
+
+	# Fully map the ram partition so it has a zero-length unmapped tail
+	decoder=$($CXL list -b "$CXL_TEST_BUS" -D -d root -m "$memdev" |
+		  jq -r ".[] |
+		  select(.volatile_capable == true) |
+		  select(.nr_targets == 1) |
+		  .decoder")
+	[[ -n "$decoder" && "$decoder" != "null" ]] ||
+		do_skip "no x1 volatile decoder found"
+
+	ram_size=$($CXL list -m "$memdev" | jq -r ".[0].ram_size")
+	[[ -n "$ram_size" && "$ram_size" != "null" ]] || err "$LINENO"
+
+	region=$($CXL create-region -t ram -d "$decoder" -m "$memdev" \
+		 -s "$ram_size" | jq -r ".region")
+	[[ -n "$region" && "$region" != "null" ]] || err "$LINENO"
+
+	# Poison the unmapped pmem tail
+	pmem_dpa=$ram_size
+	inject_poison "$memdev" "$pmem_dpa"
+	validate_poison_found "-m $memdev" 1
+	clear_poison "$memdev" "$pmem_dpa"
+	validate_poison_found "-m $memdev" 0
+
+	$CXL destroy-region -f -b "$CXL_TEST_BUS" "$region"
+}
+
 is_unaligned() {
 	local region=$1
 	local hbiw=$2
@@ -332,6 +371,7 @@ run_poison_test()
 		do_skip "test cases requires inject by region kernel support"
 	test_poison_by_region_offset
 	test_poison_by_region_offset_negative
+	test_poison_unmapped_later_partition
 }
 
 modprobe -r cxl_test

base-commit: 15e932c4e1318a9608ad9b799ad83a32a8b5970d

Signature · 1 line
2.37.3