From nobody Tue Jun 04 00:23:17 2024 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 4VtWXQ0D0Lz5Lb5c; Tue, 04 Jun 2024 00:23:18 +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 4VtWXP6X92z591Q; Tue, 4 Jun 2024 00:23:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717460597; 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=oX6xAJHt4+OA6djs4+yeIzZVtaY3qAwKJN0P+rpPzgI=; b=tH/fczErJoYyNjGJ+f+kVGCG7xzyZbItxd2M0XEI9keuJhF2cjgPIaJba3u/orDTxY56d3 k7XQUIjDd/Xlx7d3WKj2t8GsHdN9rg6eSMnlcARzF2YZ/NPoyEU9FhnSkUK8SjG4A5/IWk ffBvLB0VP+teK/MJckIiHd6cPidRWKS0HNty9HOMklTRPBH8jY205UKMBvphxOnvopDQTB q5e06vlMWl+4hiCWNUBRQ+TLWBQEfDGAdAbbrHGPiHZZ3GqgKTyvE/SI3KTy1I3ob4BjrJ QXKo77N8vIJY7cWqeomxUVq0Btwqf8b+nrLaUWaaduTDB5Bqlj26hprr1Sf62A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717460597; a=rsa-sha256; cv=none; b=yPjU7+sWxa+m/UW4+lHWxadbde4objAJ1zRKrnW0FiK6u+JicioS00RswB+6TSWmYg+Am3 B3CZZ6JsBM8cXUIU9lFHqKqfCJJBwpwPyBbpqz2kFCbrrEyHNnMzyY+7FENf3lFU6r6ofF Ygzmjz7IKK5XHaoXEKYQHxXFxk9qrLEH3kXIytTAi4MZrAgxbcSQKM4GkWevlfIqySL2xi XWQJIlegJAYFwhJAAw/wE/JYGkyOh2LrEmDO3bquvtUWJfYZq9CtocVEy+mY9jqmrvw8Ic p8LqNIY+i/8m/LU0s15ex/26DMQXbxYAd4r+pT2ytvLiMrBBF91xZv5HHDbenw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717460597; 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=oX6xAJHt4+OA6djs4+yeIzZVtaY3qAwKJN0P+rpPzgI=; b=yumRaDIysUhiylCoj2iebHyGE7sSIiqWgZmgMRGOhyz13ElU4/y3gOzbMOrWRNIn8kUi2u rDIYM4MAMKXKwLFexh4Vi/oucRg/XkFWNAzm2t/thH/NNupPpe4VJcqaMAtlRIQCb4gGGL U/4KXyk3IufaNB103WPC1cNZ19aSpXab4muq0uy0yvHdsgsQcZ/RgIU9AGrA+V34AEEw83 7QcRusFrPbKnweqy4FE1ut+AlLVx8tQgNaZwJzNuw5yL+4UxrNiX4kGNbrBzAsCaDVoe4Q a7OnPfU+cbu6n4te5zgZH/4iej+ONLkLjAv3BHbe2r+rhFmqmf3N3EjW1Xh8uw== 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 4VtWXP5mk3zwnC; Tue, 4 Jun 2024 00:23:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4540NH2q077344; Tue, 4 Jun 2024 00:23:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4540NH99077341; Tue, 4 Jun 2024 00:23:17 GMT (envelope-from git) Date: Tue, 4 Jun 2024 00:23:17 GMT Message-Id: <202406040023.4540NH99077341@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: badf44cc2124 - main - mbuf: provide m_freemp() 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: badf44cc21249a56e7d822a77acfdd21f8352d50 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=badf44cc21249a56e7d822a77acfdd21f8352d50 commit badf44cc21249a56e7d822a77acfdd21f8352d50 Author: Gleb Smirnoff AuthorDate: 2024-06-04 00:22:07 +0000 Commit: Gleb Smirnoff CommitDate: 2024-06-04 00:23:06 +0000 mbuf: provide m_freemp() This function follows both m_nextpkt and m_next linkage freeing all mbufs. Note that existing m_freem() follows only m_next. Reviewed by: khng Differential Revision: https://reviews.freebsd.org/D45477 --- sys/kern/kern_mbuf.c | 19 +++++++++++++++++++ sys/kern/uipc_mbuf.c | 3 +++ sys/sys/mbuf.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 44b6584f7331..5c1c5b095449 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -1591,6 +1591,25 @@ m_freem(struct mbuf *mb) mb = m_free(mb); } +/* + * Free an entire chain of mbufs and associated external buffers, following + * both m_next and m_nextpkt linkage. + * Note: doesn't support NULL argument. + */ +void +m_freemp(struct mbuf *m) +{ + struct mbuf *n; + + MBUF_PROBE1(m__freemp, m); + do { + n = m->m_nextpkt; + while (m != NULL) + m = m_free(m); + m = n; + } while (m != NULL); +} + /* * Temporary primitive to allow freeing without going through m_free. */ diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index d3389aeeccaf..d6b38cf8fbc8 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -111,6 +111,9 @@ SDT_PROBE_DEFINE1_XLATE(sdt, , , m__free, SDT_PROBE_DEFINE1_XLATE(sdt, , , m__freem, "struct mbuf *", "mbufinfo_t *"); +SDT_PROBE_DEFINE1_XLATE(sdt, , , m__freemp, + "struct mbuf *", "mbufinfo_t *"); + #include /* diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 741ae1b7c387..6e8454ea62d6 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -65,6 +65,7 @@ SDT_PROBE_DECLARE(sdt, , , m__cljget); SDT_PROBE_DECLARE(sdt, , , m__cljset); SDT_PROBE_DECLARE(sdt, , , m__free); SDT_PROBE_DECLARE(sdt, , , m__freem); +SDT_PROBE_DECLARE(sdt, , , m__freemp); #endif /* _KERNEL */ @@ -843,6 +844,7 @@ void m_extadd(struct mbuf *, char *, u_int, m_ext_free_t, u_int m_fixhdr(struct mbuf *); struct mbuf *m_fragment(struct mbuf *, int, int); void m_freem(struct mbuf *); +void m_freemp(struct mbuf *); void m_free_raw(struct mbuf *); struct mbuf *m_get2(int, int, short, int); struct mbuf *m_get3(int, int, short, int);