Skip to contentSkip to conversation

share nvme trace event helper functions with multiple nvme modules

PATCH Superseded yupeng 2 participants 3 messages Dec 16, 2018

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

yupeng

author
#0 lore raw

PATCH v2 1/2 share nvme trace event helper functions with multiple nvme modules

The trace.c could only be used by core.c, move it to a header file and then other nvme modules could also use it. This commit creates a new header file trace_common.h, which has all the functions of trace.c. It changes all functions to static functions, so any other modules could include it without conflict. This commit also moves some common functions from trace.h to trace_common.h. Because the trace events in trace.h are used by nvme-core only, this commit renames the trace.h to trace_core.h.

Signed-off-by yupeng <yupeng0921 at gmail.com>
---
 drivers/nvme/host/Makefile                    |  1 -
 drivers/nvme/host/core.c                      |  2 +-
 drivers/nvme/host/{trace.c => trace_common.h} | 82 +++++++++++++++++--
 drivers/nvme/host/{trace.h => trace_core.h}   | 76 +----------------
 4 files changed, 80 insertions(+), 81 deletions(-)
 rename drivers/nvme/host/{trace.c => trace_common.h} (55%)
 rename drivers/nvme/host/{trace.h => trace_core.h} (56%)
drivers/nvme/host/Makefile +0 -1
index aea459c65ae1..165c265f57f1 100644
@@ -9,7 +9,6 @@ obj-$(CONFIG_NVME_RDMA)			+= nvme-rdma.o
 obj-$(CONFIG_NVME_FC)			+= nvme-fc.o
 
 nvme-core-y				:= core.o
-nvme-core-$(CONFIG_TRACING)		+= trace.o
 nvme-core-$(CONFIG_NVME_MULTIPATH)	+= multipath.o
 nvme-core-$(CONFIG_NVM)			+= lightnvm.o
 nvme-core-$(CONFIG_FAULT_INJECTION_DEBUG_FS)	+= fault_inject.o
drivers/nvme/host/core.c +1 -1
index 962012135b62..a1cf8df4c507 100644
@@ -30,7 +30,7 @@
 #include <asm/unaligned.h>
 
 #define CREATE_TRACE_POINTS
-#include "trace.h"
+#include "trace_core.h"
 
 #include "nvme.h"
 #include "fabrics.h"
drivers/nvme/host/trace_common.h renamed from drivers/nvme/host/trace.c +77 -5

110 lines not on this page · raw message

drivers/nvme/host/trace_core.h renamed from drivers/nvme/host/trace.h +2 -74

88 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 2/2 trace nvme submit queue status

export nvme disk name, queue id, sq_head, sq_tail to trace event usage example:
go to the event directory:
cd /sys/kernel/debug/tracing/events/nvme/nvme_sq filter by disk name:
echo 'disk=="nvme1n1"' > filter
enable the event:
echo 1 > enable
check results from trace_pipe:
cat /sys/kernel/debug/tracing/trace_pipe
In practice, this patch help me debug hardware related performant issue.

Signed-off-by yupeng <yupeng0921 at gmail.com>
---
 drivers/nvme/host/pci.c       |  7 +++++
 drivers/nvme/host/trace_pci.h | 49 +++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 drivers/nvme/host/trace_pci.h
drivers/nvme/host/pci.c +7 -0
index c33bb201b884..974cb05b3592 100644
@@ -32,6 +32,9 @@
 #include <linux/sed-opal.h>
 #include <linux/pci-p2pdma.h>
 
+#define CREATE_TRACE_POINTS
+#include "trace_pci.h"
+
 #include "nvme.h"
 
 #define SQ_SIZE(depth)		(depth * sizeof(struct nvme_command))
@@ -899,6 +902,10 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
 	}
 
 	req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id);
+	trace_nvme_sq(req->rq_disk,
+		nvmeq->qid,
+		le16_to_cpu(cqe->sq_head),
+		nvmeq->sq_tail);
 	nvme_end_request(req, cqe->status, cqe->result);
 }
 
drivers/nvme/host/trace_pci.h new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw
In reply to yupeng
Quoted 8 lines · yupeng

The trace.c could only be used by core.c, move it to a header file and then other nvme modules could also use it. This commit creates a new header file trace_common.h, which has all the functions of trace.c. It changes all functions to static functions, so any other modules could include it without conflict. This commit also moves some common functions from trace.h to trace_common.h. Because the trace events in trace.h are used by nvme-core only, this commit renames the trace.h to trace_core.h.

We could always export bits out of trace.o using EXPORT_SYMBOL_GPL, no need to move duplicate the code. Also as far as I can tell you only use __assign_disk_name of the helpers, so we can move that into a new helper. It might make sense to just move that into include/linux/genhd.h to make it easily available everywhere.