Skip to contentSkip to conversation

cxl/list: remove libtracefs build dependency for --media-errors

PATCH In review Alison Schofield 2 participants 3 messages Sep 25, 2025

Subsystems (3)
lore
Share & tools
lore

Alison Schofield

author maintainer
#0 lore raw

PATCH v3 1/1 cxl/list: remove libtracefs build dependency for --media-errors

When the --media-errors option was added to cxl list it inadvertently changed the optional libtracefs requirement into a mandatory one. Ndctl versions 80,81,82 no longer build without libtracefs.

Remove that dependency.

When libtracefs is disabled the user will see a this message logged to stderr:

	$ cxl list -r region0 --media-errors --targets
	cxl list: --media-errors support disabled at build time

...followed by the region listing including the output for any other valid command line options, like --targets in the example above.

When libtracefs is disabled the cxl-poison.sh unit test is omitted.

The man page gets a note:
The media-error option is only available with -Dlibtracefs=enabled.

---

Changes in v3:
- Remove ifdef's from .c files (Dan)
Move ifdef chunk in json.c to a new conditionally compiled json_poison.c. Move ifdef notice message to !ENABLE_LIBTRACEFS stub in event_trace.h.
Changes in v2:
- Notify and continue when --media-error info is unavailable (Dan)

 Documentation/cxl/cxl-list.txt |   2 +
 config.h.meson                 |   2 +-
 cxl/json.c                     | 180 --------------------------------
 cxl/json_poison.c              | 185 +++++++++++++++++++++++++++++++++
 cxl/meson.build                |   1 +
 test/meson.build               |   9 +-
 util/event_trace.h             |  14 +++
 7 files changed, 210 insertions(+), 183 deletions(-)
 create mode 100644 cxl/json_poison.c
Documentation/cxl/cxl-list.txt +2 -0
index 9a9911e7dd9b..0595638ee054 100644
@@ -425,6 +425,8 @@ OPTIONS
 	"source:" is one of: External, Internal, Injected, Vendor Specific,
 	or Unknown, as defined in CXL Specification v3.1 Table 8-140.
 
+The media-errors option is only available with '-Dlibtracefs=enabled'.
+
 ----
 # cxl list -m mem9 --media-errors -u
 {
config.h.meson +1 -1
index f75db3e6360f..e8539f8d04df 100644
@@ -19,7 +19,7 @@
 /* ndctl test support */
 #mesondefine ENABLE_TEST
 
-/* cxl monitor support */
+/* cxl monitor and cxl list --media-errors support */
 #mesondefine ENABLE_LIBTRACEFS
 
 /* Define to 1 if big-endian-arch */
cxl/json.c +0 -180

192 lines not on this page · raw message

cxl/json_poison.c new file +185 -0

185 lines not on this page · raw message

cxl/meson.build +1 -0
index e4d1683ce8c6..b9924ae8efea 100644
@@ -29,6 +29,7 @@ if get_option('libtracefs').enabled()
   cxl_src += [
     '../util/event_trace.c',
     'monitor.c',
+    'json_poison.c',
   ]
   deps += [
     traceevent,
test/meson.build +7 -2
index 775542c1b787..615376ea635a 100644
@@ -167,7 +167,6 @@ cxl_events = find_program('cxl-events.sh')
 cxl_sanitize = find_program('cxl-sanitize.sh')
 cxl_destroy_region = find_program('cxl-destroy-region.sh')
 cxl_qos_class = find_program('cxl-qos-class.sh')
-cxl_poison = find_program('cxl-poison.sh')
 
 tests = [
   [ 'libndctl',               libndctl,		  'ndctl' ],
@@ -200,7 +199,6 @@ tests = [
   [ 'cxl-sanitize.sh',        cxl_sanitize,       'cxl'   ],
   [ 'cxl-destroy-region.sh',  cxl_destroy_region, 'cxl'   ],
   [ 'cxl-qos-class.sh',       cxl_qos_class,      'cxl'   ],
-  [ 'cxl-poison.sh',          cxl_poison,         'cxl'   ],
 ]
 
 if get_option('destructive').enabled()
@@ -253,6 +251,13 @@ if get_option('fwctl').enabled()
   ]
 endif
 
+if get_option('libtracefs').enabled()
+  cxl_poison = find_program('cxl-poison.sh')
+  tests += [
+    [ 'cxl-poison.sh', cxl_poison, 'cxl' ],
+  ]
+endif
+
 test_env = [
     'LC_ALL=C',
     'NDCTL=@0@'.format(ndctl_tool.full_path()),
util/event_trace.h +14 -0
index a87407ff8296..989c02ec2259 100644
@@ -7,6 +7,9 @@
 #include <ccan/list/list.h>
 #include <ccan/short_types/short_types.h>
 
+#ifdef ENABLE_LIBTRACEFS
+#include <tracefs.h>
+
 struct jlist_node {
 	struct json_object *jobj;
 	struct list_node list;
@@ -39,4 +42,15 @@ u32 trace_get_field_u32(struct tep_event *event, struct tep_record *record,
 			const char *name);
 u64 trace_get_field_u64(struct tep_event *event, struct tep_record *record,
 			const char *name);
+struct json_object *util_cxl_poison_list_to_json(struct cxl_region *region,
+			struct cxl_memdev *memdev, unsigned long flags);
+#else
+struct json_object *util_cxl_poison_list_to_json(struct cxl_region *region,
+			struct cxl_memdev *memdev, unsigned long flags)
+{
+	fprintf(stderr, "cxl list --media-errors support disabled at build time\n");
+	return NULL;
+}
+#endif /* ENABLE_LIBTRACEFS */
+
 #endif
Signature · 1 line
2.37.3
Reviewed-by on v3 1/1
#1 lore raw
Quoted 26 lines · Alison Schofield

When the --media-errors option was added to cxl list it inadvertently changed the optional libtracefs requirement into a mandatory one. Ndctl versions 80,81,82 no longer build without libtracefs.

Remove that dependency.

When libtracefs is disabled the user will see a this message logged to stderr:

	$ cxl list -r region0 --media-errors --targets
	cxl list: --media-errors support disabled at build time

...followed by the region listing including the output for any other valid command line options, like --targets in the example above.

When libtracefs is disabled the cxl-poison.sh unit test is omitted.

The man page gets a note:
The media-error option is only available with -Dlibtracefs=enabled.

Quoted 6 lines

---

Changes in v3:
- Remove ifdef's from .c files (Dan)
Move ifdef chunk in json.c to a new conditionally compiled json_poison.c. Move ifdef notice message to !ENABLE_LIBTRACEFS stub in event_trace.h.

Looks great, I appreciate the ifdef reorganization effort.

author maintainer
#2 lore raw
Quoted 29 lines · Dan Williams
Quoted 28 lines · Alison Schofield

When the --media-errors option was added to cxl list it inadvertently changed the optional libtracefs requirement into a mandatory one. Ndctl versions 80,81,82 no longer build without libtracefs.

Remove that dependency.

When libtracefs is disabled the user will see a this message logged to stderr:

	$ cxl list -r region0 --media-errors --targets
	cxl list: --media-errors support disabled at build time

...followed by the region listing including the output for any other valid command line options, like --targets in the example above.

When libtracefs is disabled the cxl-poison.sh unit test is omitted.

The man page gets a note:
The media-error option is only available with -Dlibtracefs=enabled.

---

Quoted 8 lines
Quoted 4 lines

Changes in v3:
- Remove ifdef's from .c files (Dan)
Move ifdef chunk in json.c to a new conditionally compiled json_poison.c. Move ifdef notice message to !ENABLE_LIBTRACEFS stub in event_trace.h.

Looks great, I appreciate the ifdef reorganization effort.

Thanks for the review!
Pending rebased with this v3 version:
https://github.com/pmem/ndctl/commit/b26e9ae