Date: Mon, 18 Jan 2021 22:08:13 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 0371c3faaa24 - main - safexcel: Add counters for some resource exhaustion conditions Message-ID: <202101182208.10IM8D9v039204@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0371c3faaa2412413d4fb44254b03124f97dfe66 commit 0371c3faaa2412413d4fb44254b03124f97dfe66 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-01-18 22:07:55 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-01-18 22:07:55 +0000 safexcel: Add counters for some resource exhaustion conditions This is useful when analyzing performance problems. MFC after: 1 week Sponsored by: Rubicon Communications, LLC (Netgate) --- sys/dev/safexcel/safexcel.c | 36 +++++++++++++++++++++++++++++++++--- sys/dev/safexcel/safexcel_var.h | 6 ++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/sys/dev/safexcel/safexcel.c b/sys/dev/safexcel/safexcel.c index c3a2cdcca62d..c30b8178efb1 100644 --- a/sys/dev/safexcel/safexcel.c +++ b/sys/dev/safexcel/safexcel.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/bus.h> +#include <sys/counter.h> #include <sys/endian.h> #include <sys/kernel.h> #include <sys/lock.h> @@ -1149,7 +1150,9 @@ safexcel_probe(device_t dev) static int safexcel_attach(device_t dev) { - struct sysctl_ctx_list *sctx; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *oid; + struct sysctl_oid_list *children; struct safexcel_softc *sc; struct safexcel_request *req; struct safexcel_ring *ring; @@ -1203,11 +1206,30 @@ safexcel_attach(device_t dev) } } - sctx = device_get_sysctl_ctx(dev); - SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + ctx = device_get_sysctl_ctx(dev); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "debug", CTLFLAG_RWTUN, &sc->sc_debug, 0, "Debug message verbosity"); + oid = device_get_sysctl_tree(sc->sc_dev); + children = SYSCTL_CHILDREN(oid); + oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "stats", + CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "statistics"); + children = SYSCTL_CHILDREN(oid); + + sc->sc_req_alloc_failures = counter_u64_alloc(M_WAITOK); + SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "req_alloc_failures", + CTLFLAG_RD, &sc->sc_req_alloc_failures, + "Number of request allocation failures"); + sc->sc_cdesc_alloc_failures = counter_u64_alloc(M_WAITOK); + SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "cdesc_alloc_failures", + CTLFLAG_RD, &sc->sc_cdesc_alloc_failures, + "Number of command descriptor ring overflows"); + sc->sc_rdesc_alloc_failures = counter_u64_alloc(M_WAITOK); + SYSCTL_ADD_COUNTER_U64(ctx, children, OID_AUTO, "rdesc_alloc_failures", + CTLFLAG_RD, &sc->sc_rdesc_alloc_failures, + "Number of result descriptor ring overflows"); + sc->sc_cid = crypto_get_driverid(dev, sizeof(struct safexcel_session), CRYPTOCAP_F_HARDWARE); if (sc->sc_cid < 0) @@ -1234,6 +1256,11 @@ safexcel_detach(device_t dev) if (sc->sc_cid >= 0) crypto_unregister_all(sc->sc_cid); + + counter_u64_free(sc->sc_req_alloc_failures); + counter_u64_free(sc->sc_cdesc_alloc_failures); + counter_u64_free(sc->sc_rdesc_alloc_failures); + for (ringidx = 0; ringidx < sc->sc_config.rings; ringidx++) { ring = &sc->sc_ring[ringidx]; for (i = 0; i < SAFEXCEL_REQUESTS_PER_RING; i++) { @@ -2065,6 +2092,7 @@ safexcel_create_chain_cb(void *arg, bus_dma_segment_t *segs, int nseg, (uint32_t)inlen, req->ctx.paddr); if (cdesc == NULL) { safexcel_cmd_descr_rollback(ring, i); + counter_u64_add(req->sc->sc_cdesc_alloc_failures, 1); req->error = EAGAIN; return; } @@ -2092,6 +2120,7 @@ safexcel_create_chain_cb(void *arg, bus_dma_segment_t *segs, int nseg, safexcel_cmd_descr_rollback(ring, ring->cmd_data->sg_nseg); safexcel_res_descr_rollback(ring, i); + counter_u64_add(req->sc->sc_rdesc_alloc_failures, 1); req->error = EAGAIN; return; } @@ -2567,6 +2596,7 @@ safexcel_process(device_t dev, struct cryptop *crp, int hint) if (__predict_false(req == NULL)) { ring->blocked = CRYPTO_SYMQ; mtx_unlock(&ring->mtx); + counter_u64_add(sc->sc_req_alloc_failures, 1); return (ERESTART); } diff --git a/sys/dev/safexcel/safexcel_var.h b/sys/dev/safexcel/safexcel_var.h index de65e666a4c3..dab4b17963ab 100644 --- a/sys/dev/safexcel/safexcel_var.h +++ b/sys/dev/safexcel/safexcel_var.h @@ -29,6 +29,8 @@ #ifndef _SAFEXCEL_VAR_H_ #define _SAFEXCEL_VAR_H_ +#include <sys/counter.h> + #define SAFEXCEL_MAX_RINGS 4 #define SAFEXCEL_MAX_BATCH_SIZE 64 #define SAFEXCEL_MAX_FRAGMENTS 64 @@ -405,6 +407,10 @@ struct safexcel_softc { struct resource *sc_intr[SAFEXCEL_MAX_RINGS]; struct safexcel_intr_handle sc_ih[SAFEXCEL_MAX_RINGS]; + counter_u64_t sc_req_alloc_failures; + counter_u64_t sc_cdesc_alloc_failures; + counter_u64_t sc_rdesc_alloc_failures; + struct safexcel_ring sc_ring[SAFEXCEL_MAX_RINGS]; int32_t sc_cid;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101182208.10IM8D9v039204>