Skip to contentSkip to conversation

nvme: add get-feature to admin cmds tracer

PATCH Superseded Max Gurtovoy 4 participants 9 messages Jan 31, 2019 – Feb 8, 2019 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

This will print get-feature cmd in more informative way. For example, run "nvme get-feature /dev/nvme0 -n 1 -f 0x9 -c 10" will trace:

nvme-3907 [008] .... 1763.635054: nvme_setup_cmd: nvme0: qid=0, cmdid=6, nsid=1, flags=0x0, meta=0x0, cmd=(nvme_admin_get_features fid=0x9 sel=0x0 cdw11=0xa)

<idle>-0     [001] d.h.  1763.635112: nvme_sq: nvme0: qid=0, head=27, tail=27
<idle>-0     [008] ..s.  1763.635121: nvme_complete_rq: nvme0: qid=0, cmdid=6, res=10, retries=0, flags=0x2, status=0
Signed-off-by Max Gurtovoy <maxg at mellanox.com>
---
 drivers/nvme/host/trace.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/nvme/host/trace.c +14 -0
index 5566dda..caa18bb 100644
@@ -58,7 +58,19 @@ static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10)
 	return ret;
 }
 
+static const char *nvme_trace_admin_get_features(struct trace_seq *p,
+						 u8 *cdw10)
+{
+	const char *ret = trace_seq_buffer_ptr(p);
+	u8 fid = cdw10[0];
+	u8 sel = cdw10[1];
+	u32 cdw11 = get_unaligned_le32(cdw10 + 4);
+
+	trace_seq_printf(p, "fid=0x%x sel=0x%x cdw11=0x%x", fid, sel, cdw11);
+	trace_seq_putc(p, 0);
 
+	return ret;
+}
 
 static const char *nvme_trace_read_write(struct trace_seq *p, u8 *cdw10)
 {
@@ -109,6 +121,8 @@ const char *nvme_trace_parse_admin_cmd(struct trace_seq *p,
 		return nvme_trace_create_cq(p, cdw10);
 	case nvme_admin_identify:
 		return nvme_trace_admin_identify(p, cdw10);
+	case nvme_admin_get_features:
+		return nvme_trace_admin_get_features(p, cdw10);
 	default:
 		return nvme_trace_common(p, cdw10);
 	}
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

drivers/nvme/host/trace.c static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10) · line 70

Quoted 10 lines · Max Gurtovoy
drivers/nvme/host/trace.c +10 -0
+static const char *nvme_trace_admin_get_features(struct trace_seq *p,
+						 u8 *cdw10)
+{
+	const char *ret = trace_seq_buffer_ptr(p);
+	u8 fid = cdw10[0];
+	u8 sel = cdw10[1];
+	u32 cdw11 = get_unaligned_le32(cdw10 + 4);
+
+	trace_seq_printf(p, "fid=0x%x sel=0x%x cdw11=0x%x", fid, sel, cdw11);
+	trace_seq_putc(p, 0);

The 'sel' field is technically 3 bits, so this decoding may have a forward compatibility problem if the commitee defines the upper bits to a different field. Of course we'd have to update any trace event if the spec changes in the future anyway.

So then maybe it would make more sense to *not* decode these things in the kernel and just print out raw dwords that can be piped to a user space utility for a more human friendly interpretation. Something like what blkparse does for block trace events. Does that sound okay, or do people really prefer having the kernel do this?

#2 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 7 lines · Keith Busch

drivers/nvme/host/trace.c static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10) · line 66

