From nobody Tue Oct 08 04:22:48 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XN2tc6ltdz5YvDb; Tue, 08 Oct 2024 04:22:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XN2tc6534z4bQb; Tue, 8 Oct 2024 04:22:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728361368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pPojhcH3AbfZmQWK+Pol+8Qn/EJu3l761FYGclwjzAE=; b=bDXIHDwTdI4nearPBbp+mKkFKvwUb1L5DvXayQhQFvEO29EgdAZFN73LT5oShiA0H/uSAl Lx4yosES+Q8DRvWbQbVP7KviLI9VUntFpP1qovxI7s+XVxxhhzztXrZahXlqfP87UBElXi XuQC+2jvW9fkLQ9n3v08N5oyHRCFMZeReydd0TXRWT1BTz73CgmBIMShWQQkz44fBgrEic BU02dqSdiIbJgkEIO+n+23nOXovKgHsjwJ1JsmprS7ETobrIGyZlYPv1xUuNRXDx4qmceb P3PPf8mU47K66LvoQ3ReyJ6wdTKlZLUJw9huZGOVYRRo5IbW45Xu4EMuQogzgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728361368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pPojhcH3AbfZmQWK+Pol+8Qn/EJu3l761FYGclwjzAE=; b=ZpnQNXSGWqJecUtx66Nj4Fuin7H55LR6KzoEakK5kum7ufeJTjwoIlfGRqMCWpUKwr9edU vbvMvyPDmKxVSNmxQLcSozOm2nrrmKTMQBWT25MrSZWGtR8rd9X0udpPYig+Ao+NE1+ZlE 98vCZkE3v3urbgl8IB1qJdZOejwoKLI8paRrNqZn+dk1iogfGmAlpypfkc0OmBCS0+/+AW S7Fvo2WqM8+Fkn4dKYTRQX/4d44khS/cPQ9SmahHbktm+HUxuhGWW47HYTefkYO/kTLQ4+ WQV8BQQ1Y+A5GDQ1bMIhVn4iUAJmtE0NtVjNOcX8HNR6JwjLidW+bdTYx+XUMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728361368; a=rsa-sha256; cv=none; b=nywHJlVa3QlOm6tbZhw2LdR0dfI3nsTEfKgjLdxn9L2qIImK8M1/mTjLf0vOjRVTZ2R2Sz 4w5hyl1n7RxzmG+I1DgGALuQKuubA4hVYfuvs9BFsr0sYCiEETg1dDRWJrWDEXBlM0QDY/ 0OVFO2Bj1ka1GsVfDSH+Aahklqit7EW/ow/P1hcgvzv8K88yfYoCDqxjqut3txJw62L01W lNBSspOK/RP4GIgNW5WYp5Mi/huQbdrE6l+f8+0ohqTC6mI2Y4CZ80kKGbHzJrZWTTExxQ aEye1vKzfo0sXC4LtNebOtXbCryukY7wKvp5iqTnyYDke/OiubFUNDcFdboYpw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XN2tc5hH7zGGv; Tue, 8 Oct 2024 04:22:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4984MmrU078528; Tue, 8 Oct 2024 04:22:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4984MmYt078525; Tue, 8 Oct 2024 04:22:48 GMT (envelope-from git) Date: Tue, 8 Oct 2024 04:22:48 GMT Message-Id: <202410080422.4984MmYt078525@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 6c711019f289 - main - nvme: Don't create sysctl for io queues not created List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6c711019f289320f38eda47dcb55b188342a4476 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=6c711019f289320f38eda47dcb55b188342a4476 commit 6c711019f289320f38eda47dcb55b188342a4476 Author: Warner Losh AuthorDate: 2024-10-08 03:08:57 +0000 Commit: Warner Losh CommitDate: 2024-10-08 04:22:40 +0000 nvme: Don't create sysctl for io queues not created When we can't set the number of I/O queues ont he admin queue, we continue on. However, we don't create the I/O queue structures, so having pointers (NULL) into them for sysctls makes no sense and leads to a panic when accessed. When summing up different stats, also skip the ioq stats when it's NULL. Sponsored by: Netflix --- sys/dev/nvme/nvme_sysctl.c | 61 +++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c index 447f48e0bdd5..c66f1ed51c9c 100644 --- a/sys/dev/nvme/nvme_sysctl.c +++ b/sys/dev/nvme/nvme_sysctl.c @@ -176,8 +176,10 @@ nvme_sysctl_num_cmds(SYSCTL_HANDLER_ARGS) num_cmds = ctrlr->adminq.num_cmds; - for (i = 0; i < ctrlr->num_io_queues; i++) - num_cmds += ctrlr->ioq[i].num_cmds; + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + num_cmds += ctrlr->ioq[i].num_cmds; + } return (sysctl_handle_64(oidp, &num_cmds, 0, req)); } @@ -191,8 +193,10 @@ nvme_sysctl_num_intr_handler_calls(SYSCTL_HANDLER_ARGS) num_intr_handler_calls = ctrlr->adminq.num_intr_handler_calls; - for (i = 0; i < ctrlr->num_io_queues; i++) - num_intr_handler_calls += ctrlr->ioq[i].num_intr_handler_calls; + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + num_intr_handler_calls += ctrlr->ioq[i].num_intr_handler_calls; + } return (sysctl_handle_64(oidp, &num_intr_handler_calls, 0, req)); } @@ -206,8 +210,10 @@ nvme_sysctl_num_retries(SYSCTL_HANDLER_ARGS) num_retries = ctrlr->adminq.num_retries; - for (i = 0; i < ctrlr->num_io_queues; i++) - num_retries += ctrlr->ioq[i].num_retries; + if (ctrlr->ioq != NULL) { + 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)); } @@ -221,8 +227,10 @@ nvme_sysctl_num_failures(SYSCTL_HANDLER_ARGS) num_failures = ctrlr->adminq.num_failures; - for (i = 0; i < ctrlr->num_io_queues; i++) - num_failures += ctrlr->ioq[i].num_failures; + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + num_failures += ctrlr->ioq[i].num_failures; + } return (sysctl_handle_64(oidp, &num_failures, 0, req)); } @@ -236,8 +244,10 @@ nvme_sysctl_num_ignored(SYSCTL_HANDLER_ARGS) num_ignored = ctrlr->adminq.num_ignored; - for (i = 0; i < ctrlr->num_io_queues; i++) - num_ignored += ctrlr->ioq[i].num_ignored; + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + num_ignored += ctrlr->ioq[i].num_ignored; + } return (sysctl_handle_64(oidp, &num_ignored, 0, req)); } @@ -251,8 +261,10 @@ nvme_sysctl_num_recovery_nolock(SYSCTL_HANDLER_ARGS) num = ctrlr->adminq.num_recovery_nolock; - for (i = 0; i < ctrlr->num_io_queues; i++) - num += ctrlr->ioq[i].num_recovery_nolock; + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + num += ctrlr->ioq[i].num_recovery_nolock; + } return (sysctl_handle_64(oidp, &num, 0, req)); } @@ -271,8 +283,10 @@ nvme_sysctl_reset_stats(SYSCTL_HANDLER_ARGS) if (val != 0) { nvme_qpair_reset_stats(&ctrlr->adminq); - for (i = 0; i < ctrlr->num_io_queues; i++) - nvme_qpair_reset_stats(&ctrlr->ioq[i]); + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_qpair_reset_stats(&ctrlr->ioq[i]); + } } return (0); @@ -413,12 +427,19 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr) nvme_sysctl_initialize_queue(&ctrlr->adminq, ctrlr_ctx, que_tree); - for (i = 0; i < ctrlr->num_io_queues; i++) { - snprintf(queue_name, QUEUE_NAME_LENGTH, "ioq%d", i); - que_tree = SYSCTL_ADD_NODE(ctrlr_ctx, ctrlr_list, OID_AUTO, - queue_name, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "IO Queue"); - nvme_sysctl_initialize_queue(&ctrlr->ioq[i], ctrlr_ctx, - que_tree); + /* + * Make sure that we've constructed the I/O queues before setting up the + * sysctls. Failed controllers won't allocate it, but we want the rest + * of the sysctls to diagnose things. + */ + if (ctrlr->ioq != NULL) { + for (i = 0; i < ctrlr->num_io_queues; i++) { + snprintf(queue_name, QUEUE_NAME_LENGTH, "ioq%d", i); + que_tree = SYSCTL_ADD_NODE(ctrlr_ctx, ctrlr_list, OID_AUTO, + queue_name, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "IO Queue"); + nvme_sysctl_initialize_queue(&ctrlr->ioq[i], ctrlr_ctx, + que_tree); + } } SYSCTL_ADD_COUNTER_U64(ctrlr_ctx, ctrlr_list, OID_AUTO, "alignment_splits",