Commit 5d87eb94 authored by Keith Busch's avatar Keith Busch Committed by Christoph Hellwig

nvme: use hw qid in trace events

We can not match a command to its completion based on the command
id alone. We need the submitting queue identifier to pair with the
completion, so this patch adds that to the trace buffer.

This patch is also collapsing the admin and IO submission traces into a
single one so we don't need to duplicate this and creating unnecessary
code branches: we know if the command is an admin vs IO based on the qid.

And since we're here, the patch fixes code formatting in the area.
Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
[hch: move the qid helper to nvme.h and made it an inline function]
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 59e29ce6
...@@ -652,10 +652,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, ...@@ -652,10 +652,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
} }
cmd->common.command_id = req->tag; cmd->common.command_id = req->tag;
if (ns) trace_nvme_setup_cmd(req, cmd);
trace_nvme_setup_nvm_cmd(req->q->id, cmd);
else
trace_nvme_setup_admin_cmd(cmd);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(nvme_setup_cmd); EXPORT_SYMBOL_GPL(nvme_setup_cmd);
......
...@@ -120,6 +120,13 @@ static inline struct nvme_request *nvme_req(struct request *req) ...@@ -120,6 +120,13 @@ static inline struct nvme_request *nvme_req(struct request *req)
return blk_mq_rq_to_pdu(req); return blk_mq_rq_to_pdu(req);
} }
static inline u16 nvme_req_qid(struct request *req)
{
if (!req->rq_disk)
return 0;
return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + 1;
}
/* The below value is the specific amount of delay needed before checking /* The below value is the specific amount of delay needed before checking
* readiness in case of the PCI_DEVICE(0x1c58, 0x0003), which needs the * readiness in case of the PCI_DEVICE(0x1c58, 0x0003), which needs the
* NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was * NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was
......
...@@ -50,13 +50,8 @@ ...@@ -50,13 +50,8 @@
nvme_admin_opcode_name(nvme_admin_security_recv), \ nvme_admin_opcode_name(nvme_admin_security_recv), \
nvme_admin_opcode_name(nvme_admin_sanitize_nvm)) nvme_admin_opcode_name(nvme_admin_sanitize_nvm))
const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode,
u8 *cdw10);
#define __parse_nvme_admin_cmd(opcode, cdw10) \
nvme_trace_parse_admin_cmd(p, opcode, cdw10)
#define nvme_opcode_name(opcode) { opcode, #opcode } #define nvme_opcode_name(opcode) { opcode, #opcode }
#define show_opcode_name(val) \ #define show_nvm_opcode_name(val) \
__print_symbolic(val, \ __print_symbolic(val, \
nvme_opcode_name(nvme_cmd_flush), \ nvme_opcode_name(nvme_cmd_flush), \
nvme_opcode_name(nvme_cmd_write), \ nvme_opcode_name(nvme_cmd_write), \
...@@ -70,83 +65,66 @@ const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode, ...@@ -70,83 +65,66 @@ const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode,
nvme_opcode_name(nvme_cmd_resv_acquire), \ nvme_opcode_name(nvme_cmd_resv_acquire), \
nvme_opcode_name(nvme_cmd_resv_release)) nvme_opcode_name(nvme_cmd_resv_release))
const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode, #define show_opcode_name(qid, opcode) \
u8 *cdw10); (qid ? show_nvm_opcode_name(opcode) : show_admin_opcode_name(opcode))
#define __parse_nvme_cmd(opcode, cdw10) \
nvme_trace_parse_nvm_cmd(p, opcode, cdw10)
TRACE_EVENT(nvme_setup_admin_cmd, const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode,
TP_PROTO(struct nvme_command *cmd), u8 *cdw10);
TP_ARGS(cmd), const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode,
TP_STRUCT__entry( u8 *cdw10);
__field(u8, opcode)
__field(u8, flags)
__field(u16, cid)
__field(u64, metadata)
__array(u8, cdw10, 24)
),
TP_fast_assign(
__entry->opcode = cmd->common.opcode;
__entry->flags = cmd->common.flags;
__entry->cid = cmd->common.command_id;
__entry->metadata = le64_to_cpu(cmd->common.metadata);
memcpy(__entry->cdw10, cmd->common.cdw10,
sizeof(__entry->cdw10));
),
TP_printk(" cmdid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)",
__entry->cid, __entry->flags, __entry->metadata,
show_admin_opcode_name(__entry->opcode),
__parse_nvme_admin_cmd(__entry->opcode, __entry->cdw10))
);
#define parse_nvme_cmd(qid, opcode, cdw10) \
(qid ? \
nvme_trace_parse_nvm_cmd(p, opcode, cdw10) : \
nvme_trace_parse_admin_cmd(p, opcode, cdw10))
TRACE_EVENT(nvme_setup_nvm_cmd, TRACE_EVENT(nvme_setup_cmd,
TP_PROTO(int qid, struct nvme_command *cmd), TP_PROTO(struct request *req, struct nvme_command *cmd),
TP_ARGS(qid, cmd), TP_ARGS(req, cmd),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(int, qid) __field(int, qid)
__field(u8, opcode) __field(u8, opcode)
__field(u8, flags) __field(u8, flags)
__field(u16, cid) __field(u16, cid)
__field(u32, nsid) __field(u32, nsid)
__field(u64, metadata) __field(u64, metadata)
__array(u8, cdw10, 24) __array(u8, cdw10, 24)
), ),
TP_fast_assign( TP_fast_assign(
__entry->qid = qid; __entry->qid = nvme_req_qid(req);
__entry->opcode = cmd->common.opcode; __entry->opcode = cmd->common.opcode;
__entry->flags = cmd->common.flags; __entry->flags = cmd->common.flags;
__entry->cid = cmd->common.command_id; __entry->cid = cmd->common.command_id;
__entry->nsid = le32_to_cpu(cmd->common.nsid); __entry->nsid = le32_to_cpu(cmd->common.nsid);
__entry->metadata = le64_to_cpu(cmd->common.metadata); __entry->metadata = le64_to_cpu(cmd->common.metadata);
memcpy(__entry->cdw10, cmd->common.cdw10, memcpy(__entry->cdw10, cmd->common.cdw10,
sizeof(__entry->cdw10)); sizeof(__entry->cdw10));
), ),
TP_printk("qid=%d, nsid=%u, cmdid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)", TP_printk("qid=%d, cmdid=%u, nsid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)",
__entry->qid, __entry->nsid, __entry->cid, __entry->qid, __entry->cid, __entry->nsid,
__entry->flags, __entry->metadata, __entry->flags, __entry->metadata,
show_opcode_name(__entry->opcode), show_opcode_name(__entry->qid, __entry->opcode),
__parse_nvme_cmd(__entry->opcode, __entry->cdw10)) parse_nvme_cmd(__entry->qid, __entry->opcode, __entry->cdw10))
); );
TRACE_EVENT(nvme_complete_rq, TRACE_EVENT(nvme_complete_rq,
TP_PROTO(struct request *req), TP_PROTO(struct request *req),
TP_ARGS(req), TP_ARGS(req),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(int, qid) __field(int, qid)
__field(int, cid) __field(int, cid)
__field(u64, result) __field(u64, result)
__field(u8, retries) __field(u8, retries)
__field(u8, flags) __field(u8, flags)
__field(u16, status) __field(u16, status)
), ),
TP_fast_assign( TP_fast_assign(
__entry->qid = req->q->id; __entry->qid = nvme_req_qid(req);
__entry->cid = req->tag; __entry->cid = req->tag;
__entry->result = le64_to_cpu(nvme_req(req)->result.u64); __entry->result = le64_to_cpu(nvme_req(req)->result.u64);
__entry->retries = nvme_req(req)->retries; __entry->retries = nvme_req(req)->retries;
__entry->flags = nvme_req(req)->flags; __entry->flags = nvme_req(req)->flags;
__entry->status = nvme_req(req)->status; __entry->status = nvme_req(req)->status;
), ),
TP_printk("qid=%d, cmdid=%u, res=%llu, retries=%u, flags=0x%x, status=%u", TP_printk("qid=%d, cmdid=%u, res=%llu, retries=%u, flags=0x%x, status=%u",
__entry->qid, __entry->cid, __entry->result, __entry->qid, __entry->cid, __entry->result,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment