Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp484084imm; Fri, 29 Jun 2018 00:58:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzJJc7PgSNEcGqKLJQZLsywqjchHwpGlqQgMR4PpVRJ1SuMXegKqQufJ/IwCwboTLbsrvW X-Received: by 2002:a17:902:9b82:: with SMTP id y2-v6mr13906285plp.69.1530259101441; Fri, 29 Jun 2018 00:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530259101; cv=none; d=google.com; s=arc-20160816; b=ZgUx8+xfW40xdVOy+gTvryehqsfFVWCLay2ksMpHrBuXXoKMKl32hfru5dfEd3wcS0 KCx24/G62Ssk2S3AIBvdDl7QSaa8doo/eEdXiCLX2kUNGlJ7KpWy2jmjgSMOU6AKleAw PyT/yelTbqxx+dUVLfCgdqTXNQaPKk14++1s3c99kQ2yNnP2YK5JFdruiNhxl1KDDKwe ujeiti/lkO0nUgGSpfjfSlcQ+wEX8RED8w2n6clRWCSYfYHSrnSwbc+65ipA5iAqNm67 RnFbIQBPdHV68ftt5fh6Gg6wb2fo0u1+pIKuX3oQRhTNvqmsjVCZ+tKFMXq8EL+hKR3Z sTDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=O493GVmjv69zMHpZIRleXs5Dsyr2hmndx2blhq5TeH0=; b=vG+lNQeA0PuF64ji0AzsshjV6g7xUxYmQF/c18UvU2uL5gcCkpYusabtjeP1hto4SG pjgB8Ty4JQDuNSktCN1U/MqqtDAOF6VSPS/daymSvT7AYzsqtnjr6poSDxcTIBUjWLRy bYuQSORqbte67ZV9JdkLfN+WyePDN43fddZlULPCqL/09hdItqaDkqXf6eUFxkutTOzs GkmENLNReeyr9ubYvifmzOhAgsrH+uokw90GYN22xFugGRPCQzyEMErkXdaT8l1AFEqz qY9uzhdaj3+r2jnO7RDp4QrYOciU5a+ctJwin5K9MhC2JWf/mT35I3DtU+ZznCZpMIle tvpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15-v6si8752094pfc.320.2018.06.29.00.58.07; Fri, 29 Jun 2018 00:58:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934252AbeF2H50 (ORCPT + 99 others); Fri, 29 Jun 2018 03:57:26 -0400 Received: from verein.lst.de ([213.95.11.211]:52864 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933885AbeF2H5Z (ORCPT ); Fri, 29 Jun 2018 03:57:25 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id C498C68C4E; Fri, 29 Jun 2018 09:57:29 +0200 (CEST) Date: Fri, 29 Jun 2018 09:57:29 +0200 From: Christoph Hellwig To: Keith Busch Cc: Johannes Thumshirn , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 1/4] nvme: trace nvme queue identifiers Message-ID: <20180629075729.GA13413@lst.de> References: <20180628214956.13877-1-keith.busch@intel.com> <20180628214956.13877-2-keith.busch@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180628214956.13877-2-keith.busch@intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 03:49:53PM -0600, Keith Busch wrote: > We can not match a command to its completion based on the command id > alone. We need the submitting queue identifier to pair 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 since we don't need to duplicate this and creating > unnecessary code branches. > > Signed-off-by: Keith Busch > --- > drivers/nvme/host/core.c | 7 +++---- > drivers/nvme/host/trace.h | 41 ++++++++++------------------------------- > 2 files changed, 13 insertions(+), 35 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 46df030b2c3f..398a5fb26603 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -97,6 +97,8 @@ static dev_t nvme_chr_devt; > static struct class *nvme_class; > static struct class *nvme_subsys_class; > > +static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl, > + unsigned nsid); Huh? > static void nvme_ns_remove(struct nvme_ns *ns); > static int nvme_revalidate_disk(struct gendisk *disk); > static void nvme_put_subsystem(struct nvme_subsystem *subsys); > @@ -652,10 +654,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, > } > > cmd->common.command_id = req->tag; > - if (ns) > - trace_nvme_setup_nvm_cmd(req->q->id, cmd); > - else > - trace_nvme_setup_admin_cmd(cmd); > + trace_nvme_setup_nvm_cmd(req, cmd); > return ret; > } > EXPORT_SYMBOL_GPL(nvme_setup_cmd); > diff --git a/drivers/nvme/host/trace.h b/drivers/nvme/host/trace.h > index 01390f0e1671..42c99445dd96 100644 > --- a/drivers/nvme/host/trace.h > +++ b/drivers/nvme/host/trace.h > @@ -75,34 +75,9 @@ const char *nvme_trace_parse_nvm_cmd(struct trace_seq *p, u8 opcode, > #define __parse_nvme_cmd(opcode, cdw10) \ > nvme_trace_parse_nvm_cmd(p, opcode, cdw10) > > -TRACE_EVENT(nvme_setup_admin_cmd, > - TP_PROTO(struct nvme_command *cmd), > - TP_ARGS(cmd), > - TP_STRUCT__entry( > - __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)) > -); > - > - > TRACE_EVENT(nvme_setup_nvm_cmd, > - TP_PROTO(int qid, struct nvme_command *cmd), > - TP_ARGS(qid, cmd), > + TP_PROTO(struct request *req, struct nvme_command *cmd), > + TP_ARGS(req, cmd), > TP_STRUCT__entry( > __field(int, qid) > __field(u8, opcode) > @@ -113,7 +88,7 @@ TRACE_EVENT(nvme_setup_nvm_cmd, > __array(u8, cdw10, 24) > ), > TP_fast_assign( > - __entry->qid = qid; > + __entry->qid = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + !!req->rq_disk; This looks pretty ugly. I'd much prefer: if (req->rq_disk) __entry->qid = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)); else __entry->qid = 0; Also the indentation in the existing code seems weird and not based on tabs. We should fix that up. > + __entry->qid ? > + show_opcode_name(__entry->opcode) : > + show_admin_opcode_name(__entry->opcode), > + __entry->qid ? > + __parse_nvme_cmd(__entry->opcode, __entry->cdw10) : > + __parse_nvme_admin_cmd(__entry->opcode, __entry->cdw10)) > ); Can we hide this? E.g. pass the qid to show_opcode_name and then implement show_opcode_name as: #define show_opcode_name(qid, opcode) \ (qid ? show_admin_opcode_name(opcode) : show_nvm_opcode_name(opcode)) Same for __parse_nvme_cmd. > + __entry->qid = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + !!req->rq_disk; Same as above. In fact I guess we should just have a helper: static inline u16 nvme_req_to_qid(struct request *req) { if (!req->rq_disk) return 0; return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)); }