add tracepoints for nvme command submission and completion
v3 cover add tracepoints for nvme command submission and completion
Add tracepoints for nvme command submission and completion. The tracepoints are modeled after SCSI's trace_scsi_dispatch_cmd_start() and trace_scsi_dispatch_cmd_done() tracepoints and fulfil a similar purpose, namely a fast way to check which command is going to be queued into the HW or Fabric driver and which command is completed again.
Here's an example output using the qemu emulated pci nvme:
# tracer: nop
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
dd-205 [002] .... 7.128368: nvme_setup_cmd: nsid=1, command_id=568, flags=0x0, metadata=0x0, cmd=(nvme_cmd_read slba=0, length=31, control=0x0, dsmgmt=0, reftag=0)
<idle>-0 [002] d.h. 7.129098: nvme_complete_rq: command_id=568, result=0, retries=0, flags=0x0, status=0
dd-205 [002] .... 7.129150: nvme_setup_cmd: nsid=1, command_id=568, flags=0x0, metadata=0x0, cmd=(nvme_cmd_read slba=32, length=63, control=0x0, dsmgmt=0, reftag=0)
dd-205 [002] .... 7.129189: nvme_setup_cmd: nsid=1, command_id=569, flags=0x0, metadata=0x0, cmd=(nvme_cmd_read slba=96, length=127, control=0x0, dsmgmt=0, reftag=0)
<idle>-0 [002] d.h. 7.129318: nvme_complete_rq: command_id=568, result=0, retries=0, flags=0x0, status=0
dd-205 [002] d.h. 7.129355: nvme_complete_rq: command_id=569, result=0, retries=0, flags=0x0, status=0
dd-206 [003] .... 7.137389: nvme_setup_cmd: nsid=1, command_id=22, flags=0x0, metadata=0x0, cmd=(nvme_cmd_write slba=0, length=2559, control=0x0, dsmgmt=0, reftag=0)
dd-206 [003] .... 7.137888: nvme_setup_cmd: nsid=1, command_id=23, flags=0x0, metadata=0x0, cmd=(nvme_cmd_write slba=2560, length=2559, control=0x0, dsmgmt=0, reftag=0)
dd-206 [003] .... 7.138365: nvme_setup_cmd: nsid=1, command_id=24, flags=0x0, metadata=0x0, cmd=(nvme_cmd_write slba=5120, length=2559, control=0x0, dsmgmt=0, reftag=0)
dd-206 [003] d.h. 7.138634: nvme_complete_rq: command_id=22, result=0, retries=0, flags=0x0, status=0
dd-206 [003] .... 7.139014: nvme_setup_cmd: nsid=1, command_id=25, flags=0x0, metadata=0x0, cmd=(nvme_cmd_write slba=7680, length=2559, control=0x0, dsmgmt=0, reftag=0)
<idle>-0 [003] d.h. 7.139658: nvme_complete_rq: command_id=23, result=0, retries=0, flags=0x0, status=0
<idle>-0 [003] d.h. 7.140650: nvme_complete_rq: command_id=24, result=0, retries=0, flags=0x0, status=0
<idle>-0 [003] d.h. 7.141670: nvme_complete_rq: command_id=25, result=0, retries=0, flags=0x0, status=0Johannes Thumshirn (2):
nvme: add tracepoint for nvme_setup_cmd
nvme: add tracepoint for nvme_complete_rq
drivers/nvme/host/Makefile | 5 ++- drivers/nvme/host/core.c | 6 +++ drivers/nvme/host/trace.c | 82 ++++++++++++++++++++++++++++++++++++ drivers/nvme/host/trace.h | 103 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 drivers/nvme/host/trace.c create mode 100644 drivers/nvme/host/trace.h
Signature · 1 line
2.12.3
PATCH v3 1/2 nvme: add tracepoint for nvme_setup_cmd
---
Changes to v2:
* Don't cast le64_to_cpu() conversions to unsigned long long (Christoph)
* Add proper copyright header (Christoph)
* Move trace decoding into own file (Christoph)
* Include the src directory in the Makefile for trace (Christoph)
* Removed spaces before and after parenthesis (Christoph)
* Reduced print lines to fit the 80 char limit (Christoph)
Changes to v1:
* Fix typo (Hannes)
* move include/trace/events/nvme.h -> drivers/nvme/host/trace.h (Christoph)
--- drivers/nvme/host/Makefile | 5 ++- drivers/nvme/host/core.c | 4 +++ drivers/nvme/host/trace.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/trace.h | 77 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 drivers/nvme/host/trace.c create mode 100644 drivers/nvme/host/trace.h
drivers/nvme/host/Makefile +4 -1
@@ -1,11 +1,14 @@ # SPDX-License-Identifier: GPL-2.0 + +ccflags-y += -I$(src) + obj-$(CONFIG_NVME_CORE) += nvme-core.o obj-$(CONFIG_BLK_DEV_NVME) += nvme.o obj-$(CONFIG_NVME_FABRICS) += nvme-fabrics.o obj-$(CONFIG_NVME_RDMA) += nvme-rdma.o obj-$(CONFIG_NVME_FC) += nvme-fc.o -nvme-core-y := core.o +nvme-core-y := trace.o core.o nvme-core-$(CONFIG_NVME_MULTIPATH) += multipath.o nvme-core-$(CONFIG_NVM) += lightnvm.o
drivers/nvme/host/core.c +4 -0
@@ -29,6 +29,9 @@#include <linux/pm_qos.h> #include <asm/unaligned.h> +#define CREATE_TRACE_POINTS +#include "trace.h" +#include "nvme.h" #include "fabrics.h"
@@ -591,6 +594,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, } cmd->common.command_id = req->tag; +trace_nvme_setup_cmd (cmd);return ret; }EXPORT_SYMBOL_GPL (nvme_setup_cmd);
drivers/nvme/host/trace.c new file +82 -0
82 lines not on this page · raw message
drivers/nvme/host/trace.h new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.12.3
Re: [PATCH v3 1/2] nvme: add tracepoint for nvme_setup_cmd
Johannes,
Very nice!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v3 1/2] nvme: add tracepoint for nvme_setup_cmd
In reply to Johannes ThumshirnLooks good.
Christoph Hellwig
maintainerRe: [PATCH v3 1/2] nvme: add tracepoint for nvme_setup_cmd
In reply to Johannes ThumshirnQuoted 1 line · Johannes Thumshirn
+nvme-core-y := trace.o core.o
trace.o should be conditional on CONFIG_TRACEPOINTS.
drivers/nvme/host/trace.h line 52
Quoted 10 lines
drivers/nvme/host/trace.h new file +10
-0+TRACE_EVENT(nvme_setup_cmd, + TP_PROTO(struct nvme_command *cmd), + TP_ARGS(cmd), + TP_STRUCT__entry( + __field(__u8, opcode) + __field(__u8, flags) + __field(__u16, cid) + __field(__le32, nsid) + __field(__le64, metadata) + __field_struct( struct nvme_command, cmnd )
This still copies the whole SQE. I think that is way to much to copy, especially given that you also copy many of the fields separately as well.
Re: [PATCH v3 1/2] nvme: add tracepoint for nvme_setup_cmd
Quoted 4 lines · Christoph Hellwig
Quoted 1 line · Johannes Thumshirn
+nvme-core-y := trace.o core.o
trace.o should be conditional on
CONFIG_TRACEPOINTS.
Doesn't do too much of a difference for me if CONFIG_TRACEPOINTS=n but if you insist I can do it of cause.
Quoted 6 lines
Quoted 6 lines
drivers/nvme/host/trace.h new file +6
-0+TRACE_EVENT(nvme_setup_cmd, + TP_PROTO(struct nvme_command *cmd), + TP_ARGS(cmd), + TP_STRUCT__entry( + __field(__u8, opcode) + __field(__u8, flags)
Quoted 8 lines
drivers/nvme/host/trace.h line 52
Quoted 4 lines
drivers/nvme/host/trace.h new file +4
-0+ __field(__u16, cid) + __field(__le32, nsid) + __field(__le64, metadata) + __field_struct( struct nvme_command, cmnd )This still copies the whole SQE. I think that is way to much to copy, especially given that you also copy many of the fields separately as well.
it's not that much, but ok.
Will be sending out a v4 tomorrow.
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH v3 2/2 nvme: add tracepoint for nvme_complete_rq
In reply to Johannes Thumshirn---
Changes to v2:
* Pass the whole struct request to the tracepoint
* Removed spaces after parenthesis (Christoph)
--- drivers/nvme/host/core.c | 2 ++ drivers/nvme/host/trace.h | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)
drivers/nvme/host/core.c +2 -0
@@ -193,6 +193,8 @@ static inline bool nvme_req_needs_retry(struct request *req)void nvme_complete_rq (struct request *req) { +trace_nvme_complete_rq (req); +if (unlikely (nvme_req (req)->status &&nvme_req_needs_retry (req))) {if (nvme_req_needs_failover (req)) {nvme_failover_req (req);
drivers/nvme/host/trace.h +26 -0
@@ -22,6 +22,8 @@#include <linux/tracepoint.h> #include <linux/trace_seq.h> +#include "nvme.h" +#define nvme_opcode_name (opcode) { opcode, #opcode }#define show_opcode_name (val) \ __print_symbolic(val, \
@@ -66,6 +68,30 @@ TRACE_EVENT(nvme_setup_cmd, __parse_nvme_cmd(__entry->cmnd)) ); +TRACE_EVENT (nvme_complete_rq, + TP_PROTO(struct request *req), +TP_ARGS (req), +TP_STRUCT__entry ( + __field(int, cid) + __field(__le64, result) + __field(u8, retries) + __field(u8, flags) +__field (u16, status) + ), +TP_fast_assign ( + __entry->cid = req->tag; + __entry->result = nvme_req(req)->result.u64; + __entry->retries = nvme_req(req)->retries; + __entry->flags = nvme_req(req)->flags; + __entry->status = nvme_req(req)->status; + ), +TP_printk ("cmdid=%u, res=%llu, retries=%u, flags=0x%x, status=%u" , + __entry->cid, +le64_to_cpu (__entry->result), + __entry->retries, __entry->flags, __entry->status) + +); +#endif /* _TRACE_NVME_H */ #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.12.3
Re: [PATCH v3 2/2] nvme: add tracepoint for nvme_complete_rq
Johannes,
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v3 2/2] nvme: add tracepoint for nvme_complete_rq
In reply to Johannes ThumshirnLooks good.