Quoted 6 lines · Max Gurtovoy
drivers/nvme/host/trace.c +6 -0
+static const char *nvme_trace_admin_get_features(struct trace_seq *p,
+						 u8 *cdw10)
+{
+	const char *ret = trace_seq_buffer_ptr(p);
+	u8 fid = cdw10[0];
+	u8 sel = cdw10[1];

u8 sel = cdw10[1] & 0x7;

Quoted 8 lines

drivers/nvme/host/trace.c static const char *nvme_trace_admin_identify(struct trace_seq *p, u8 *cdw10) · line 70

Quoted 4 lines
drivers/nvme/host/trace.c +4 -0
+	u32 cdw11 = get_unaligned_le32(cdw10 + 4);
+
+	trace_seq_printf(p, "fid=0x%x sel=0x%x cdw11=0x%x", fid, sel, cdw11);
+	trace_seq_putc(p, 0);

The 'sel' field is technically 3 bits, so this decoding may have a forward compatibility problem if the commitee defines the upper bits to a different field. Of course we'd have to update any trace event if the spec changes in the future anyway.

see above.

Quoted 6 lines

So then maybe it would make more sense to *not* decode these things in the kernel and just print out raw dwords that can be piped to a user space utility for a more human friendly interpretation. Something like what blkparse does for block trace events. Does that sound okay, or do people really prefer having the kernel do this?

Well, I guess that nvme-cli is the only common tool used by the majority of the community.

we can add something like "nvme trace-parse <raw-cmd>".

but this will open a various places to go wrong (and it will happen for sure).

Let's see what other guys think..

#3 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 11 lines · Max Gurtovoy
Quoted 7 lines · Keith Busch

Review

Quoted 6 lines · Max Gurtovoy
(quoted diff) +6 -0
+static const char *nvme_trace_admin_get_features(struct trace_seq *p,
+???????????????????????? u8 *cdw10)
+{
+??? const char *ret = trace_seq_buffer_ptr(p);
+??? u8 fid = cdw10[0];
+??? u8 sel = cdw10[1];

u8 sel = cdw10[1] & 0x7;

Yup

[...]

Quoted 9 lines

Well, I guess that nvme-cli is the only common tool used by the majority of the community.

we can add something like "nvme trace-parse <raw-cmd>".

but this will open a various places to go wrong (and it will happen for sure).

Let's see what other guys think..

I'm open for both sides, but we're already decoding a bunch of commands in the kernel and so does the SCSI tracing, so I don't see a compelling reason to stop it now.

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#4 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 19 lines · Johannes Thumshirn
Quoted 9 lines · Max Gurtovoy
Quoted 7 lines · Keith Busch

Review

Quoted 6 lines · Max Gurtovoy
(quoted diff) +6 -0
+static const char *nvme_trace_admin_get_features(struct trace_seq *p,
+???????????????????????? u8 *cdw10)
+{
+??? const char *ret = trace_seq_buffer_ptr(p);
+??? u8 fid = cdw10[0];
+??? u8 sel = cdw10[1];

u8 sel = cdw10[1] & 0x7;

Yup

[...]

Quoted 5 lines

Well, I guess that nvme-cli is the only common tool used by the majority of the community.

we can add something like "nvme trace-parse <raw-cmd>".

Quoted 7 lines
Quoted 4 lines

but this will open a various places to go wrong (and it will happen for sure).

Let's see what other guys think..

I'm open for both sides, but we're already decoding a bunch of commands in the kernel and so does the SCSI tracing, so I don't see a compelling reason to stop it now.

Yup, I also think we shouldn't throw all cmd decoding from kernel and we can add more decoding incrementally as I did in this commit.

Sagi/Christoph,

what is your standing in this topic ? should I send V2 ?

#5 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 10 lines · Max Gurtovoy
Quoted 3 lines

I'm open for both sides, but we're already decoding a bunch of commands in the kernel and so does the SCSI tracing, so I don't see a compelling reason to stop it now.

Yup, I also think we shouldn't throw all cmd decoding from kernel and we can add more decoding incrementally as I did in this commit.

Sagi/Christoph,

what is your standing in this topic ? should I send V2 ?

I don't really care. We clearly have command decoding in the trace points, so adding a little more won't hurt, but I'm also not sure we really need it.

#6 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 3 lines · Christoph Hellwig

I don't really care. We clearly have command decoding in the trace points, so adding a little more won't hurt, but I'm also not sure we really need it.

Hmm one thing, *iff* we want to decode the commands in user-space we have to agree on one input format for the decoder which then becomes an ABI (see for example blktrace). If we decode in the kernel we can easily extent it (like we already did with the tracepoints).

IMHO maintaining an ABI like format is a major pain in the lower body parts and the benefits from it aren't worth it.

Just my .2$.

Byte,
Johannes

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#7 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 5 lines · Johannes Thumshirn
Quoted 3 lines · Christoph Hellwig

I don't really care. We clearly have command decoding in the trace points, so adding a little more won't hurt, but I'm also not sure we really need it.

Quoted 7 lines

Hmm one thing, *iff* we want to decode the commands in user-space we have to agree on one input format for the decoder which then becomes an ABI (see for example blktrace). If we decode in the kernel we can easily extent it (like we already did with the tracepoints).

IMHO maintaining an ABI like format is a major pain in the lower body parts and the benefits from it aren't worth it.

That's fine, I certainly won't nak this and am okay to see this staged for the next merge window. I just wanted to confirm preference on maintaining the kernel vs tooling as the spec changes.

#8 lore raw

PATCH 1/1 nvme: add get-feature to admin cmds tracer

Quoted 3 lines · Keith Busch

That's fine, I certainly won't nak this and am okay to see this staged for the next merge window. I just wanted to confirm preference on maintaining the kernel vs tooling as the spec changes.

Sure and I'm not totally sure doing the decoding in the kernel as is should be carved in stone either.

I guess we have to revisit this decision some day in the future, possibly due to spec changes and so on.

Byte,
Johannes

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850