git: fb56e14ce64e - stable/13 - nvme: Do not rearm timeout for commands without one.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Fri, 21 Jan 2022 02:27:09 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=fb56e14ce64e3fc4703413c21d67c89df72fd9c5

commit fb56e14ce64e3fc4703413c21d67c89df72fd9c5
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-01-07 17:54:49 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-01-21 02:07:31 +0000

    nvme: Do not rearm timeout for commands without one.
    
    Admin queues almost always have several ASYNC_EVENT_REQUEST outstanding.
    They have no timeouts, but their presence in qpair->outstanding_tr caused
    useless timeout callout rearming twice a second.
    
    While there, relax timeout callout period from 0.5s to 0.5-1s to improve
    aggregation.  Command timeouts are measured in seconds, so we don't need
    to be precise here.
    
    Reviewed by:    imp
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D33781
    
    (cherry picked from commit b3c9b6060f9a3525196867d8e812b24fc0bc61e1)
---
 sys/dev/nvme/nvme_qpair.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 54718492ff09..0bf485cea47f 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -948,7 +948,6 @@ nvme_qpair_timeout(void *arg)
 	struct nvme_qpair	*qpair = arg;
 	struct nvme_controller	*ctrlr = qpair->ctrlr;
 	struct nvme_tracker	*tr;
-	struct nvme_tracker	*tr_temp;
 	sbintime_t		now;
 	bool			idle;
 	uint32_t		csts;
@@ -962,8 +961,12 @@ again:
 		if (idle)
 			break;
 		now = getsbinuptime();
-		TAILQ_FOREACH_SAFE(tr, &qpair->outstanding_tr, tailq, tr_temp) {
-			if (now > tr->deadline && tr->deadline != 0) {
+		idle = true;
+		TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) {
+			if (tr->deadline == SBT_MAX)
+				continue;
+			idle = false;
+			if (now > tr->deadline) {
 				/*
 				 * We're now passed our earliest deadline. We
 				 * need to do expensive things to cope, but next
@@ -1028,7 +1031,7 @@ again:
 	 * Rearm the timeout.
 	 */
 	if (!idle) {
-		callout_schedule(&qpair->timer, hz / 2);
+		callout_schedule_sbt(&qpair->timer, SBT_1S / 2, SBT_1S / 2, 0);
 	} else {
 		qpair->timer_armed = false;
 	}
@@ -1061,8 +1064,8 @@ nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr)
 		tr->deadline = getsbinuptime() + timeout * SBT_1S;
 		if (!qpair->timer_armed) {
 			qpair->timer_armed = true;
-			callout_reset_on(&qpair->timer, hz / 2,
-			    nvme_qpair_timeout, qpair, qpair->cpu);
+			callout_reset_sbt_on(&qpair->timer, SBT_1S / 2, SBT_1S / 2,
+			    nvme_qpair_timeout, qpair, qpair->cpu, 0);
 		}
 	} else
 		tr->deadline = SBT_MAX;