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
This commit is contained in:
Warner Losh 2024-05-24 08:32:47 -06:00
parent 99c14fb99f
commit d09ee08f10
4 changed files with 15 additions and 0 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -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) \

View file

@ -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");
}