[PATCH v2 2/2] nvme: add tracepoint for nvme_complete_rq

From: Johannes Thumshirn
Date: Tue Jan 16 2018 - 09:29:33 EST


Signed-off-by: Johannes Thumshirn <jthumshirn@xxxxxxx>
Reviewed-by: Hannes Reinecke <hare@xxxxxxxx>
---
drivers/nvme/host/core.c | 2 ++
drivers/nvme/host/trace.h | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 776fe7c0a411..d62b4d429921 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -258,6 +258,8 @@ static inline bool nvme_req_needs_retry(struct request *req)

void nvme_complete_rq(struct request *req)
{
+ trace_nvme_complete_rq(nvme_req(req), req->tag);
+
if (unlikely(nvme_req(req)->status && nvme_req_needs_retry(req))) {
if (nvme_req_needs_failover(req)) {
nvme_failover_req(req);
diff --git a/drivers/nvme/host/trace.h b/drivers/nvme/host/trace.h
index 7b6bb1b5995e..c1596aec37fd 100644
--- a/drivers/nvme/host/trace.h
+++ b/drivers/nvme/host/trace.h
@@ -9,6 +9,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, \
@@ -58,6 +60,35 @@ TRACE_EVENT(nvme_setup_cmd,
__parse_nvme_cmd(__entry->cmnd))
);

+TRACE_EVENT(nvme_complete_rq,
+
+ TP_PROTO(struct nvme_request *req, int tag),
+
+ TP_ARGS(req, tag),
+
+ TP_STRUCT__entry(
+ __field( int, cid )
+ __field( __le64, result )
+ __field( u8, retries )
+ __field( u8, flags )
+ __field( u16, status )
+ ),
+
+ TP_fast_assign(
+ __entry->cid = tag;
+ __entry->result = req->result.u64;
+ __entry->retries = req->retries;
+ __entry->flags = req->flags;
+ __entry->status = req->status;
+ ),
+
+ TP_printk("command_id=%u, result=%llu, retries=%u, flags=0x%x, status=%u",
+ __entry->cid,
+ (unsigned long long)le64_to_cpu(__entry->result),
+ __entry->retries, __entry->flags, __entry->status)
+
+);
+
#endif /* _TRACE_NVME_H */

#undef TRACE_INCLUDE_PATH
--
2.12.3