test/cxl-dax-hmem.sh: validate dax_hmem vs CXL collisions
Alison Schofield
maintainerPATCH v2 1/1 test/cxl-dax-hmem.sh: validate dax_hmem vs CXL collisions
From: Dan Williams <[email protected]>
Use the new "cxl_test.hmem_test" and "cxl_test.fail_autoassemble" module options to implement a new cxl-dax-hmem.sh test. The test checks dax_hmem takeover of Soft Reserve ranges that collide with autoassembled CXL regions. It depends on the cxl_mock_mem driver to launch multiple async probes before the dax_hmem driver attaches.
[as: do_skip on missing params, explicit param usage, robust unload, check_dmesg, misc style]
---
Changes in v2:
- Add delay (cxl-list) between modprobe and dax lookup In testing sometimes a daxctl right after modprobe fails to find the devices.
test/cxl-dax-hmem.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++ test/meson.build | 2 ++ 2 files changed, 70 insertions(+) create mode 100755 test/cxl-dax-hmem.sh
test/cxl-dax-hmem.sh new file +68 -0
@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026 Intel Corporation + +. $(dirname $0)/common + +rc=77 + +set -ex + +trap 'err $LINENO' ERR + +check_prereq "jq" + +modinfo cxl_test | grep -q '^parm:.*hmem_test' || \ + do_skip "cxl_test hmem_test module param not available" + +modinfo cxl_test | grep -q '^parm:.*fail_autoassemble' || \ + do_skip "cxl_test fail_autoassemble module param not available" + +rc=1 + +unload() +{ + modprobe -r dax_cxl 2>/dev/null || true + modprobe -r dax_hmem 2>/dev/null || true + modprobe -r cxl_mock_mem 2>/dev/null || true + modprobe -r cxl_test 2>/dev/null || true +} + +find_dax_cxl() +{ + $DAXCTL list -R | jq -r \ + '.[] | select(.path | contains("cxl_acpi.0")) | .path' +} + +find_dax_hmem() +{ + $DAXCTL list -R | jq -r \ + '.[] | select(.path | contains("hmem_platform.1")) | .path' +} + +unload + +# Verify CXL autoassembly claims the Soft Reserve range before dax_hmem +modprobe cxl_mock_mem +modprobe cxl_test hmem_test=1 +$CXL list + +dax=$(find_dax_cxl) +[[ -z "$dax" ]] && err $LINENO +dax=$(find_dax_hmem) +[[ -n "$dax" ]] && err $LINENO + +unload + +# Verify dax_hmem claims the Soft Reserve range when CXL autoassembly fails +modprobe cxl_mock_mem +modprobe cxl_test hmem_test=1 fail_autoassemble=1 +$CXL list + +dax=$(find_dax_cxl) +[[ -n "$dax" ]] && err $LINENO +dax=$(find_dax_hmem) +[[ -z "$dax" ]] && err $LINENO + +unload +check_dmesg "$LINENO"
test/meson.build +2 -0
@@ -169,6 +169,7 @@ cxl_destroy_region = find_program('cxl-destroy-region.sh') cxl_qos_class = find_program('cxl-qos-class.sh') cxl_translate = find_program('cxl-translate.sh') cxl_elc = find_program('cxl-elc.sh') +cxl_dax_hmem = find_program('cxl-dax-hmem.sh') tests = [ [ 'libndctl', libndctl, 'ndctl' ],
@@ -203,6 +204,7 @@ tests = [ [ 'cxl-qos-class.sh', cxl_qos_class, 'cxl' ], [ 'cxl-translate.sh', cxl_translate, 'cxl' ], [ 'cxl-elc.sh', cxl_elc, 'cxl' ], + [ 'cxl-dax-hmem.sh', cxl_dax_hmem, 'cxl' ], ] if get_option('destructive').enabled()
Signature · 1 line
2.37.3
Quoted 8 lines · Alison Schofield
From: Dan Williams <[email protected]>
Use the new "cxl_test.hmem_test" and "cxl_test.fail_autoassemble" module options to implement a new
cxl-dax-hmem.shtest. The test checksdax_hmemtakeover of Soft Reserve ranges that collide with autoassembled CXL regions. It depends on thecxl_mock_memdriver to launch multiple async probes before thedax_hmemdriver attaches.
Quoted 5 lines
[as:
do_skipon missing params, explicit param usage, robust unload,check_dmesg, misc style]Signed-off-by Dan Williams <[email protected]>Tested-by Alison Schofield <[email protected]>
Quoted 106 lines
---
Changes in v2:
- Add delay (cxl-list) between modprobe and dax lookup In testing sometimes a daxctl right after modprobe fails to find the devices.test/cxl-dax-hmem.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++ test/meson.build | 2 ++ 2 files changed, 70 insertions(+) create mode 100755 test/cxl-dax-hmem.shtest/cxl-dax-hmem.sh new file +68
-0@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026 Intel Corporation + +. $(dirname $0)/common + +rc=77 + +set -ex + +trap 'err $LINENO' ERR + +check_prereq "jq" + +modinfo cxl_test | grep -q '^parm:.*hmem_test' || \ + do_skip "cxl_test hmem_test module param not available" + +modinfo cxl_test | grep -q '^parm:.*fail_autoassemble' || \ + do_skip "cxl_test fail_autoassemble module param not available" + +rc=1 + +unload() +{ + modprobe -r dax_cxl 2>/dev/null || true + modprobe -r dax_hmem 2>/dev/null || true + modprobe -r cxl_mock_mem 2>/dev/null || true + modprobe -r cxl_test 2>/dev/null || true +} + +find_dax_cxl() +{ + $DAXCTL list -R | jq -r \ + '.[] | select(.path | contains("cxl_acpi.0")) | .path' +} + +find_dax_hmem() +{ + $DAXCTL list -R | jq -r \ + '.[] | select(.path | contains("hmem_platform.1")) | .path' +} + +unload + +# Verify CXL autoassembly claims the Soft Reserve range before dax_hmem +modprobe cxl_mock_mem +modprobe cxl_test hmem_test=1 +$CXL list + +dax=$(find_dax_cxl) +[[ -z "$dax" ]] && err $LINENO +dax=$(find_dax_hmem) +[[ -n "$dax" ]] && err $LINENO + +unload + +# Verify dax_hmem claims the Soft Reserve range when CXL autoassembly fails +modprobe cxl_mock_mem +modprobe cxl_test hmem_test=1 fail_autoassemble=1 +$CXL list + +dax=$(find_dax_cxl) +[[ -n "$dax" ]] && err $LINENO +dax=$(find_dax_hmem) +[[ -z "$dax" ]] && err $LINENO + +unload +check_dmesg "$LINENO"test/meson.build +2
-0@@ -169,6 +169,7 @@ cxl_destroy_region = find_program('cxl-destroy-region.sh') cxl_qos_class = find_program('cxl-qos-class.sh') cxl_translate = find_program('cxl-translate.sh') cxl_elc = find_program('cxl-elc.sh') +cxl_dax_hmem = find_program('cxl-dax-hmem.sh') tests = [ [ 'libndctl', libndctl, 'ndctl' ],@@ -203,6 +204,7 @@ tests = [ [ 'cxl-qos-class.sh', cxl_qos_class, 'cxl' ], [ 'cxl-translate.sh', cxl_translate, 'cxl' ], [ 'cxl-elc.sh', cxl_elc, 'cxl' ], + [ 'cxl-dax-hmem.sh', cxl_dax_hmem, 'cxl' ], ] if get_option('destructive').enabled()
Quoted 11 lines · Dave Jiang
Quoted 8 lines · Alison Schofield
From: Dan Williams <[email protected]>
Use the new "cxl_test.hmem_test" and "cxl_test.fail_autoassemble" module options to implement a new
cxl-dax-hmem.shtest. The test checksdax_hmemtakeover of Soft Reserve ranges that collide with autoassembled CXL regions. It depends on thecxl_mock_memdriver to launch multiple async probes before thedax_hmemdriver attaches.
Quoted 7 lines
Quoted 5 lines
[as:
do_skipon missing params, explicit param usage, robust unload,check_dmesg, misc style]Signed-off-by Dan Williams <[email protected]>Tested-by Alison Schofield <[email protected]>Reviewed-by Dave Jiang <[email protected]>
Thanks! Applied https://github.com/pmem/ndctl/tree/pending