From nobody Tue Feb 10 02:49:42 2026 Received: from mail-yw1-f193.google.com (mail-yw1-f193.google.com [209.85.128.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DCC12101AE for ; Thu, 8 Jan 2026 00:58:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767833928; cv=none; b=NWUlvcJBhP9T3tA3djq2hWunvc+/w+94W4Crq2jfnNetmEsJBMLkKT+LiI1uBQfEHYeW5WO8SnjweApYobI6NdeMYnvUiXwgqByUXiyw0vZv95m2x8Ys2eUjeaBKIuMYtElaAqNtLQaa14fRLZOnHE8vPh7HbodCiPmbaB8e3GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767833928; c=relaxed/simple; bh=6tucM9ZQ59G0xrDfMuItsfF1GTt7N8xzYil/t1gA1PQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=STgcAUKVXZQ2BLoU1CH8LAO6QIxJ2IB9iDLG00YhulNf3zWcJYfyEOBb6Qxp84Wm0+R8giZ8x5AsMUGsZomPs56ZwmOPFnJLGxfBRBj6MZS+fwKd0U61hX7C8b0g8y4fIFtUXkCEWFlKNNDrGZ8HD25O8qFbauW/a8lTvNuAZKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l2QjA1Ek; arc=none smtp.client-ip=209.85.128.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l2QjA1Ek" Received: by mail-yw1-f193.google.com with SMTP id 00721157ae682-78e6dc6d6d7so29418117b3.3 for ; Wed, 07 Jan 2026 16:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767833923; x=1768438723; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DXRdbOnUYiudn9GxHVVfvuR3By+3aRth8g9ruHEmquY=; b=l2QjA1Ekya05GYHt01OxB2dyZAG1P5dMJwxi9qkXuZgkJOHcTH+LwfxBKo6PjaRmFr orpLTsra1X/PwHcIkfIUXSCKM9yGMtNWiRbk7AJEnT/cICaHlAe7on3rAMNtFrspKCDP HkLEy09D9hE7YbQWA1D+KBiobO3sAD8vZOqksl4Ed1ZxFC1spnitG4746M+oXJUOtGef Mfvgs5ki/n27Ejv2qoeB29W7ZTHniI27cZP9lE1S9OG0H9aPvvUsbPy3zD7pOxPvV8UT Xlw1cQ03tmZjfvDGPBBT6w7QzdBzsX+Nf8UQ+wDk0S4adMXN6XDS+8UCmb+rMLMCIi19 KPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767833923; x=1768438723; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=DXRdbOnUYiudn9GxHVVfvuR3By+3aRth8g9ruHEmquY=; b=NaOC6v7RDMpULqe4NGS9SwhY6GXD9cLZ9d+p3pWDivTtZJhmA29Ue4WPFiX3I2KMAy SyZ1rUzysphvWxlNJvJkjrr2NNHvH43q5+mJolgyJr/jGRGyY5hgtoMagydzCNyP3/7c UXj9sj/dyUAjHoFUFgy4Mt2pU3HSnYaUjIUeC0EihdTBKKTRt5m3PirsGdz70dCEyFON nJxwikhvBMQBHF/ynrgqYXL33TlW0GpptP51TcMtans5nVoThAhxcAKEm4RedI/2tkdT xcbemB+RqPN11uFy4W0iTsSbiA49blfL55+idMaEXNUfUYyW4ekyBnzw+l64YZVAie5u tU3w== X-Forwarded-Encrypted: i=1; AJvYcCWw1oeg4og1gDvhmZVgEx0g6cR1bLcSNJW5QCTVCY6YMwS7lYe9w/mq7PT8gA4lZkC0k0Y5uxP9jnBirBw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzr00H2XezhIgJSOWGmZq2cvvdba7WbifTu8PAJ9E2l0bsmKduJ QjgFMdUdotnGWLcL1mTANiDj44KkDfeNIF2zGEZDJW9ZpYW7a0mBZgijSV5FO0YN X-Gm-Gg: AY/fxX4EynegYs0OQynFdTsOkyf5pbk9XOHQi+bdD4Jke0kKY/hBdEH8iYaf7D4qb7I fjm4OUd0hD3l4facauMkqxzBzmRwSonVb5lBNp7jrP+6dj8Y08th5yc+DkKP64dOwlfWvrLc8CD lCG6gB/4SZ9+44GKN+Xt6i6kaHq8xpKSomCoLIb+NA/c9IEnlKUV+pr07JTe1JWiML9Zj0IhD4F 3cpPLkr8LJzxudCi0eyh79Yi1HgfG0H1y3FtzgHZOu1AyMMA6STKZBDdS1c9x7HsyIYvaH4LTLH mvRV706ITmcjOjPsFp9Bx6Aig9U2Y/dYwoKpW+COrMtz0EZm8SyXDHElXdryIb9ilKIu+rOa9kO V8O/TljeptiyqznTdClrrYYxlmlfC2UCYzCRX+h0qyrbifNrH265dUVa5eXpJSmPHndPdsH/3Mu Q0sydTq7WB X-Google-Smtp-Source: AGHT+IGSZsqPA4Z0otbmZ3NOTLwk4921dfCJ5SicHC0H7KIg1eX7bEw/y3LBIJTZ2PC9nnY65wqkaQ== X-Received: by 2002:a05:690e:419a:b0:63f:ba88:e905 with SMTP id 956f58d0204a3-64716b99817mr4126568d50.30.1767833922740; Wed, 07 Jan 2026 16:58:42 -0800 (PST) Received: from localhost ([2a03:2880:25ff:4::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6470d89d510sm2724820d50.16.2026.01.07.16.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jan 2026 16:58:42 -0800 (PST) From: Bobby Eshleman Date: Wed, 07 Jan 2026 16:57:38 -0800 Subject: [PATCH net-next v8 4/5] net: devmem: document NETDEV_A_DMABUF_AUTORELEASE netlink attribute Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260107-scratch-bobbyeshleman-devmem-tcp-token-upstream-v8-4-92c968631496@meta.com> References: <20260107-scratch-bobbyeshleman-devmem-tcp-token-upstream-v8-0-92c968631496@meta.com> In-Reply-To: <20260107-scratch-bobbyeshleman-devmem-tcp-token-upstream-v8-0-92c968631496@meta.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kuniyuki Iwashima , Willem de Bruijn , Neal Cardwell , David Ahern , Arnd Bergmann , Jonathan Corbet , Andrew Lunn , Shuah Khan , Donald Hunter , Mina Almasry Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Stanislav Fomichev , asml.silence@gmail.com, matttbe@kernel.org, skhawaja@google.com, Bobby Eshleman X-Mailer: b4 0.14.3 From: Bobby Eshleman Update devmem.rst documentation to describe the autorelease netlink attribute used during RX dmabuf binding. The autorelease attribute is specified at bind-time via the netlink API (NETDEV_CMD_BIND_RX) and controls what happens to outstanding tokens when the socket closes. Document the two token release modes (automatic vs manual), how to configure the binding for autorelease, the perf benefits, new caveats and restrictions, and the way the mode is enforced system-wide. Signed-off-by: Bobby Eshleman --- Changes in v7: - Document netlink instead of sockopt - Mention system-wide locked to one mode --- Documentation/networking/devmem.rst | 70 +++++++++++++++++++++++++++++++++= ++++ 1 file changed, 70 insertions(+) diff --git a/Documentation/networking/devmem.rst b/Documentation/networking= /devmem.rst index a6cd7236bfbd..67c63bc5a7ae 100644 --- a/Documentation/networking/devmem.rst +++ b/Documentation/networking/devmem.rst @@ -235,6 +235,76 @@ can be less than the tokens provided by the user in ca= se of: (a) an internal kernel leak bug. (b) the user passed more than 1024 frags. =20 + +Autorelease Control +~~~~~~~~~~~~~~~~~~~ + +The autorelease mode controls what happens to outstanding tokens (tokens n= ot +released via SO_DEVMEM_DONTNEED) when the socket closes. Autorelease is +configured per-binding at binding creation time via the netlink API:: + + struct netdev_bind_rx_req *req; + struct netdev_bind_rx_rsp *rsp; + struct ynl_sock *ys; + struct ynl_error yerr; + + ys =3D ynl_sock_create(&ynl_netdev_family, &yerr); + + req =3D netdev_bind_rx_req_alloc(); + netdev_bind_rx_req_set_ifindex(req, ifindex); + netdev_bind_rx_req_set_fd(req, dmabuf_fd); + netdev_bind_rx_req_set_autorelease(req, 0); /* 0 =3D manual, 1 =3D auto */ + __netdev_bind_rx_req_set_queues(req, queues, n_queues); + + rsp =3D netdev_bind_rx(ys, req); + + dmabuf_id =3D rsp->id; + +When autorelease is disabled (0): + +- Outstanding tokens are NOT released when the socket closes +- Outstanding tokens are only released when the dmabuf is unbound +- Provides better performance by eliminating xarray overhead (~13% CPU red= uction) +- Kernel tracks tokens via atomic reference counters in net_iov structures + +When autorelease is enabled (1): + +- Outstanding tokens are automatically released when the socket closes +- Backwards compatible behavior +- Kernel tracks tokens in an xarray per socket + +The default is autorelease disabled. + +Important: In both modes, applications should call SO_DEVMEM_DONTNEED to +return tokens as soon as they are done processing. The autorelease setting= only +affects what happens to tokens that are still outstanding when close() is = called. + +The mode is enforced system-wide. Once a binding is created with a specific +autorelease mode, all subsequent bindings system-wide must use the same mo= de. + + +Performance Considerations +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Disabling autorelease provides approximately ~13% CPU utilization improvem= ent +in RX workloads. That said, applications must ensure all tokens are releas= ed +via SO_DEVMEM_DONTNEED before closing the socket, otherwise the backing pa= ges +will remain pinned until the dmabuf is unbound. + + +Caveats +~~~~~~~ + +- Once a system-wide autorelease mode is selected (via the first binding), + all subsequent bindings must use the same mode. Attempts to create bindi= ngs + with a different mode will be rejected with -EINVAL. + +- Applications using manual release mode (autorelease=3D0) must ensure all= tokens + are returned via SO_DEVMEM_DONTNEED before socket close to avoid resource + leaks during the lifetime of the dmabuf binding. Tokens not released bef= ore + close() will only be freed when the dmabuf is unbound. + + TX Interface =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.47.3