Linux CXL
 help / color / mirror / Atom feed
* [ndctl PATCH] test/cxl-sanitize: avoid sanitize submit/wait race
@ 2026-04-30  2:18 Alison Schofield
  2026-04-30 16:31 ` Dave Jiang
  0 siblings, 1 reply; 3+ messages in thread
From: Alison Schofield @ 2026-04-30  2:18 UTC (permalink / raw)
  To: nvdimm, linux-cxl; +Cc: 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.

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

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 test/cxl-sanitize.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/cxl-sanitize.sh b/test/cxl-sanitize.sh
index 9c161014ccb7..d1ed598f3663 100644
--- a/test/cxl-sanitize.sh
+++ b/test/cxl-sanitize.sh
@@ -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
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-12  3:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30  2:18 [ndctl PATCH] test/cxl-sanitize: avoid sanitize submit/wait race Alison Schofield
2026-04-30 16:31 ` Dave Jiang
2026-05-12  3:32   ` Alison Schofield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox