anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame 0104-cxl-list-Add-debug-option.patch

Jeff Moyer 2c91dc
From 2a43dce3913b392a13a5ee918c8ee831a25d720e Mon Sep 17 00:00:00 2001
Jeff Moyer 2c91dc
From: Dan Williams <dan.j.williams@intel.com>
Jeff Moyer 2c91dc
Date: Sun, 23 Jan 2022 16:53:24 -0800
Jeff Moyer 2c91dc
Subject: [PATCH 104/217] cxl/list: Add --debug option
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
Add an option to turn on libray and cxl_filter_walk() messages. Gate it
Jeff Moyer 2c91dc
based on the global ENABLE_DEBUG configuration setting.
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
Link: https://lore.kernel.org/r/164298560409.3021641.11040422738199381922.stgit@dwillia2-desk3.amr.corp.intel.com
Jeff Moyer 2c91dc
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Jeff Moyer 2c91dc
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Jeff Moyer 2c91dc
---
Jeff Moyer 2c91dc
 Documentation/cxl/cxl-list.txt | 6 ++++--
Jeff Moyer 2c91dc
 cxl/filter.c                   | 3 +++
Jeff Moyer 2c91dc
 cxl/list.c                     | 9 +++++++++
Jeff Moyer 2c91dc
 3 files changed, 16 insertions(+), 2 deletions(-)
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt
Jeff Moyer 2c91dc
index 3076deb..42b6de6 100644
Jeff Moyer 2c91dc
--- a/Documentation/cxl/cxl-list.txt
Jeff Moyer 2c91dc
+++ b/Documentation/cxl/cxl-list.txt
Jeff Moyer 2c91dc
@@ -200,9 +200,11 @@ OPTIONS
Jeff Moyer 2c91dc
 	descendants of the individual ports that match the filter. By default
Jeff Moyer 2c91dc
 	all descendant objects are listed.
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
-include::human-option.txt[]
Jeff Moyer 2c91dc
+--debug::
Jeff Moyer 2c91dc
+	If the cxl tool was built with debug enabled, turn on debug
Jeff Moyer 2c91dc
+	messages.
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
-include::verbose-option.txt[]
Jeff Moyer 2c91dc
+include::human-option.txt[]
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 include::../copyright.txt[]
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
diff --git a/cxl/filter.c b/cxl/filter.c
Jeff Moyer 2c91dc
index 8b79db3..32171a4 100644
Jeff Moyer 2c91dc
--- a/cxl/filter.c
Jeff Moyer 2c91dc
+++ b/cxl/filter.c
Jeff Moyer 2c91dc
@@ -387,6 +387,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
Jeff Moyer 2c91dc
 	if (!jports)
Jeff Moyer 2c91dc
 		goto err;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
+	dbg(p, "walk memdevs\n");
Jeff Moyer 2c91dc
 	cxl_memdev_foreach(ctx, memdev) {
Jeff Moyer 2c91dc
 		struct json_object *jdev;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
@@ -403,6 +404,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
Jeff Moyer 2c91dc
 		}
Jeff Moyer 2c91dc
 	}
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
+	dbg(p, "walk buses\n");
Jeff Moyer 2c91dc
 	cxl_bus_foreach(ctx, bus) {
Jeff Moyer 2c91dc
 		struct json_object *jbus = NULL;
Jeff Moyer 2c91dc
 		struct json_object *jchildports = NULL;
Jeff Moyer 2c91dc
@@ -431,6 +433,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
Jeff Moyer 2c91dc
 			}
Jeff Moyer 2c91dc
 		}
Jeff Moyer 2c91dc
 walk_children:
Jeff Moyer 2c91dc
+		dbg(p, "walk ports\n");
Jeff Moyer 2c91dc
 		walk_child_ports(port, p, pick_array(jchildports, jports),
Jeff Moyer 2c91dc
 				 flags);
Jeff Moyer 2c91dc
 		cond_add_put_array_suffix(jbus, "ports", devname, jchildports);
Jeff Moyer 2c91dc
diff --git a/cxl/list.c b/cxl/list.c
Jeff Moyer 2c91dc
index 1ef91b4..01ab19b 100644
Jeff Moyer 2c91dc
--- a/cxl/list.c
Jeff Moyer 2c91dc
+++ b/cxl/list.c
Jeff Moyer 2c91dc
@@ -13,6 +13,7 @@
Jeff Moyer 2c91dc
 #include "filter.h"
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 static struct cxl_filter_params param;
Jeff Moyer 2c91dc
+static bool debug;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 static const struct option options[] = {
Jeff Moyer 2c91dc
 	OPT_STRING('m', "memdev", &param.memdev_filter, "memory device name(s)",
Jeff Moyer 2c91dc
@@ -35,6 +36,9 @@ static const struct option options[] = {
Jeff Moyer 2c91dc
 		    "use human friendly number formats "),
Jeff Moyer 2c91dc
 	OPT_BOOLEAN('H', "health", &param.health,
Jeff Moyer 2c91dc
 		    "include memory device health information "),
Jeff Moyer 2c91dc
+#ifdef ENABLE_DEBUG
Jeff Moyer 2c91dc
+	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
Jeff Moyer 2c91dc
+#endif
Jeff Moyer 2c91dc
 	OPT_END(),
Jeff Moyer 2c91dc
 };
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
@@ -84,9 +88,14 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
Jeff Moyer 2c91dc
 	}
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
Jeff Moyer 2c91dc
+	if (debug) {
Jeff Moyer 2c91dc
+		cxl_set_log_priority(ctx, LOG_DEBUG);
Jeff Moyer 2c91dc
+		param.ctx.log_priority = LOG_DEBUG;
Jeff Moyer 2c91dc
+	}
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	if (cxl_filter_has(param.port_filter, "root") && param.ports)
Jeff Moyer 2c91dc
 		param.buses = true;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
+	dbg(&param, "walk topology\n");
Jeff Moyer 2c91dc
 	return cxl_filter_walk(ctx, ¶m;;
Jeff Moyer 2c91dc
 }
Jeff Moyer 2c91dc
-- 
Jeff Moyer 2c91dc
2.27.0
Jeff Moyer 2c91dc