From owner-dev-commits-src-main@freebsd.org Mon Jan 18 22:08:14 2021 Return-Path: <owner-dev-commits-src-main@freebsd.org> Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E33EA4F7306; Mon, 18 Jan 2021 22:08:14 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DKQsB0Zchz3JwD; Mon, 18 Jan 2021 22:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B52761B541; Mon, 18 Jan 2021 22:08:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10IM8DED039205; Mon, 18 Jan 2021 22:08:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10IM8D9v039204; Mon, 18 Jan 2021 22:08:13 GMT (envelope-from git) Date: Mon, 18 Jan 2021 22:08:13 GMT Message-Id: <202101182208.10IM8D9v039204@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston <markj@FreeBSD.org> Subject: git: 0371c3faaa24 - main - safexcel: Add counters for some resource exhaustion conditions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0371c3faaa2412413d4fb44254b03124f97dfe66 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository <dev-commits-src-main.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/dev-commits-src-main>, <mailto:dev-commits-src-main-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/dev-commits-src-main/> List-Post: <mailto:dev-commits-src-main@freebsd.org> List-Help: <mailto:dev-commits-src-main-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main>, <mailto:dev-commits-src-main-request@freebsd.org?subject=subscribe> X-List-Received-Date: Mon, 18 Jan 2021 22:08:15 -0000 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;