From: alison.schofield@intel.com
To: Dan Williams <dan.j.williams@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ben Widawsky <bwidawsk@kernel.org>
Cc: Alison Schofield <alison.schofield@intel.com>,
nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: [ndctl PATCH 5/5] test: add a cxl-get-poison test
Date: Thu, 10 Nov 2022 19:20:08 -0800 [thread overview]
Message-ID: <fe384a7dc7bc9b84db640dbbf6b7af73fe7ebd5c.1668133294.git.alison.schofield@intel.com> (raw)
In-Reply-To: <cover.1668133294.git.alison.schofield@intel.com>
From: Alison Schofield <alison.schofield@intel.com>
Exercise cxl list, libcxl, and driver pieces of the get poison
pathway. The poison records themselves are mocked by cxl_test,
but the work of triggering the poison read, logging as trace events,
and then collecting and parsing is all for real.
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
test/cxl-get-poison.sh | 78 ++++++++++++++++++++++++++++++++++++++++++
test/meson.build | 2 ++
2 files changed, 80 insertions(+)
create mode 100644 test/cxl-get-poison.sh
diff --git a/test/cxl-get-poison.sh b/test/cxl-get-poison.sh
new file mode 100644
index 000000000000..fe93a67a5240
--- /dev/null
+++ b/test/cxl-get-poison.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2022 Intel Corporation. All rights reserved.
+
+. $(dirname $0)/common
+
+rc=1
+
+set -ex
+
+trap 'err $LINENO' ERR
+
+check_prereq "jq"
+
+modprobe -r cxl_test
+modprobe cxl_test
+udevadm settle
+
+# The number or errors that cxl_test mocks is subject to change.
+NR_ERRS=2
+
+# THEORY OF OPERATION: Exercise cxl-cli and cxl driver capabilites wrt
+# retrieving poison lists. The poison list is maintained by the device.
+# It may be requested per memdev or per region.
+
+create_region()
+{
+ region=$($CXL create-region -d $decoder -m $memdevs | jq -r ".region")
+
+ if [[ ! $region ]]; then
+ echo "create-region failed for $decoder"
+ err "$LINENO"
+ fi
+}
+
+setup_x2_region()
+{
+ # Find an x2 decoder
+ decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] |
+ select(.pmem_capable == true) |
+ select(.nr_targets == 2) |
+ .decoder")
+
+ # Find a memdev for each host-bridge interleave position
+ port_dev0=$($CXL list -T -d $decoder | jq -r ".[] |
+ .targets | .[] | select(.position == 0) | .target")
+ port_dev1=$($CXL list -T -d $decoder | jq -r ".[] |
+ .targets | .[] | select(.position == 1) | .target")
+ mem0=$($CXL list -M -p $port_dev0 | jq -r ".[0].memdev")
+ mem1=$($CXL list -M -p $port_dev1 | jq -r ".[0].memdev")
+ memdevs="$mem0 $mem1"
+}
+
+find_media_errors()
+{
+ nr=$(echo $json | jq -r ".nr_media_errors")
+ if [[ $nr -ne $NR_ERRS ]]; then
+ echo "$mem: $NR_ERRS media errors expected, $nr found"
+ err "$LINENO"
+ fi
+}
+
+# Read poison from each available memdev
+readarray -t mems < <("$CXL" list -b cxl_test -Mi | jq -r '.[].memdev')
+for mem in ${mems[@]}; do
+ json=$("$CXL" list -m "$mem" --media-errors | jq -r '.[].media_errors')
+ find_media_errors
+done
+
+# Read poison from one region
+setup_x2_region
+create_region
+json=$("$CXL" list -r "$region" --media-errors | jq -r '.[].media_errors')
+find_media_errors
+cxl disable-region $region
+cxl destroy-region $region
+
+modprobe -r cxl_test
diff --git a/test/meson.build b/test/meson.build
index 5953c286d13f..721c69e79f5e 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -154,6 +154,7 @@ cxl_topo = find_program('cxl-topology.sh')
cxl_sysfs = find_program('cxl-region-sysfs.sh')
cxl_labels = find_program('cxl-labels.sh')
cxl_create_region = find_program('cxl-create-region.sh')
+cxl_get_poison = find_program('cxl-get-poison.sh')
tests = [
[ 'libndctl', libndctl, 'ndctl' ],
@@ -182,6 +183,7 @@ tests = [
[ 'cxl-region-sysfs.sh', cxl_sysfs, 'cxl' ],
[ 'cxl-labels.sh', cxl_labels, 'cxl' ],
[ 'cxl-create-region.sh', cxl_create_region, 'cxl' ],
+ [ 'cxl-get-poison.sh', cxl_get_poison, 'cxl' ],
]
if get_option('destructive').enabled()
--
2.37.3
prev parent reply other threads:[~2022-11-11 3:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 3:20 [ndctl PATCH 0/3] Support poison list retrieval alison.schofield
2022-11-11 3:20 ` [ndctl PATCH 1/5] libcxl: add interfaces for GET_POISON_LIST mailbox commands alison.schofield
2022-11-16 12:56 ` Jonathan Cameron
2022-11-17 23:45 ` Alison Schofield
2022-11-11 3:20 ` [ndctl PATCH 2/5] cxl: add an optional pid check to event parsing alison.schofield
2022-11-16 12:57 ` Jonathan Cameron
2022-11-11 3:20 ` [ndctl PATCH 3/5] cxl/list: collect and parse the poison list records alison.schofield
2022-11-11 3:20 ` [ndctl PATCH 4/5] cxl/list: add --media-errors option to cxl list alison.schofield
2022-11-16 13:03 ` Jonathan Cameron
2022-11-17 23:42 ` Alison Schofield
2022-11-21 10:57 ` Jonathan Cameron
2022-11-11 3:20 ` alison.schofield [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe384a7dc7bc9b84db640dbbf6b7af73fe7ebd5c.1668133294.git.alison.schofield@intel.com \
--to=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox