From nobody Thu Oct 31 20:33:18 2024 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 4XfbKp4ktjz5cKmN; Thu, 31 Oct 2024 20:33: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XfbKp4BcNz4Wh0; Thu, 31 Oct 2024 20:33:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730406798; 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=ZMq+OsHee+iU4R4gsz9tuU4P1s4kRqveCDA2Yq6IpP4=; b=SkjpFhyd+ecVxmmUR41DqqRNDNtDpr145E2cKAs1c5riFc5GIf0rhkcbai8lSRnoev7i0A 6xp4JuhO+a+WHuMWx2K9boAHS1/daCsUXfSbHweqyg56FYNCwbhA/Py2b75kRCfigWe3Ok HQXRzpj12N0G+bT6UqJ6STabVETs2PPSdabnCmSKoEhLGwUgRwagA3GxuQI4lwCOSPXGEH du3lC6hF3NtY9VVbGjsGhiCG0A96uzvfT5IrkM+FBj5ZgQnq5ypor67uETnr/uahSeK+PU nvrb45LIxHCE9cpdeotkBBC4vLeIzJQ8JAcZi7rUFMotr5nfo6JQOZd0Ok5YCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730406798; 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=ZMq+OsHee+iU4R4gsz9tuU4P1s4kRqveCDA2Yq6IpP4=; b=whCg5aTWov0v41BJyZPHHCEpfirEvNjQpBXQFCaRCOhk6K7NzCQ4NmM+9Qp8sL/wfOZ/k7 GLbw42A1axWsOLu3rfIFnoKQ3xfSGvryTBaihbcOaaGBNHERGEfkSpR5XZye+vwlKI4/aQ OkzAg/D3Zx//JBzRjxETyopr8HtAVd6mIoF/iq9wMKNvinfuHQFunEI3d+gURslopVuspl wAB/nCLO81GV2nlUuWzebUP7jVvyzpSr264RLw8wu1O670LR5Cuh9SYRoYC5J4TjMTtIxk rOPEYrDenkPVXehM0NXdV75mXDsJzISSiHxQBx0Wee1DfqBNE8wrgprAvEl2hQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730406798; a=rsa-sha256; cv=none; b=XVgtvomnZwrmiuadMLXyKvIBYyAfL8nnyki3hlY8HChbnSN453e0aw35fckFxPXCorSfRt L8bJpjAaKsnwF12zIi9dDE0y08ZNq0/en1ouXw7z7pZ6hq/PktEaBu77KFodCEGRB49/46 eFYY9EHr6fkN4XywgkpCiwKL28C5QP+hLOosMmAINnFjEB3GFSY0onLkTLHgM7spG+Pz14 n4rAy879PcP1eGBgMnL6NOhbdxxOoUV73fgh7HZp3kMyfNVgGUUf/+o1cTYAr2MoUh9HQH ZqRXy8ugDsRlShaBnvx3JWCsrS0sw24QSG5Bvd1Jc28l7wRlO8uQt+SWqIFICg== 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 4XfbKp3nvTzrBj; Thu, 31 Oct 2024 20:33:18 +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 49VKXIDH081790; Thu, 31 Oct 2024 20:33:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49VKXInx081787; Thu, 31 Oct 2024 20:33:18 GMT (envelope-from git) Date: Thu, 31 Oct 2024 20:33:18 GMT Message-Id: <202410312033.49VKXInx081787@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 314cb279959b - main - mbuf: Don't force all M_EXTPG mbufs to be read-only 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 314cb279959b08811543612a715e47266f685c7b Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=314cb279959b08811543612a715e47266f685c7b commit 314cb279959b08811543612a715e47266f685c7b Author: John Baldwin AuthorDate: 2024-10-31 20:32:31 +0000 Commit: John Baldwin CommitDate: 2024-10-31 20:32:31 +0000 mbuf: Don't force all M_EXTPG mbufs to be read-only Some M_EXTPG mbufs are read-only (e.g. those backing sendfile requests), but others are not. Add a flags argument to mb_alloc_ext_pgs that can be used to set M_RDONLY when needed rather than setting it unconditionally. Update mb_unmapped_to_ext to preserve M_RDONLY from the unmapped mbuf. Reviewed by: gallatin Differential Revision: https://reviews.freebsd.org/D46783 --- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 2 +- sys/dev/cxgbe/tom/t4_cpl_io.c | 2 +- sys/dev/iscsi/icl_soft.c | 2 +- sys/dev/nvmf/nvmf_tcp.c | 2 +- sys/fs/nfsclient/nfs_clrpcops.c | 2 +- sys/kern/kern_mbuf.c | 9 +++++---- sys/kern/kern_sendfile.c | 2 +- sys/kern/uipc_mbuf.c | 4 ++-- sys/sys/mbuf.h | 2 +- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index ab1428c06d87..c8592807f843 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -651,7 +651,7 @@ icl_cxgbei_conn_pdu_append_bio(struct icl_conn *ic, struct icl_pdu *ip, while (len > 0) { if (m == NULL) { m = mb_alloc_ext_pgs(flags & ~ICL_NOCOPY, - cxgbei_free_mext_pg); + cxgbei_free_mext_pg, 0); if (__predict_false(m == NULL)) return (ENOMEM); atomic_add_int(&icp->ref_cnt, 1); diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c index 0a40bbda3f3f..8cafac61fa8b 100644 --- a/sys/dev/cxgbe/tom/t4_cpl_io.c +++ b/sys/dev/cxgbe/tom/t4_cpl_io.c @@ -2126,7 +2126,7 @@ alloc_aiotx_mbuf(struct kaiocb *job, int len) if (npages < 0) break; - m = mb_alloc_ext_pgs(M_WAITOK, aiotx_free_pgs); + m = mb_alloc_ext_pgs(M_WAITOK, aiotx_free_pgs, M_RDONLY); m->m_epg_1st_off = pgoff; m->m_epg_npgs = npages; if (npages == 1) { diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c index 832ff8135ec5..812793a9fba3 100644 --- a/sys/dev/iscsi/icl_soft.c +++ b/sys/dev/iscsi/icl_soft.c @@ -1139,7 +1139,7 @@ icl_soft_conn_pdu_append_bio(struct icl_conn *ic, struct icl_pdu *request, while (len > 0) { if (m == NULL) { m = mb_alloc_ext_pgs(flags & ~ICL_NOCOPY, - icl_soft_free_mext_pg); + icl_soft_free_mext_pg, 0); if (__predict_false(m == NULL)) return (ENOMEM); atomic_add_int(&isp->ref_cnt, 1); diff --git a/sys/dev/nvmf/nvmf_tcp.c b/sys/dev/nvmf/nvmf_tcp.c index 22275aaa835b..2e33334b92ee 100644 --- a/sys/dev/nvmf/nvmf_tcp.c +++ b/sys/dev/nvmf/nvmf_tcp.c @@ -884,7 +884,7 @@ nvmf_tcp_mext_pg(void *arg, int how) struct nvmf_tcp_command_buffer *cb = arg; struct mbuf *m; - m = mb_alloc_ext_pgs(how, nvmf_tcp_free_mext_pg); + m = mb_alloc_ext_pgs(how, nvmf_tcp_free_mext_pg, M_RDONLY); m->m_ext.ext_arg1 = cb; tcp_hold_command_buffer(cb); return (m); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 7540893ce63c..e1c02a71939b 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -9402,7 +9402,7 @@ nfsm_split(struct mbuf *mp, uint64_t xfer) if (pgno == m->m_epg_npgs) panic("nfsm_split: eroneous ext_pgs mbuf"); - m2 = mb_alloc_ext_pgs(M_WAITOK, mb_free_mext_pgs); + m2 = mb_alloc_ext_pgs(M_WAITOK, mb_free_mext_pgs, 0); m2->m_epg_flags |= EPG_FLAG_ANON; /* diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 5c1c5b095449..73c98209474a 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -1014,7 +1014,8 @@ _mb_unmapped_to_ext(struct mbuf *m) ref_inc++; m_extadd(m_new, (char *)sf_buf_kva(sf), PAGE_SIZE, - mb_unmapped_free_mext, sf, mref, M_RDONLY, EXT_SFBUF); + mb_unmapped_free_mext, sf, mref, m->m_flags & M_RDONLY, + EXT_SFBUF); m_new->m_data += segoff; m_new->m_len = seglen; @@ -1119,7 +1120,7 @@ mb_unmapped_to_ext(struct mbuf *top) * freed. */ struct mbuf * -mb_alloc_ext_pgs(int how, m_ext_free_t ext_free) +mb_alloc_ext_pgs(int how, m_ext_free_t ext_free, int flags) { struct mbuf *m; @@ -1137,7 +1138,7 @@ mb_alloc_ext_pgs(int how, m_ext_free_t ext_free) m->m_epg_tls = NULL; m->m_epg_so = NULL; m->m_data = NULL; - m->m_flags |= (M_EXT | M_RDONLY | M_EXTPG); + m->m_flags |= M_EXT | M_EXTPG | flags; m->m_ext.ext_flags = EXT_FLAG_EMBREF; m->m_ext.ext_count = 1; m->m_ext.ext_size = 0; @@ -1709,7 +1710,7 @@ mb_alloc_ext_plus_pages(int len, int how) vm_page_t pg; int i, npgs; - m = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + m = mb_alloc_ext_pgs(how, mb_free_mext_pgs, 0); if (m == NULL) return (NULL); m->m_epg_flags |= EPG_FLAG_ANON; diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index 323e7fcde07b..05a820fe5ac1 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -1003,7 +1003,7 @@ retry_space: ext_pgs_idx++; if (ext_pgs_idx == max_pgs) { m0 = mb_alloc_ext_pgs(M_WAITOK, - sendfile_free_mext_pg); + sendfile_free_mext_pg, M_RDONLY); if (flags & SF_NOCACHE) { m0->m_ext.ext_flags |= diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index f6ce9b5cc74b..f3e2f13e89ec 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1887,7 +1887,7 @@ m_uiotombuf_nomap(struct uio *uio, int how, int len, int maxseg, int flags) * ciphersuites. */ if (__predict_false(total == 0)) { - mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs, 0); if (mb == NULL) return (NULL); mb->m_epg_flags = EPG_FLAG_ANON; @@ -1899,7 +1899,7 @@ m_uiotombuf_nomap(struct uio *uio, int how, int len, int maxseg, int flags) */ m = NULL; while (total > 0) { - mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs); + mb = mb_alloc_ext_pgs(how, mb_free_mext_pgs, 0); if (mb == NULL) goto failed; if (m == NULL) diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index ab494a76833e..434f29feddcf 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -808,7 +808,7 @@ void mb_dupcl(struct mbuf *, struct mbuf *); void mb_free_ext(struct mbuf *); void mb_free_extpg(struct mbuf *); void mb_free_mext_pgs(struct mbuf *); -struct mbuf *mb_alloc_ext_pgs(int, m_ext_free_t); +struct mbuf *mb_alloc_ext_pgs(int, m_ext_free_t, int); struct mbuf *mb_alloc_ext_plus_pages(int, int); struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int, struct mbuf **);