diff options
author | Johannes Thumshirn <jthumshirn@suse.de> | 2018-01-26 05:21:37 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-01-26 06:34:40 -0500 |
commit | 3d030e41d96f46c14faf79f19c3cf1b9961815c8 (patch) | |
tree | 4a7dbb948f812b13ae0c73f9dce9f1d784cdac91 | |
parent | ad70062cdb4002c74db4fbed4e2b34daffccacc2 (diff) |
nvme: add tracepoint for nvme_setup_cmd
Add tracepoints for nvme_setup_cmd() for tracing admin and/or nvm commands.
Examples of the two tracepoints are as follows for trace_nvme_setup_admin_cmd():
kworker/u8:0-5 [003] .... 2.998792: nvme_setup_admin_cmd: cmdid=14, flags=0x0, meta=0x0, cmd=(nvme_admin_create_cq cqid=1, qsize=1023, cq_flags=0x3, irq_vector=0)
and trace_nvme_setup_nvm_cmd():
dd-205 [001] .... 3.503929: nvme_setup_nvm_cmd: qid=1, nsid=1, cmdid=989, flags=0x0, meta=0x0, cmd=(nvme_cmd_read slba=4096, len=2047, ctrl=0x0, dsmgmt=0, reftag=0)
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | drivers/nvme/host/Makefile | 4 | ||||
-rw-r--r-- | drivers/nvme/host/core.c | 7 | ||||
-rw-r--r-- | drivers/nvme/host/trace.c | 130 | ||||
-rw-r--r-- | drivers/nvme/host/trace.h | 140 |
4 files changed, 281 insertions, 0 deletions
diff --git a/drivers/nvme/host/Makefile b/drivers/nvme/host/Makefile index a25fd43650ad..441e67e3a9d7 100644 --- a/drivers/nvme/host/Makefile +++ b/drivers/nvme/host/Makefile | |||
@@ -1,4 +1,7 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | |||
3 | ccflags-y += -I$(src) | ||
4 | |||
2 | obj-$(CONFIG_NVME_CORE) += nvme-core.o | 5 | obj-$(CONFIG_NVME_CORE) += nvme-core.o |
3 | obj-$(CONFIG_BLK_DEV_NVME) += nvme.o | 6 | obj-$(CONFIG_BLK_DEV_NVME) += nvme.o |
4 | obj-$(CONFIG_NVME_FABRICS) += nvme-fabrics.o | 7 | obj-$(CONFIG_NVME_FABRICS) += nvme-fabrics.o |
@@ -6,6 +9,7 @@ obj-$(CONFIG_NVME_RDMA) += nvme-rdma.o | |||
6 | obj-$(CONFIG_NVME_FC) += nvme-fc.o | 9 | obj-$(CONFIG_NVME_FC) += nvme-fc.o |
7 | 10 | ||
8 | nvme-core-y := core.o | 11 | nvme-core-y := core.o |
12 | nvme-core-$(CONFIG_TRACING) += trace.o | ||
9 | nvme-core-$(CONFIG_NVME_MULTIPATH) += multipath.o | 13 | nvme-core-$(CONFIG_NVME_MULTIPATH) += multipath.o |
10 | nvme-core-$(CONFIG_NVM) += lightnvm.o | 14 | nvme-core-$(CONFIG_NVM) += lightnvm.o |
11 | 15 | ||
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 63c2c469112d..f1430ca79a5b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
@@ -29,6 +29,9 @@ | |||
29 | #include <linux/pm_qos.h> | 29 | #include <linux/pm_qos.h> |
30 | #include <asm/unaligned.h> | 30 | #include <asm/unaligned.h> |
31 | 31 | ||
32 | #define CREATE_TRACE_POINTS | ||
33 | #include "trace.h" | ||
34 | |||
32 | #include "nvme.h" | 35 | #include "nvme.h" |
33 | #include "fabrics.h" | 36 | #include "fabrics.h" |
34 | 37 | ||
@@ -628,6 +631,10 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, | |||
628 | } | 631 | } |
629 | 632 | ||
630 | cmd->common.command_id = req->tag; | 633 | cmd->common.command_id = req->tag; |
634 | if (ns) | ||
635 | trace_nvme_setup_nvm_cmd(req->q->id, cmd); | ||
636 | else | ||
637 | trace_nvme_setup_admin_cmd(cmd); | ||
631 | return ret; | 638 | return ret; |
632 | } | 639 | } |
633 | EXPORT_SYMBOL_GPL(nvme_setup_cmd); | 640 | EXPORT_SYMBOL_GPL(nvme_setup_cmd); |
diff --git a/drivers/nvme/host/trace.c b/drivers/nvme/host/trace.c new file mode 100644 index 000000000000..41944bbef835 --- /dev/null +++ b/drivers/nvme/host/trace.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * NVM Express device driver tracepoints | ||
3 | * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | ||
14 | |||
15 | #include <asm/unaligned.h> | ||
16 | #include "trace.h" | ||
17 | |||
18 | static const char *nvme_trace_create_sq(struct trace_seq *p, u8 *cdw10) | ||
19 | { | ||
20 | const char *ret = trace_seq_buffer_ptr(p); | ||
21 | u16 sqid = get_unaligned_le16(cdw10); | ||
22 | u16 qsize = get_unaligned_le16(cdw10 + 2); | ||
23 | u16 sq_flags = get_unaligned_le16(cdw10 + 4); | ||
24 | u16 cqid = get_unaligned_le16(cdw10 + 6); | ||
25 | |||
26 | |||
27 | trace_seq_printf(p, "sqid=%u, qsize=%u, sq_flags=0x%x, cqid=%u", | ||
28 | sqid, qsize, sq_flags, cqid); | ||
29 | trace_seq_putc(p, 0); | ||
30 | |||
31 | return ret; | ||
32 | } | ||
33 | |||
34 | static const char *nvme_trace_create_cq(struct trace_seq *p, u8 *cdw10) | ||
35 | { | ||
36 | const char *ret = trace_seq_buffer_ptr(p); | ||
37 | u16 cqid = get_unaligned_le16(cdw10); | ||
38 | u16 qsize = get_unaligned_le16(cdw10 + 2); | ||
39 | u16 cq_flags = get_unaligned_le16(cdw10 + 4); | ||
40 | u16 irq_vector = get_unaligned_le16(cdw10 + 6); | ||
41 | |||
42 | trace_seq_printf(p, "cqid=%u, qsize=%u, cq_flags=0x%x, irq_vector=%u", | ||
43 | cqid, qsize, cq_flags, irq_vector); | ||
44 | trace_seq_putc(p, 0); | ||
45 | |||
46 | return ret; | ||
47 | } | ||
48 | |||
49 | static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10) | ||
50 | { | ||
51 | const char *ret = trace_seq_buffer_ptr(p); | ||
52 | u8 cns = cdw10[0]; | ||
53 | u16 ctrlid = get_unaligned_le16(cdw10 + 2); | ||
54 | |||
55 | trace_seq_printf(p, "cns=%u, ctrlid=%u", cns, ctrlid); | ||
56 | trace_seq_putc(p, 0); | ||
57 | |||
58 | return ret; | ||
59 | } | ||
60 | |||
61 | |||
62 | |||
63 | static const char *nvme_trace_read_write(struct trace_seq *p, u8 *cdw10) | ||
64 | { | ||
65 | const char *ret = trace_seq_buffer_ptr(p); | ||
66 | u64 slba = get_unaligned_le64(cdw10); | ||
67 | u16 length = get_unaligned_le16(cdw10 + 8); | ||
68 | u16 control = get_unaligned_le16(cdw10 + 10); | ||
69 | u32 dsmgmt = get_unaligned_le32(cdw10 + 12); | ||
70 | u32 reftag = get_unaligned_le32(cdw10 + 16); | ||
71 | |||
72 | trace_seq_printf(p, | ||
73 | "slba=%llu, len=%u, ctrl=0x%x, dsmgmt=%u, reftag=%u", | ||
74 | slba, length, control, dsmgmt, reftag); | ||
75 | trace_seq_putc(p, 0); | ||
76 | |||
77 | return ret; | ||
78 | } | ||
79 | |||
80 | static const char *nvme_trace_dsm(struct trace_seq *p, u8 *cdw10) | ||
81 | { | ||
82 | const char *ret = trace_seq_buffer_ptr(p); | ||
83 | |||
84 | trace_seq_printf(p, "nr=%u, attributes=%u", | ||
85 | get_unaligned_le32(cdw10), | ||
86 | get_unaligned_le32(cdw10 + 4)); | ||
87 | trace_seq_putc(p, 0); | ||
88 | |||
89 | return ret; | ||
90 | } | ||
91 | |||
92 | static const char *nvme_trace_common(struct trace_seq *p, u8 *cdw10) | ||
93 | { | ||
94 | const char *ret = trace_seq_buffer_ptr(p); | ||
95 | |||
96 | trace_seq_printf(p, "cdw10=%*ph", 24, cdw10); | ||
97 | trace_seq_putc(p, 0); | ||
98 | |||
99 | return ret; | ||
100 | } | ||
101 | |||
102 | const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, | ||
103 | u8 opcode, u8 *cdw10) | ||
104 | { | ||
105 | switch (opcode) { | ||
106 | case nvme_admin_create_sq: | ||
107 | return nvme_trace_create_sq(p, cdw10); | ||
108 | case nvme_admin_create_cq: | ||
109 | return nvme_trace_create_cq(p, cdw10); | ||
110 | case nvme_admin_identify: | ||
111 | return nvme_trace_admin_identify(p, cdw10); | ||
112 | default: | ||
113 | return nvme_trace_common(p, cdw10); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, | ||
118 | u8 opcode, u8 *cdw10) | ||
119 | { | ||
120 | switch (opcode) { | ||
121 | case nvme_cmd_read: | ||
122 | case nvme_cmd_write: | ||
123 | case nvme_cmd_write_zeroes: | ||
124 | return nvme_trace_read_write(p, cdw10); | ||
125 | case nvme_cmd_dsm: | ||
126 | return nvme_trace_dsm(p, cdw10); | ||
127 | default: | ||
128 | return nvme_trace_common(p, cdw10); | ||
129 | } | ||
130 | } | ||
diff --git a/drivers/nvme/host/trace.h b/drivers/nvme/host/trace.h new file mode 100644 index 000000000000..feadf0b57d17 --- /dev/null +++ b/drivers/nvme/host/trace.h | |||
@@ -0,0 +1,140 @@ | |||
1 | /* | ||
2 | * NVM Express device driver tracepoints | ||
3 | * Copyright (c) 2018 Johannes Thumshirn, SUSE Linux GmbH | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | */ | ||
14 | |||
15 | #undef TRACE_SYSTEM | ||
16 | #define TRACE_SYSTEM nvme | ||
17 | |||
18 | #if !defined(_TRACE_NVME_H) || defined(TRACE_HEADER_MULTI_READ) | ||
19 | #define _TRACE_NVME_H | ||
20 | |||
21 | #include <linux/nvme.h> | ||
22 | #include <linux/tracepoint.h> | ||
23 | #include <linux/trace_seq.h> | ||
24 | |||
25 | #include "nvme.h" | ||
26 | |||
27 | #define nvme_admin_opcode_name(opcode) { opcode, #opcode } | ||
28 | #define show_admin_opcode_name(val) \ | ||
29 | __print_symbolic(val, \ | ||
30 | nvme_admin_opcode_name(nvme_admin_delete_sq), \ | ||
31 | nvme_admin_opcode_name(nvme_admin_create_sq), \ | ||
32 | nvme_admin_opcode_name(nvme_admin_get_log_page), \ | ||
33 | nvme_admin_opcode_name(nvme_admin_delete_cq), \ | ||
34 | nvme_admin_opcode_name(nvme_admin_create_cq), \ | ||
35 | nvme_admin_opcode_name(nvme_admin_identify), \ | ||
36 | nvme_admin_opcode_name(nvme_admin_abort_cmd), \ | ||
37 | nvme_admin_opcode_name(nvme_admin_set_features), \ | ||
38 | nvme_admin_opcode_name(nvme_admin_get_features), \ | ||
39 | nvme_admin_opcode_name(nvme_admin_async_event), \ | ||
40 | nvme_admin_opcode_name(nvme_admin_ns_mgmt), \ | ||
41 | nvme_admin_opcode_name(nvme_admin_activate_fw), \ | ||
42 | nvme_admin_opcode_name(nvme_admin_download_fw), \ | ||
43 | nvme_admin_opcode_name(nvme_admin_ns_attach), \ | ||
44 | nvme_admin_opcode_name(nvme_admin_keep_alive), \ | ||
45 | nvme_admin_opcode_name(nvme_admin_directive_send), \ | ||
46 | nvme_admin_opcode_name(nvme_admin_directive_recv), \ | ||
47 | nvme_admin_opcode_name(nvme_admin_dbbuf), \ | ||
48 | nvme_admin_opcode_name(nvme_admin_format_nvm), \ | ||
49 | nvme_admin_opcode_name(nvme_admin_security_send), \ | ||
50 | nvme_admin_opcode_name(nvme_admin_security_recv), \ | ||
51 | nvme_admin_opcode_name(nvme_admin_sanitize_nvm)) | ||
52 | |||
53 | const char *nvme_trace_parse_admin_cmd(struct trace_seq *p, u8 opcode, | ||
54 | u8 *cdw10); | ||
55 | #define __parse_nvme_admin_cmd(opcode, cdw10) \ | ||
56 | nvme_trace_parse_admin_cmd(p, opcode, cdw10) | ||
57 | |||
58 | #define nvme_opcode_name(opcode) { opcode, #opcode } | ||
59 | #define show_opcode_name(val) \ | ||
60 | __print_symbolic(val, \ | ||
61 | nvme_opcode_name(nvme_cmd_flush), \ | ||
62 | nvme_opcode_name(nvme_cmd_write), \ | ||
63 | nvme_opcode_name(nvme_cmd_read), \ | ||
64 | nvme_opcode_name(nvme_cmd_write_uncor), \ | ||
65 | nvme_opcode_name(nvme_cmd_compare), \ | ||
66 | nvme_opcode_name(nvme_cmd_write_zeroes), \ | ||
67 | nvme_opcode_name(nvme_cmd_dsm), \ | ||
68 | nvme_opcode_name(nvme_cmd_resv_register), \ | ||
69 | nvme_opcode_name(nvme_cmd_resv_report), \ | ||
70 | nvme_opcode_name(nvme_cmd_resv_acquire), \ | ||
71 | nvme_opcode_name(nvme_cmd_resv_release)) | ||
72 | |||
73 | const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode, | ||
74 | u8 *cdw10); | ||
75 | #define __parse_nvme_cmd(opcode, cdw10) \ | ||
76 | nvme_trace_parse_nvm_cmd(p, opcode, cdw10) | ||
77 | |||
78 | TRACE_EVENT(nvme_setup_admin_cmd, | ||
79 | TP_PROTO(struct nvme_command *cmd), | ||
80 | TP_ARGS(cmd), | ||
81 | TP_STRUCT__entry( | ||
82 | __field(u8, opcode) | ||
83 | __field(u8, flags) | ||
84 | __field(u16, cid) | ||
85 | __field(u64, metadata) | ||
86 | __array(u8, cdw10, 24) | ||
87 | ), | ||
88 | TP_fast_assign( | ||
89 | __entry->opcode = cmd->common.opcode; | ||
90 | __entry->flags = cmd->common.flags; | ||
91 | __entry->cid = cmd->common.command_id; | ||
92 | __entry->metadata = le64_to_cpu(cmd->common.metadata); | ||
93 | memcpy(__entry->cdw10, cmd->common.cdw10, | ||
94 | sizeof(__entry->cdw10)); | ||
95 | ), | ||
96 | TP_printk(" cmdid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)", | ||
97 | __entry->cid, __entry->flags, __entry->metadata, | ||
98 | show_admin_opcode_name(__entry->opcode), | ||
99 | __parse_nvme_admin_cmd(__entry->opcode, __entry->cdw10)) | ||
100 | ); | ||
101 | |||
102 | |||
103 | TRACE_EVENT(nvme_setup_nvm_cmd, | ||
104 | TP_PROTO(int qid, struct nvme_command *cmd), | ||
105 | TP_ARGS(qid, cmd), | ||
106 | TP_STRUCT__entry( | ||
107 | __field(int, qid) | ||
108 | __field(u8, opcode) | ||
109 | __field(u8, flags) | ||
110 | __field(u16, cid) | ||
111 | __field(u32, nsid) | ||
112 | __field(u64, metadata) | ||
113 | __array(u8, cdw10, 24) | ||
114 | ), | ||
115 | TP_fast_assign( | ||
116 | __entry->qid = qid; | ||
117 | __entry->opcode = cmd->common.opcode; | ||
118 | __entry->flags = cmd->common.flags; | ||
119 | __entry->cid = cmd->common.command_id; | ||
120 | __entry->nsid = le32_to_cpu(cmd->common.nsid); | ||
121 | __entry->metadata = le64_to_cpu(cmd->common.metadata); | ||
122 | memcpy(__entry->cdw10, cmd->common.cdw10, | ||
123 | sizeof(__entry->cdw10)); | ||
124 | ), | ||
125 | TP_printk("qid=%d, nsid=%u, cmdid=%u, flags=0x%x, meta=0x%llx, cmd=(%s %s)", | ||
126 | __entry->qid, __entry->nsid, __entry->cid, | ||
127 | __entry->flags, __entry->metadata, | ||
128 | show_opcode_name(__entry->opcode), | ||
129 | __parse_nvme_cmd(__entry->opcode, __entry->cdw10)) | ||
130 | ); | ||
131 | |||
132 | #endif /* _TRACE_NVME_H */ | ||
133 | |||
134 | #undef TRACE_INCLUDE_PATH | ||
135 | #define TRACE_INCLUDE_PATH . | ||
136 | #undef TRACE_INCLUDE_FILE | ||
137 | #define TRACE_INCLUDE_FILE trace | ||
138 | |||
139 | /* This part must be outside protection */ | ||
140 | #include <trace/define_trace.h> | ||