From nobody Mon Jan 13 19:30:11 2025 X-Original-To: dev-commits-src-all@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 4YX2Qq6w2fz5kjdL; Mon, 13 Jan 2025 19:30:11 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YX2Qq66gMz3WTk; Mon, 13 Jan 2025 19:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736796611; 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=yOUwBGEByw9UOevQfAqbChtTUhqZoDsR0mL+h381kAM=; b=h3wXWHarL6JVB48Ebc80s67Pk3UeChmapYpDmFZJP8FLdnI+Z6bJ+KrOyIcfqF4UGVXzJf oIb2Lt5oqy9Lhn28WK4c8F/Lw5/suZ0GqghsqcWpS8u8pyH94F+XBOEYSynN64f2F841pb nNcgpLNf3qabIyhnbXHwwvvY7hAWUQtKyrPbaZntj9S+h7GV1Lw8U9KcZhu9gmGwxDLnyg SvhCce96TdAfqgnNKyqFnxO5H2lYQIS1+qPkgYCEe97I3mFpjsJNKAw3jqjCl0X7pDAV5x RpfknJMQaI83RDMIvE4oOpjgBdlzKsG000Jyj5pmOE5qd6HLDNrfTgqfQIUiWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736796611; 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=yOUwBGEByw9UOevQfAqbChtTUhqZoDsR0mL+h381kAM=; b=HHWkKEg453Gz6gZ0V8Wkm3awE8aYTPtewAgk3MpPIQzmfbUSI6RlmfrP8Mw1cX0GNJZTZ/ 20v1VNn4OWU7vkpDqrHKo9Jmg9avphqwoB9UxFuOO9BU0B05em6WeTZnmJw8ILW002pWfa FlguqQF2+jrnmKFKsr9jlp+hi70rj6RF3gM0GaYmhkSwn1CrgOWE/p21bsnEBYtJkrjoDs D5OF5ju72MOMWLCMqRdDGy6LNAZtoh5r5mdHck8F/sDtSz6pJ4XazHFNehZdxPRgnZ0QQ1 SYswY45qtilECt/JON6HeNcdCAT3ubz+6nAg8yawMCyvllT1lxBlRC3IJPRBiA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736796611; a=rsa-sha256; cv=none; b=MVZ+KYpDBYuAUcxSZJ2xcDoKqIGMrx/gZgOhxoupRnHVrxoUHRz/KpkgX+IO8th+tUitvK N9E/MwAio72KkSsEhTJkeeWDO8tLLaO0baP+3rhZGeHcxzSQh4plHARGwNsmIR43Dpr4if h9jYgkM/uDxDANI4ppnuYrw59t+wfoN5wY5Vm4PjPf1qsXsMdfcP2elUgU3EJk6b2DuPd0 4uDvFrJp2jGkJYM/CgT4kJvZ4M4TcQjUAqUAQLIb1TRIq9Qi8Qarc5/YMuotSPdjy8OcoV FV5CgMayhrbzdygSbzTbnn4VtKBBl15p7fBBqMSgqRgUsHjmN9IT5YnmwqPCOw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YX2Qq5Kypzklc; Mon, 13 Jan 2025 19:30:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50DJUBni046445; Mon, 13 Jan 2025 19:30:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50DJUBQX046437; Mon, 13 Jan 2025 19:30:11 GMT (envelope-from git) Date: Mon, 13 Jan 2025 19:30:11 GMT Message-Id: <202501131930.50DJUBQX046437@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: cf322978d73a - main - mb_unmapped_to_ext(): return error code on error List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cf322978d73a3ed4958cb64cc4f1b47ceb53a03e Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cf322978d73a3ed4958cb64cc4f1b47ceb53a03e commit cf322978d73a3ed4958cb64cc4f1b47ceb53a03e Author: Konstantin Belousov AuthorDate: 2024-12-28 08:30:01 +0000 Commit: Konstantin Belousov CommitDate: 2025-01-13 19:29:31 +0000 mb_unmapped_to_ext(): return error code on error to allow to distinguish the causes of failure. Reviewed by: markj Sponsored by: NVidia networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D48265 --- sys/kern/kern_mbuf.c | 41 +++++++++++++++++++++++++++-------------- sys/sys/mbuf.h | 2 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 73c98209474a..26be33658ab9 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -936,8 +936,8 @@ mb_unmapped_free_mext(struct mbuf *m) mb_free_extpg(old_m); } -static struct mbuf * -_mb_unmapped_to_ext(struct mbuf *m) +static int +_mb_unmapped_to_ext(struct mbuf *m, struct mbuf **mres) { struct mbuf *m_new, *top, *prev, *mref; struct sf_buf *sf; @@ -947,9 +947,15 @@ _mb_unmapped_to_ext(struct mbuf *m) u_int ref_inc = 0; M_ASSERTEXTPG(m); + + if (m->m_epg_tls != NULL) { + /* can't convert TLS mbuf */ + m_freem(m); + *mres = NULL; + return (EINVAL); + } + len = m->m_len; - KASSERT(m->m_epg_tls == NULL, ("%s: can't convert TLS mbuf %p", - __func__, m)); /* See if this is the mbuf that holds the embedded refcount. */ if (m->m_ext.ext_flags & EXT_FLAG_EMBREF) { @@ -1048,7 +1054,8 @@ _mb_unmapped_to_ext(struct mbuf *m) atomic_add_int(refcnt, ref_inc); } m_free(m); - return (top); + *mres = top; + return (0); fail: if (ref_inc != 0) { @@ -1065,13 +1072,15 @@ fail: } m_free(m); m_freem(top); - return (NULL); + *mres = NULL; + return (ENOMEM); } -struct mbuf * -mb_unmapped_to_ext(struct mbuf *top) +int +mb_unmapped_to_ext(struct mbuf *top, struct mbuf **mres) { - struct mbuf *m, *next, *prev = NULL; + struct mbuf *m, *m1, *next, *prev = NULL; + int error; prev = NULL; for (m = top; m != NULL; m = next) { @@ -1087,12 +1096,15 @@ mb_unmapped_to_ext(struct mbuf *top) */ prev->m_next = NULL; } - m = _mb_unmapped_to_ext(m); - if (m == NULL) { - m_freem(top); + error = _mb_unmapped_to_ext(m, &m1); + if (error != 0) { + if (top != m) + m_free(top); m_freem(next); - return (NULL); + *mres = NULL; + return (error); } + m = m1; if (prev == NULL) { top = m; } else { @@ -1111,7 +1123,8 @@ mb_unmapped_to_ext(struct mbuf *top) prev = m; } } - return (top); + *mres = top; + return (0); } /* diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 434f29feddcf..9373a3c3d656 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -813,7 +813,7 @@ struct mbuf *mb_alloc_ext_plus_pages(int, int); struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int, struct mbuf **); int mb_unmapped_compress(struct mbuf *m); -struct mbuf *mb_unmapped_to_ext(struct mbuf *m); +int mb_unmapped_to_ext(struct mbuf *m, struct mbuf **mres); void mb_free_notready(struct mbuf *m, int count); void m_adj(struct mbuf *, int); void m_adj_decap(struct mbuf *, int);