Skip to contentSkip to conversation

test/cxl-sanitize: avoid sanitize submit/wait race

PATCH In review Alison Schofield 2 participants 3 messages Apr 30 – May 12 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Alison Schofield

author maintainer
#0 lore raw

PATCH 1/1 test/cxl-sanitize: avoid sanitize submit/wait race

This test verifies that wait-sanitize blocks for the programmed timeout after issuing sanitize on an inactive memdev.

The sanitize request is issued in the background and wait-sanitize is called immediately after. In cxl_test, sanitize completes asynchronously via delayed work, and the sysfs write does not block. This creates a race where wait-sanitize may run before sanitize is observed and return immediately.

This test has been reliable since its introduction, but recently started failing consistently in one environment, suggesting a timing sensitivity. It fails here:

  ((SECONDS > start + 2)) || err $LINENO

Add a short delay after backgrounding the sanitize write to make sure that wait-sanitize can observe the in-progress operation.

A sysfs-based synchronization was considered, but no in-progress state is exposed to user space.

---
 test/cxl-sanitize.sh | 3 +++
 1 file changed, 3 insertions(+)
test/cxl-sanitize.sh +3 -0
index 9c161014ccb7..d1ed598f3663 100644
@@ -68,6 +68,9 @@ done
 set_timeout $inactive 3000
 start=$SECONDS
 echo 1 > /sys/bus/cxl/devices/${inactive}/security/sanitize &
+
+# Allow background sanitize to start before wait-sanitize can observe it
+sleep 1
 "$CXL" wait-sanitize $inactive || err $LINENO
 ((SECONDS > start + 2)) || err $LINENO
 
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Alison Schofield

This test verifies that wait-sanitize blocks for the programmed timeout after issuing sanitize on an inactive memdev.

The sanitize request is issued in the background and wait-sanitize is called immediately after. In cxl_test, sanitize completes asynchronously via delayed work, and the sysfs write does not block. This creates a race where wait-sanitize may run before sanitize is observed and return immediately.

This test has been reliable since its introduction, but recently started failing consistently in one environment, suggesting a timing sensitivity. It fails here:

  ((SECONDS > start + 2)) || err $LINENO
Quoted 7 lines

Add a short delay after backgrounding the sanitize write to make sure that wait-sanitize can observe the in-progress operation.

A sysfs-based synchronization was considered, but no in-progress state is exposed to user space.

Looks reasonable

Quoted 18 lines
---
 test/cxl-sanitize.sh | 3 +++
 1 file changed, 3 insertions(+)
test/cxl-sanitize.sh +3 -0
index 9c161014ccb7..d1ed598f3663 100644
@@ -68,6 +68,9 @@ done
 set_timeout $inactive 3000
 start=$SECONDS
 echo 1 > /sys/bus/cxl/devices/${inactive}/security/sanitize &
+
+# Allow background sanitize to start before wait-sanitize can observe it
+sleep 1
 "$CXL" wait-sanitize $inactive || err $LINENO
 ((SECONDS > start + 2)) || err $LINENO
 
author maintainer
#2 lore raw
Quoted 21 lines · Dave Jiang
Quoted 18 lines · Alison Schofield

This test verifies that wait-sanitize blocks for the programmed timeout after issuing sanitize on an inactive memdev.

The sanitize request is issued in the background and wait-sanitize is called immediately after. In cxl_test, sanitize completes asynchronously via delayed work, and the sysfs write does not block. This creates a race where wait-sanitize may run before sanitize is observed and return immediately.

This test has been reliable since its introduction, but recently started failing consistently in one environment, suggesting a timing sensitivity. It fails here:

  ((SECONDS > start + 2)) || err $LINENO

Add a short delay after backgrounding the sanitize write to make sure that wait-sanitize can observe the in-progress operation.

Quoted 8 lines
Quoted 4 lines

A sysfs-based synchronization was considered, but no in-progress state is exposed to user space.

Looks reasonable

Thanks!
Applied to: https://github.com/pmem/ndctl/tree/pending