From nobody Tue Aug 20 14:05:33 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 4WpB7d43w0z5TBrt; Tue, 20 Aug 2024 14:05:33 +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 4WpB7d1Rt1z4gNQ; Tue, 20 Aug 2024 14:05:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724162733; 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=648lJqsOkKgvQXEWxEyCpW5lPKzjzuz3EkyykZLVAsc=; b=t0A1PivEMqlfDOapETz2vMaYPp0026+XNmRswSIernJsbr3UHrKd1vevPgtdNtIN+Lk1rW wvxac7DzsP6bQoVA1AJtZ9qWCPi+hWyE8mw6cXkkhRY8+PuAukSZC6GyrkKcZ3KrbANfVD oVQ7abW6tdXxU1rHVW5szgphw4FFCQBbSd3IqqzlgGkfgDhW/KiYNeChYahlDowZtNN/zL TvO4boi+VAthes9kPas5e9EsbQiomY3jhyJ5DXo/R2wd1bWiQJOJw8GRU3/RE94ZgLFHCF dRFQ6KvavzZStOXHcaiZjwFIzIpuHLiWxUuaLNQl2hiMnVNaTU3SrVgU3edKDQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724162733; a=rsa-sha256; cv=none; b=XU7WDVWFaRJe8ARpg9MLCy80KX05TqLAaQhIMQk+bOEoI7CHKYNlOQG8xMoPgWnC3TaZgi EVicaVTGlzOD18Hl1ifcBQ8R5G1JmgGOJOzQSFd/Wpbosrjno6LT6nYGYrEJlmK4MsvQDJ I9XtaKge9Dgj22kO0PUzWbYtRsA5QyE16DHdwDrWjpppVgUwa34E9LytcuTbKUIcyudA13 pHqTW4ANxI+34JHTs87zMfK2G7kxGwrrI3zJqpKKHuempwsjTZMwJrH7jUWWuDcS7ME34q h24GoliI10CNQDhkvNxGOeKOI2Z6S8xWpfcIyhJ1p7cb2ayOUcwMtZXO174ZFQ== 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=1724162733; 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=648lJqsOkKgvQXEWxEyCpW5lPKzjzuz3EkyykZLVAsc=; b=sl9lk8kc25cdT0ouvhrBtCUmUm6oXTq7cuLJYmKzSeukgYntYgaIP4d9ot1vTJdckth+CY Zzvv0osW438Xw4Wi/z9u+GSHeyTYvdm6lMDF6bSzsUw/AoBVNhikc/QYXe3KIlMtePUdHW 9Tz0Np5f5MyZpy8Zt/3vKfCIDbsu5XZqV04DJa/TjUN93jgsRln9jlcrITCkIlv56yRA4w L1BYSzTlzQr4D7RINOBdQPgA9av10Sc/4Vt3YVJR1IMzHiro2k65p/n32yOFhUtytLMc+Z buT+z/a2QkGrtmxffZzXnVkIvzX5qLvrVmQLzITWeOCvZXQI+qRD+aNWC5si2A== 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 4WpB7d11zTz13Mt; Tue, 20 Aug 2024 14:05:33 +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 47KE5Xx1091197; Tue, 20 Aug 2024 14:05:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47KE5Xnn091194; Tue, 20 Aug 2024 14:05:33 GMT (envelope-from git) Date: Tue, 20 Aug 2024 14:05:33 GMT Message-Id: <202408201405.47KE5Xnn091194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 717800323493 - stable/14 - xen/netfront: Decouple XENNET tags from mbuf lifetimes 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7178003234932e62dd552da9b39d2e6c35ed97f8 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7178003234932e62dd552da9b39d2e6c35ed97f8 commit 7178003234932e62dd552da9b39d2e6c35ed97f8 Author: Mark Johnston AuthorDate: 2024-08-02 13:09:41 +0000 Commit: Mark Johnston CommitDate: 2024-08-20 13:27:05 +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 (cherry picked from commit 2e4781cb12af2d13262ed5decf6fd95c8d58d9f5) --- 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 dafb838cf328..da0f1680a87e 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)