Skip to contentSkip to conversation

cxl/test: Add test case for region info to cxl-events.sh

PATCH In review [email protected] 3 participants 3 messages Mar 28, 2024 – Jun 25, 2024 libnvdimm: non-volatile memory device

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 cxl/test: Add test case for region info to cxl-events.sh

From: Alison Schofield <[email protected]>

Events cxl_general_media and cxl_dram both report DPAs that may be mapped in a region. If the DPA is mapped, the trace event will include the HPA translation, region name and region uuid in the trace event.

Add a test case that triggers these events with DPAs that map into a region. Verify the region is included in the trace event.

---
 test/cxl-events.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
test/cxl-events.sh +24 -0
index fe702bf98ad4..ff4f3fdff1d8 100644
@@ -23,6 +23,26 @@ modprobe cxl_test
 rc=1
 
 dev_path="/sys/bus/platform/devices"
+trace_path="/sys/kernel/tracing"
+
+test_region_info()
+{
+	# Trigger a memdev in the cxl_test autodiscovered region
+	region=$($CXL list  -R | jq -r ".[] | .region")
+	memdev=$($CXL list -r "$region" --targets |
+		jq -r '.[].mappings' |
+		jq -r '.[0].memdev')
+	host=$($CXL list -m "$memdev" | jq -r '.[].host')
+
+	echo 1 > "$dev_path"/"$host"/event_trigger
+
+	if ! grep "cxl_general_media.*$region" "$trace_path"/trace; then
+		err "$LINENO"
+	fi
+	if ! grep "cxl_dram.*$region" "$trace_path"/trace; then
+		err "$LINENO"
+	fi
+}
 
 test_cxl_events()
 {
@@ -74,6 +94,10 @@ if [ "$num_info" -ne $num_info_expected ]; then
 	err "$LINENO"
 fi
 
+echo 1 > /sys/kernel/tracing/tracing_on
+test_region_info
+echo 0 > /sys/kernel/tracing/tracing_on
+
 check_dmesg "$LINENO"
 
 modprobe -r cxl_test
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On 3/27/24 9:37 PM, [email protected] wrote:

From: Alison Schofield <[email protected]>

Events cxl_general_media and cxl_dram both report DPAs that may be mapped in a region. If the DPA is mapped, the trace event will include the HPA translation, region name and region uuid in the trace event.

Add a test case that triggers these events with DPAs that map into a region. Verify the region is included in the trace event.

Quoted 46 lines
---
 test/cxl-events.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
test/cxl-events.sh +24 -0
index fe702bf98ad4..ff4f3fdff1d8 100644
@@ -23,6 +23,26 @@ modprobe cxl_test
 rc=1
 
 dev_path="/sys/bus/platform/devices"
+trace_path="/sys/kernel/tracing"
+
+test_region_info()
+{
+	# Trigger a memdev in the cxl_test autodiscovered region
+	region=$($CXL list  -R | jq -r ".[] | .region")
+	memdev=$($CXL list -r "$region" --targets |
+		jq -r '.[].mappings' |
+		jq -r '.[0].memdev')
+	host=$($CXL list -m "$memdev" | jq -r '.[].host')
+
+	echo 1 > "$dev_path"/"$host"/event_trigger
+
+	if ! grep "cxl_general_media.*$region" "$trace_path"/trace; then
+		err "$LINENO"
+	fi
+	if ! grep "cxl_dram.*$region" "$trace_path"/trace; then
+		err "$LINENO"
+	fi
+}
 
 test_cxl_events()
 {
@@ -74,6 +94,10 @@ if [ "$num_info" -ne $num_info_expected ]; then
 	err "$LINENO"
 fi
 
+echo 1 > /sys/kernel/tracing/tracing_on
+test_region_info
+echo 0 > /sys/kernel/tracing/tracing_on
+
 check_dmesg "$LINENO"
 
 modprobe -r cxl_test
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 11 lines · alison.schofield@ wrote:

From: Alison Schofield <[email protected]>

Events cxl_general_media and cxl_dram both report DPAs that may be mapped in a region. If the DPA is mapped, the trace event will include the HPA translation, region name and region uuid in the trace event.

Add a test case that triggers these events with DPAs that map into a region. Verify the region is included in the trace event.

[snip]