From nobody Thu Mar 30 17:55:26 2023 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 4PnWKp4rRkz425xY; Thu, 30 Mar 2023 17:55:26 +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 4PnWKp4Qn7z4bpF; Thu, 30 Mar 2023 17:55:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680198926; 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=flixQfwoT5q89pZK7FSaZyuQNQy8q4idEaGvpKBk0so=; b=veyXD7OYY4il0TcTV14m9lF64DU7IievK7EZpaUEJ6E7N20xV1EinA4syjkIx7UcQUwr1Z +wH7vRecl14QNBRkMqhcurPdT1VFM2gl2kcKqzJQw5u3B9zg5xKvTMX1gXYjjQp0N4LYuE E6ArQKwjkO3eS6nHnEfBSS5+bHGoRCC8BtXMhV3SAcxY9kvjqYaiG20lsJoI2YHDqRIzvK P1pcLEqB1K0NdVsRbyP+L2fW0fmy4QFc3LfL+7lZLniSNE0s7Qr7FMhHmJt0tRa3klKTQQ 0UgZqR4UN7GZKG11czsT6Se4FiL20icTJXjBAfAKop65n0+XBm1PN/JinCU7Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680198926; 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=flixQfwoT5q89pZK7FSaZyuQNQy8q4idEaGvpKBk0so=; b=mZ+Hbu985d50V1pPIv77bioyj0AGQ3xnUh9ACF0KWpkRB+SD1zKQ21QzHIvnH16Zea+Hfo OleVrNqPwnfykuNzZR38Yl7sArhz6jqEW45G1oOVT5asNPPPExxr2YlkGp74KrKnTnEE01 h5I2xaBcwGoW90EzI1z0rg/XhE9+ggTrWRv2n5P0PkBIatShbg2JHr6jdGhwBdYmWjPOu9 rL9XPEOqWxZfbMsip8BnuLDerv6Auk53rAt1rihOg9GTJrUPfgHZ9w4kg+7D8tYo4KC2/O aI4LTdvNIkj0SHVKilXAmkgGDT2u4Lre5poV0L5YfWpUjI8tOhVTml0lJdAqOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680198926; a=rsa-sha256; cv=none; b=Dcs7zu9sH4gLSJ6KQfm59g5gzBjHzxs5PIIS9E9MnrrscY1WaApzLA82X0xDqjz8ieEfHi Gm7ZADaANoq4FpRszkDI2bSoYDQQeUdDc31CUPzPNMY/VHlEJn4o5TGPg/AVGBYWfngXen jQla0OmmllUJAeb/bCUVkiPxKcz2xtHq37MQIDuuUlJ/0ML1cdFnBbOrNjmB9BCnICRWYn hl2roPJ5yXdheFJ0cJgRZjGxHURl6Boz6v3dB5wu0dcNzOxWBZ7ReTC3Ut147qlQDiOAk2 Wd2O4hYPa8N+0dZvtABWUyxgqmiCxTMdQ+DElrUvZh4zSdaX6rzejLheBFView== 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 4PnWKp3XQ8zLlP; Thu, 30 Mar 2023 17:55:26 +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 32UHtQe1007971; Thu, 30 Mar 2023 17:55:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32UHtQhl007970; Thu, 30 Mar 2023 17:55:26 GMT (envelope-from git) Date: Thu, 30 Mar 2023 17:55:26 GMT Message-Id: <202303301755.32UHtQhl007970@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: fd02d0bc14b5 - main - graid3: Pre-allocate the timeout event structure 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org 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: fd02d0bc14b5c8d7109a180575b565fa7427b93e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=fd02d0bc14b5c8d7109a180575b565fa7427b93e commit fd02d0bc14b5c8d7109a180575b565fa7427b93e Author: Mark Johnston AuthorDate: 2023-03-26 18:14:53 +0000 Commit: Mark Johnston CommitDate: 2023-03-30 17:38:15 +0000 graid3: Pre-allocate the timeout event structure As in commit 2f1cfb7f63ca ("gmirror: Pre-allocate the timeout event structure"), graid3 must avoid M_WAITOK allocations in callout handlers. Reported by: graid3 regression tests MFC after 2 weeks --- sys/geom/raid3/g_raid3.c | 40 ++++++++++++++++++++++++++++++++-------- sys/geom/raid3/g_raid3.h | 1 + 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 22e833c25f5d..1b425ba66f5f 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -125,6 +125,7 @@ static void g_raid3_dumpconf(struct sbuf *sb, const char *indent, static void g_raid3_sync_stop(struct g_raid3_softc *sc, int type); static int g_raid3_register_request(struct bio *pbp); static void g_raid3_sync_release(struct g_raid3_softc *sc); +static void g_raid3_timeout_drain(struct g_raid3_softc *sc); static const char * g_raid3_disk_state2str(int state) @@ -285,15 +286,14 @@ g_raid3_event_free(struct g_raid3_event *ep) free(ep, M_RAID3); } -int -g_raid3_event_send(void *arg, int state, int flags) +static int +g_raid3_event_dispatch(struct g_raid3_event *ep, void *arg, int state, + int flags) { struct g_raid3_softc *sc; struct g_raid3_disk *disk; - struct g_raid3_event *ep; int error; - ep = malloc(sizeof(*ep), M_RAID3, M_WAITOK); G_RAID3_DEBUG(4, "%s: Sending event %p.", __func__, ep); if ((flags & G_RAID3_EVENT_DEVICE) != 0) { disk = NULL; @@ -330,6 +330,15 @@ g_raid3_event_send(void *arg, int state, int flags) return (error); } +int +g_raid3_event_send(void *arg, int state, int flags) +{ + struct g_raid3_event *ep; + + ep = malloc(sizeof(*ep), M_RAID3, M_WAITOK); + return (g_raid3_event_dispatch(ep, arg, state, flags)); +} + static struct g_raid3_event * g_raid3_event_get(struct g_raid3_softc *sc) { @@ -634,7 +643,7 @@ g_raid3_destroy_device(struct g_raid3_softc *sc) mtx_unlock(&sc->sc_events_mtx); } } - callout_drain(&sc->sc_callout); + g_raid3_timeout_drain(sc); cp = LIST_FIRST(&sc->sc_sync.ds_geom->consumer); g_topology_lock(); if (cp != NULL) @@ -2377,13 +2386,26 @@ static void g_raid3_go(void *arg) { struct g_raid3_softc *sc; + struct g_raid3_event *ep; sc = arg; G_RAID3_DEBUG(0, "Force device %s start due to timeout.", sc->sc_name); - g_raid3_event_send(sc, 0, + ep = sc->sc_timeout_event; + sc->sc_timeout_event = NULL; + g_raid3_event_dispatch(ep, sc, 0, G_RAID3_EVENT_DONTWAIT | G_RAID3_EVENT_DEVICE); } +static void +g_raid3_timeout_drain(struct g_raid3_softc *sc) +{ + sx_assert(&sc->sc_lock, SX_XLOCKED); + + callout_drain(&sc->sc_callout); + g_raid3_event_free(sc->sc_timeout_event); + sc->sc_timeout_event = NULL; +} + static u_int g_raid3_determine_state(struct g_raid3_disk *disk) { @@ -2473,7 +2495,7 @@ g_raid3_update_device(struct g_raid3_softc *sc, boolean_t force) */ if (g_raid3_ndisks(sc, -1) + force == sc->sc_ndisks) { if (!force) - callout_drain(&sc->sc_callout); + g_raid3_timeout_drain(sc); } else { if (force) { /* @@ -3217,9 +3239,11 @@ g_raid3_create(struct g_class *mp, const struct g_raid3_metadata *md) G_RAID3_DEBUG(1, "root_mount_hold %p", sc->sc_rootmount); /* - * Run timeout. + * Schedule startup timeout. */ timeout = atomic_load_acq_int(&g_raid3_timeout); + sc->sc_timeout_event = malloc(sizeof(struct g_raid3_event), M_RAID3, + M_WAITOK); callout_reset(&sc->sc_callout, timeout * hz, g_raid3_go, sc); return (sc->sc_geom); } diff --git a/sys/geom/raid3/g_raid3.h b/sys/geom/raid3/g_raid3.h index 8f0d92dee7ef..edfc036809c8 100644 --- a/sys/geom/raid3/g_raid3.h +++ b/sys/geom/raid3/g_raid3.h @@ -224,6 +224,7 @@ struct g_raid3_softc { TAILQ_HEAD(, g_raid3_event) sc_events; struct mtx sc_events_mtx; + struct g_raid3_event *sc_timeout_event; struct callout sc_callout;