From nobody Fri Aug 02 18:05:47 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 4WbDK80DdTz5S8kB; Fri, 02 Aug 2024 18:05:48 +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 4WbDK76mRpz49r0; Fri, 2 Aug 2024 18:05:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722621947; 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=NDocZG/qTTaYD1Ez96XS+1mr3+l+tjlJKEYsG0HXaEA=; b=hFOq47fW1aNE5f3Wl76ZKvL16HgTUUJQgvrYKjkVkW/uisGB+0qMlVvDtqO4MFqCEkprbP eiMSFrM3537rGLCeMzM/9j2d9ZDkklMdZxh/hgR0iQL8LWE6TS2OukX+Jijq4QZwMaHOZb Y/KUfRlnwPSvb6aEyxTCbsks1Tn5qv9o8tQhpx1WN0oexA9N+Qd7W9h/E1uMoZ6SxJAdq9 0rb2dPmHIY60iMa8DeX/u5IlWnHuUP2r8WD65SmP7DE8ZUggdqIOJOdkGZ2naXf5SWtMyv nsvALvuEKdfCi3OTR8a3zlE3eZ1G3unJqLGVaj+gFze1kS6Pr4EXxQXgeReXcA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722621947; a=rsa-sha256; cv=none; b=T/ij/dZWy/2k6Xk7My852qlPl5xmHOfqdphW77fp109P4j6lLH1ZbzDvx7TWhWvlAIRWgu ynAy4cYkWi4YiHFk0DIW+Wbf22k7LqgSuV/KGXTCN5gKWhFj6tep/4bXmaxl+tC2pdmOhu bGTXeLDGqnNuAqQMy4GW1iyjxICIPi32/mWC69SvPI2Z8d1bAXGG2OrfTFUpq1QrRk/muF GD2VYSydEykwhSd2LT1DJIJCr1rGbHHxi1N4XQM2aDEr+4a0IJzYmH9UEletPcHW92XyyT i+cnqu08SByqBWtVtgm3Xl0SzfIIqOLy6MrJVa5NNyBvuXVvrX64t10ffEMZ9g== 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=1722621947; 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=NDocZG/qTTaYD1Ez96XS+1mr3+l+tjlJKEYsG0HXaEA=; b=lqT3RFqcm/tG/6PQVx8RiT4VYP1EbxkB3hkdpgjuGzjmNG8hOTKipwW51oaKa/jdhKr4GS 38Wqo3jlg1iU0gBtQj1hiAXcFeflY/euyaNL6B6j5XiCDRU7tI8/NfnMtpbRBnlEOACyw5 9BkLoENeQ82SMHJLUrQdqOZPLXIUGFpEORTTlh9FI7Ngu7s1vAGfQ5pFP+D+sQKEmsmD5Q hlJXWWaKtSJupcS5bcFB4DA6PPmz74bTQb6UG0AJ9YEnl2Ds+InxnTmX6v/gxVBc3n7iav l1F92m4mzXYEfNbZa1CxEfPjT5zV8HPOfQQoBDC5tefcqslt9k2T7c+y1ln1wg== 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 4WbDK76FXHzf84; Fri, 2 Aug 2024 18:05:47 +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 472I5lwh025095; Fri, 2 Aug 2024 18:05:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 472I5lhT025092; Fri, 2 Aug 2024 18:05:47 GMT (envelope-from git) Date: Fri, 2 Aug 2024 18:05:47 GMT Message-Id: <202408021805.472I5lhT025092@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: 2e4781cb12af - main - xen/netfront: Decouple XENNET tags from mbuf lifetimes 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e4781cb12af2d13262ed5decf6fd95c8d58d9f5 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2e4781cb12af2d13262ed5decf6fd95c8d58d9f5 commit 2e4781cb12af2d13262ed5decf6fd95c8d58d9f5 Author: Mark Johnston AuthorDate: 2024-08-02 13:09:41 +0000 Commit: Mark Johnston CommitDate: 2024-08-02 18:05:37 +0000 xen/netfront: Decouple XENNET tags from mbuf lifetimes netmap's generic mode tries to improve performance by minimizing mbuf allocations. In service of this goal, it maintains an extra reference to the mbuf and polls the counter to see if the driver has released its reference by calling m_freem(). As a result, the extref destructor is not called when expected by the netfront driver, and mbufs tags are not freed. Modify the tx path to release its mbuf tags promptly when reclaiming tx descriptors. They are drawn from a fixed-size pool, so otherwise are quickly exhausted when a netfront interface is in netmap generic mode. Co-authored by: royger MFC after: 2 weeks Fixes: dabb3db7a817 ("xen/netfront: deal with mbuf data crossing a page boundary") Sponsored by: Cloud Software Group Sponsored by: Klara, Inc. Sponsored by: Zenarmor --- sys/dev/xen/netfront/netfront.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c index 6ac6ecc3bdb7..e13fb8765bae 100644 --- a/sys/dev/xen/netfront/netfront.c +++ b/sys/dev/xen/netfront/netfront.c @@ -335,8 +335,16 @@ static void mbuf_release(struct mbuf *m) KASSERT(ref != NULL, ("Cannot find refcount")); KASSERT(ref->count > 0, ("Invalid reference count")); - if (--ref->count == 0) + if (--ref->count == 0) { + /* + * Explicitly free the tag while we hold the tx queue lock. + * This ensures that the tag is deleted promptly in case + * something else is holding extra references to the mbuf chain, + * such as netmap. + */ + m_tag_delete(m, &ref->tag); m_freem(m); + } } static void tag_free(struct m_tag *t)