Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Aug 2019 18:54:58 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r350936 - stable/12/sys/dev/nvme
Message-ID:  <201908121854.x7CIsw6V065140@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Aug 12 18:54:58 2019
New Revision: 350936
URL: https://svnweb.freebsd.org/changeset/base/350936

Log:
  MFC r350146 (by imp): Keep track of the number of retried commands.
  
  Retried commands can indicate a performance degredation of an nvme drive. Keep
  track of the number of retries and report it out via sysctl, just like number of
  commands an interrupts.

Modified:
  stable/12/sys/dev/nvme/nvme_private.h
  stable/12/sys/dev/nvme/nvme_qpair.c
  stable/12/sys/dev/nvme/nvme_sysctl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/nvme/nvme_private.h
==============================================================================
--- stable/12/sys/dev/nvme/nvme_private.h	Mon Aug 12 18:54:24 2019	(r350935)
+++ stable/12/sys/dev/nvme/nvme_private.h	Mon Aug 12 18:54:58 2019	(r350936)
@@ -190,6 +190,7 @@ struct nvme_qpair {
 
 	int64_t			num_cmds;
 	int64_t			num_intr_handler_calls;
+	int64_t			num_retries;
 
 	struct nvme_command	*cmd;
 	struct nvme_completion	*cpl;

Modified: stable/12/sys/dev/nvme/nvme_qpair.c
==============================================================================
--- stable/12/sys/dev/nvme/nvme_qpair.c	Mon Aug 12 18:54:24 2019	(r350935)
+++ stable/12/sys/dev/nvme/nvme_qpair.c	Mon Aug 12 18:54:58 2019	(r350936)
@@ -393,6 +393,8 @@ nvme_qpair_complete_tracker(struct nvme_qpair *qpair, 
 	error = nvme_completion_is_error(cpl);
 	retry = error && nvme_completion_is_retry(cpl) &&
 	   req->retries < nvme_retry_count;
+	if (retry)
+		qpair->num_retries++;
 
 	if (error && (print_on_error == ERROR_PRINT_ALL ||
 		(!retry && print_on_error == ERROR_PRINT_NO_RETRY))) {
@@ -684,6 +686,7 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_
 
 	qpair->num_cmds = 0;
 	qpair->num_intr_handler_calls = 0;
+	qpair->num_retries = 0;
 	qpair->cmd = (struct nvme_command *)queuemem;
 	qpair->cpl = (struct nvme_completion *)(queuemem + cmdsz);
 	prpmem = (uint8_t *)(queuemem + cmdsz + cplsz);

Modified: stable/12/sys/dev/nvme/nvme_sysctl.c
==============================================================================
--- stable/12/sys/dev/nvme/nvme_sysctl.c	Mon Aug 12 18:54:24 2019	(r350935)
+++ stable/12/sys/dev/nvme/nvme_sysctl.c	Mon Aug 12 18:54:58 2019	(r350936)
@@ -166,6 +166,7 @@ nvme_qpair_reset_stats(struct nvme_qpair *qpair)
 
 	qpair->num_cmds = 0;
 	qpair->num_intr_handler_calls = 0;
+	qpair->num_retries = 0;
 }
 
 static int
@@ -199,6 +200,21 @@ nvme_sysctl_num_intr_handler_calls(SYSCTL_HANDLER_ARGS
 }
 
 static int
+nvme_sysctl_num_retries(SYSCTL_HANDLER_ARGS)
+{
+	struct nvme_controller 	*ctrlr = arg1;
+	int64_t			num_retries = 0;
+	int			i;
+
+	num_retries = ctrlr->adminq.num_retries;
+
+	for (i = 0; i < ctrlr->num_io_queues; i++)
+		num_retries += ctrlr->ioq[i].num_retries;
+
+	return (sysctl_handle_64(oidp, &num_retries, 0, req));
+}
+
+static int
 nvme_sysctl_reset_stats(SYSCTL_HANDLER_ARGS)
 {
 	struct nvme_controller 	*ctrlr = arg1;
@@ -249,6 +265,8 @@ nvme_sysctl_initialize_queue(struct nvme_qpair *qpair,
 	    "Number of times interrupt handler was invoked (will typically be "
 	    "less than number of actual interrupts generated due to "
 	    "coalescing)");
+	SYSCTL_ADD_QUAD(ctrlr_ctx, que_list, OID_AUTO, "num_retries",
+	    CTLFLAG_RD, &qpair->num_retries, "Number of commands retried");
 
 	SYSCTL_ADD_PROC(ctrlr_ctx, que_list, OID_AUTO,
 	    "dump_debug", CTLTYPE_UINT | CTLFLAG_RW, qpair, 0,
@@ -299,6 +317,11 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *c
 	    "Number of times interrupt handler was invoked (will "
 	    "typically be less than number of actual interrupts "
 	    "generated due to coalescing)");
+
+	SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO,
+	    "num_retries", CTLTYPE_S64 | CTLFLAG_RD,
+	    ctrlr, 0, nvme_sysctl_num_retries, "IU",
+	    "Number of commands retried");
 
 	SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO,
 	    "reset_stats", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908121854.x7CIsw6V065140>