nvmet: add async event tracing support
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Tue, 19 May 2020 08:06:30 +0000 (01:06 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 27 May 2020 05:12:38 +0000 (07:12 +0200)
This adds a new tracepoint for the target to trace async event. This is
helpful in debugging and comparing host and target side async events
especially when host is connected to different targets on different
machines and now that we rely on userspace components to generate AEN. 

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/core.c
drivers/nvme/target/trace.h

index b685f99..7ce3d3b 100644 (file)
@@ -151,6 +151,7 @@ static void nvmet_async_events_process(struct nvmet_ctrl *ctrl, u16 status)
                kfree(aen);
 
                mutex_unlock(&ctrl->lock);
+               trace_nvmet_async_event(ctrl, req->cqe->result.u32);
                nvmet_req_complete(req, status);
        }
 }
index e645caa..0458046 100644 (file)
@@ -130,6 +130,34 @@ TRACE_EVENT(nvmet_req_complete,
 
 );
 
+#define aer_name(aer) { aer, #aer }
+
+TRACE_EVENT(nvmet_async_event,
+       TP_PROTO(struct nvmet_ctrl *ctrl, __le32 result),
+       TP_ARGS(ctrl, result),
+       TP_STRUCT__entry(
+               __field(int, ctrl_id)
+               __field(u32, result)
+       ),
+       TP_fast_assign(
+               __entry->ctrl_id = ctrl->cntlid;
+               __entry->result = (le32_to_cpu(result) & 0xff00) >> 8;
+       ),
+       TP_printk("nvmet%d: NVME_AEN=%#08x [%s]",
+               __entry->ctrl_id, __entry->result,
+               __print_symbolic(__entry->result,
+               aer_name(NVME_AER_NOTICE_NS_CHANGED),
+               aer_name(NVME_AER_NOTICE_ANA),
+               aer_name(NVME_AER_NOTICE_FW_ACT_STARTING),
+               aer_name(NVME_AER_NOTICE_DISC_CHANGED),
+               aer_name(NVME_AER_ERROR),
+               aer_name(NVME_AER_SMART),
+               aer_name(NVME_AER_CSS),
+               aer_name(NVME_AER_VS))
+       )
+);
+#undef aer_name
+
 #endif /* _TRACE_NVMET_H */
 
 #undef TRACE_INCLUDE_PATH