git: d09ee08f106d - main - nvme: Count number of alginment splits
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 24 May 2024 15:40:44 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d09ee08f106ddabeb02affc7e9dcfea8c154a57d commit d09ee08f106ddabeb02affc7e9dcfea8c154a57d Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-05-24 14:32:47 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-05-24 14:32:47 +0000 nvme: Count number of alginment splits When possible, we split up I/Os to NVMe drives that advertise a preferred alignment. Add a counter for this. Sponsored by: Netflix Reviewed by: chuck, mav Differential Revision: https://reviews.freebsd.org/D45311 --- sys/dev/nvme/nvme_ctrlr.c | 5 +++++ sys/dev/nvme/nvme_ns.c | 1 + sys/dev/nvme/nvme_private.h | 4 ++++ sys/dev/nvme/nvme_sysctl.c | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index 00e619bfdc46..d9bd1fce2864 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -1442,6 +1442,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev) ctrlr->enable_aborts = 0; TUNABLE_INT_FETCH("hw.nvme.enable_aborts", &ctrlr->enable_aborts); + ctrlr->alignment_splits = counter_u64_alloc(M_WAITOK); + /* Cap transfers by the maximum addressable by page-sized PRP (4KB pages -> 2MB). */ ctrlr->max_xfer_size = MIN(maxphys, (ctrlr->page_size / 8 * ctrlr->page_size)); if (nvme_ctrlr_construct_admin_qpair(ctrlr) != 0) @@ -1560,6 +1562,9 @@ noadminq: ctrlr->resource_id, ctrlr->resource); nores: + if (ctrlr->alignment_splits) + counter_u64_free(ctrlr->alignment_splits); + mtx_destroy(&ctrlr->lock); } diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index e494b8cd857a..201cf9188c1e 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -428,6 +428,7 @@ nvme_ns_split_bio(struct nvme_namespace *ns, struct bio *bp, if (child_bios == NULL) return (ENOMEM); + counter_u64_add(ns->ctrlr->alignment_splits, 1); for (i = 0; i < num_bios; i++) { child = child_bios[i]; err = nvme_ns_bio_process(ns, child, nvme_bio_child_done); diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index 69141add4e48..8415819ca20b 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -32,6 +32,7 @@ #include <sys/param.h> #include <sys/bio.h> #include <sys/bus.h> +#include <sys/counter.h> #include <sys/kernel.h> #include <sys/lock.h> #include <sys/malloc.h> @@ -317,6 +318,9 @@ struct nvme_controller { bus_dmamap_t hmb_desc_map; struct nvme_hmb_desc *hmb_desc_vaddr; uint64_t hmb_desc_paddr; + + /* Statistics */ + counter_u64_t alignment_splits; }; #define nvme_mmio_offsetof(reg) \ diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c index d6452a2e5492..447f48e0bdd5 100644 --- a/sys/dev/nvme/nvme_sysctl.c +++ b/sys/dev/nvme/nvme_sysctl.c @@ -30,6 +30,7 @@ #include "opt_nvme.h" #include <sys/param.h> +#include <sys/systm.h> #include <sys/bus.h> #include <sys/sysctl.h> @@ -419,4 +420,8 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr) nvme_sysctl_initialize_queue(&ctrlr->ioq[i], ctrlr_ctx, que_tree); } + + SYSCTL_ADD_COUNTER_U64(ctrlr_ctx, ctrlr_list, OID_AUTO, "alignment_splits", + CTLFLAG_RD, &ctrlr->alignment_splits, + "Number of times we split the I/O alignment for drives with preferred alignment"); }