export trace.c helper functions to other modules
Subsystems (2)
PATCH v4 1/2 export trace.c helper functions to other modules
Export bellow three functions:nvme_trace_parse_admin_cmdnvme_trace_parse_nvm_cmdnvme_trace_disk_name
Thus any other modules which depends on nvme-core could use the trace events in trace.h
--- drivers/nvme/host/trace.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nvme/host/trace.c +3 -0
@@ -113,6 +113,7 @@ const char *nvme_trace_parse_admin_cmd(struct trace_seq *p,return nvme_trace_common (p, cdw10); } } +EXPORT_SYMBOL_GPL (nvme_trace_parse_admin_cmd);const char *nvme_trace_parse_nvm_cmd (struct trace_seq *p,u8 opcode,u8 *cdw10)
@@ -128,6 +129,7 @@ const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p,return nvme_trace_common (p, cdw10); } } +EXPORT_SYMBOL_GPL (nvme_trace_parse_nvm_cmd);const char *nvme_trace_disk_name (struct trace_seq *p,char *name) {
@@ -139,3 +141,4 @@ const char *nvme_trace_disk_name(struct trace_seq *p, char *name)return ret; } +EXPORT_SYMBOL_GPL (nvme_trace_disk_name);
Signature · 1 line
2.17.1
PATCH v4 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.
--- drivers/nvme/host/pci.c | 5 +++++ drivers/nvme/host/trace.c | 2 ++ drivers/nvme/host/trace.h | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+)
drivers/nvme/host/pci.c +5 -0
@@ -32,6 +32,7 @@#include <linux/sed-opal.h> #include <linux/pci-p2pdma.h> +#include "trace.h" #include "nvme.h" #define SQ_SIZE (depth) (depth * sizeof(struct nvme_command))
@@ -899,6 +900,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.c +2 -0
@@ -142,3 +142,5 @@ const char *nvme_trace_disk_name(struct trace_seq *p, char *name)return ret; }EXPORT_SYMBOL_GPL (nvme_trace_disk_name); + +EXPORT_TRACEPOINT_SYMBOL (nvme_sq);
drivers/nvme/host/trace.h +21 -0
@@ -184,6 +184,27 @@ TRACE_EVENT(nvme_async_event,#undef aer_name +TRACE_EVENT (nvme_sq, + TP_PROTO(void *rq_disk, int qid, int sq_head, int sq_tail), +TP_ARGS (rq_disk, qid, sq_head, sq_tail), +TP_STRUCT__entry ( + __array(char, disk, DISK_NAME_LEN) + __field(int, qid) + __field(int, sq_head) +__field (int, sq_tail) + ), +TP_fast_assign ( + __assign_disk_name(__entry->disk, rq_disk); + __entry->qid = qid; + __entry->sq_head = sq_head; + __entry->sq_tail = sq_tail; + ), +TP_printk ("nvme: %s qid=%d head=%d tail=%d" , +__print_disk_name (__entry->disk), + __entry->qid, __entry->sq_head, __entry->sq_tail + ) +); +#endif /* _TRACE_NVME_H */ #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.17.1
Re: [PATCH v4 2/2] trace nvme submit queue status
drivers/nvme/host/pci.c static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx) · line 906
Quoted 9 lines
drivers/nvme/host/pci.c +4
-0@@ -899,6 +900,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);
Why the newline escapes? why not escape at the 80 char border?
Other than that, looks fine,
Re: [PATCH v4 2/2] trace nvme submit queue status
Quoted 5 lines · Sagi Grimberg
Quoted 5 lines
(quoted diff) +0
-0@@ -899,6 +900,10 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx) }
Quoted 8 lines
drivers/nvme/host/pci.c static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx) · line 906
Quoted 5 lines
drivers/nvme/host/pci.c +4
-0req =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);Why the newline escapes? why not escape at the 80 char border?
Sorry, I don't quite understand your meaning. Do you mean I'd better change this:
trace_nvme_sq(req->rq_disk,
nvmeq->qid,
le16_to_cpu(cqe->sq_head),
nvmeq->sq_tail);
to something like below:
trace_nvme_sq(req->rq_disk, nvmeq->qid, le16_to_cpu(cqe->sq_head),
nvmeq->sq_tail);Please let me know whether my understanding is correct.
Christoph Hellwig
maintainerRe: [PATCH v4 2/2] trace nvme submit queue status
Quoted 10 lines · peng yu
Sorry, I don't quite understand your meaning. Do you mean I'd better change this:
trace_nvme_sq(req->rq_disk, nvmeq->qid, le16_to_cpu(cqe->sq_head), nvmeq->sq_tail); to something like below: trace_nvme_sq(req->rq_disk, nvmeq->qid, le16_to_cpu(cqe->sq_head), nvmeq->sq_tail);Please let me know whether my understanding is correct.
Yes. Let me know if this version that I've applied is fine with you:
http://git.infradead.org/nvme.git/commitdiff/ed537628e59166a080d618825a7d175565a9cad4
Re: [PATCH v4 2/2] trace nvme submit queue status
In reply to yupengQuoted 7 lines · yupeng
drivers/nvme/host/trace.h +7
-0+TRACE_EVENT(nvme_sq, + TP_PROTO(void *rq_disk, int qid, int sq_head, int sq_tail), + TP_ARGS(rq_disk, qid, sq_head, sq_tail), + TP_STRUCT__entry( + __array(char, disk, DISK_NAME_LEN) + __field(int, qid) + __field(int, sq_head)
drivers/nvme/host/trace.h TRACE_EVENT(nvme_async_event, · line 203
Quoted 10 lines
drivers/nvme/host/trace.h +10
-0+__field (int, sq_tail) + ), +TP_fast_assign ( + __assign_disk_name(__entry->disk, rq_disk); + __entry->qid = qid; + __entry->sq_head = sq_head; + __entry->sq_tail = sq_tail; + ), + TP_printk("nvme: %s qid=%d head=%d tail=%d", + __print_disk_name(__entry->disk),
No need for a space after the %s. __print_disk_name already appends a space if there's a disk name, and we don't want the extra space if there isn't one. Also, every other nvme trace has a ',' after each entry. Not a big deal, just minor format consistency.
[email protected]
maintainerRe: [PATCH v4 2/2] trace nvme submit queue status
Quoted 4 lines · Keith Busch
No need for a space after the %s.
__print_disk_namealready appends a space if there's a disk name, and we don't want the extra space if there isn't one. Also, every other nvme trace has a ',' after each entry. Not a big deal, just minor format consistency.
Yeah. What about something like this incremental patch to make the trace formatting and argument passing match what we otherwise do:
drivers/nvme/host/pci.c +1 -2
@@ -1004,8 +1004,7 @@ 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); +trace_nvme_sq (req, cqe->sq_head, nvmeq->sq_tail);nvme_end_request (req, cqe->status, cqe->result); }
drivers/nvme/host/trace.h +11 -9
@@ -185,22 +185,24 @@ TRACE_EVENT(nvme_async_event,#undef aer_nameTRACE_EVENT (nvme_sq, - TP_PROTO(void *rq_disk, int qid, int sq_head, int sq_tail), -TP_ARGS (rq_disk, qid, sq_head, sq_tail), + TP_PROTO(struct request *req, __le16 sq_head, int sq_tail), +TP_ARGS (req, sq_head, sq_tail),TP_STRUCT__entry ( + __field(int, ctrl_id) __array(char, disk, DISK_NAME_LEN) __field(int, qid) - __field(int, sq_head) -__field (int, sq_tail) + __field(u16, sq_head) +__field (u16, sq_tail) ),TP_fast_assign ( - __assign_disk_name(__entry->disk, rq_disk); - __entry->qid = qid; - __entry->sq_head = sq_head; + __entry->ctrl_id = nvme_req(req)->ctrl->instance; + __assign_disk_name(__entry->disk, req->rq_disk); + __entry->qid = nvme_req_qid(req); + __entry->sq_head = le16_to_cpu(sq_head); __entry->sq_tail = sq_tail; ), -TP_printk ("nvme: %s qid=%d head=%d tail=%d" , -__print_disk_name (__entry->disk), +TP_printk ("nvme%d: %sqid=%d, head=%u, tail=%u" , + __entry->ctrl_id,__print_disk_name (__entry->disk), __entry->qid, __entry->sq_head, __entry->sq_tail ) );
Keith Busch
Reviewed-byRe: [PATCH v4 2/2] trace nvme submit queue status
Quoted 8 lines · On Tue, Dec 18, 2018@06:47:50PM +0100, [email protected] wrote:
Quoted 4 lines · Keith Busch
No need for a space after the %s.
__print_disk_namealready appends a space if there's a disk name, and we don't want the extra space if there isn't one. Also, every other nvme trace has a ',' after each entry. Not a big deal, just minor format consistency.Yeah. What about something like this incremental patch to make the trace formatting and argument passing match what we otherwise do:
Nice, that looks good. It's also necessary for admin commands since there was no other way to see which controller a completion came from without this.
Quoted 52 lines
drivers/nvme/host/pci.c +1
-2@@ -1004,8 +1004,7 @@ 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); +trace_nvme_sq (req, cqe->sq_head, nvmeq->sq_tail);nvme_end_request (req, cqe->status, cqe->result); }drivers/nvme/host/trace.h +11
-9@@ -185,22 +185,24 @@ TRACE_EVENT(nvme_async_event,#undef aer_nameTRACE_EVENT (nvme_sq, - TP_PROTO(void *rq_disk, int qid, int sq_head, int sq_tail), -TP_ARGS (rq_disk, qid, sq_head, sq_tail), + TP_PROTO(struct request *req, __le16 sq_head, int sq_tail), +TP_ARGS (req, sq_head, sq_tail),TP_STRUCT__entry ( + __field(int, ctrl_id) __array(char, disk, DISK_NAME_LEN) __field(int, qid) - __field(int, sq_head) -__field (int, sq_tail) + __field(u16, sq_head) +__field (u16, sq_tail) ),TP_fast_assign ( - __assign_disk_name(__entry->disk, rq_disk); - __entry->qid = qid; - __entry->sq_head = sq_head; + __entry->ctrl_id = nvme_req(req)->ctrl->instance; + __assign_disk_name(__entry->disk, req->rq_disk); + __entry->qid = nvme_req_qid(req); + __entry->sq_head = le16_to_cpu(sq_head); __entry->sq_tail = sq_tail; ), -TP_printk ("nvme: %s qid=%d head=%d tail=%d" , -__print_disk_name (__entry->disk), +TP_printk ("nvme%d: %sqid=%d, head=%u, tail=%u" , + __entry->ctrl_id,__print_disk_name (__entry->disk), __entry->qid, __entry->sq_head, __entry->sq_tail ) );
Re: [PATCH v4 2/2] trace nvme submit queue status
In reply to [email protected]Quoted 42 lines · On Tue, Dec 18, 2018@9:47 AM [email protected] <[email protected]> wrote:
drivers/nvme/host/pci.c +1
-2@@ -1004,8 +1004,7 @@ 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); +trace_nvme_sq (req, cqe->sq_head, nvmeq->sq_tail);nvme_end_request (req, cqe->status, cqe->result); }drivers/nvme/host/trace.h +8
-7@@ -185,22 +185,24 @@ TRACE_EVENT(nvme_async_event,#undef aer_name TRACE_EVENT(nvme_sq, - TP_PROTO(void *rq_disk, int qid, int sq_head, int sq_tail), - TP_ARGS(rq_disk, qid, sq_head, sq_tail), + TP_PROTO(struct request *req, __le16 sq_head, int sq_tail), + TP_ARGS(req, sq_head, sq_tail), TP_STRUCT__entry( + __field(int, ctrl_id) __array(char, disk, DISK_NAME_LEN) __field(int, qid) - __field(int, sq_head) - __field(int, sq_tail) + __field(u16, sq_head) + __field(u16, sq_tail) ), TP_fast_assign( - __assign_disk_name(__entry->disk, rq_disk); - __entry->qid = qid; - __entry->sq_head = sq_head; + __entry->ctrl_id = nvme_req(req)->ctrl->instance; + __assign_disk_name(__entry->disk, req->rq_disk); + __entry->qid = nvme_req_qid(req);
drivers/nvme/host/trace.h TRACE_EVENT(nvme_async_event, · line 208
Quoted 10 lines
drivers/nvme/host/trace.h +3
-2+ __entry->sq_head =le16_to_cpu (sq_head); __entry->sq_tail = sq_tail; ), -TP_printk ("nvme: %s qid=%d head=%d tail=%d" , -__print_disk_name (__entry->disk), +TP_printk ("nvme%d: %sqid=%d, head=%u, tail=%u" , + __entry->ctrl_id,__print_disk_name (__entry->disk), __entry->qid, __entry->sq_head, __entry->sq_tail ) );
I think this change is nice. Will you submit this change or are you suggesting me to do it?
[email protected]
maintainerRe: [PATCH v4 2/2] trace nvme submit queue status
Quoted 2 lines · peng yu
I think this change is nice. Will you submit this change or are you suggesting me to do it?
I've folded the changes in.
Christoph Hellwig
maintainerQuoted 6 lines · yupeng
Export bellow three functions:
nvme_trace_parse_admin_cmdnvme_trace_parse_nvm_cmdnvme_trace_disk_name
Thus any other modules which depends on nvme-core could use the trace events intrace.h
But we don't actually use these trace events anywhere outside of core.c, even with your second patch, do we?
Christoph Hellwig
maintainerQuoted 10 lines · Christoph Hellwig
Quoted 6 lines · yupeng
Export bellow three functions:
nvme_trace_parse_admin_cmdnvme_trace_parse_nvm_cmdnvme_trace_disk_name
Thus any other modules which depends on nvme-core could use the trace events intrace.h
Quoted 2 lines
But we don't actually use these trace events anywhere outside of
core.c, even with your second patch, do we?
Except for nvme_trace_disk_name, which is used via __print_disk_name.