From nobody Mon Feb 9 19:05:29 2026 Received: from mail-yx1-f66.google.com (mail-yx1-f66.google.com [74.125.224.66]) (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 098CD25F78F for ; Sat, 10 Jan 2026 02:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768011550; cv=none; b=U15hcOt0BQeT5Y/C0ejnv6zLZ5Rd0QLXLMZccu4JtfxSAgsU5J1OKhK6ikoalsQPmyDhET3Mli8/jSmFtWOOEeaa6zUhjwUq3b8jMQ/KcMWKbIY+Unfow9dSqbtVu3L3cf7l70QX7GDz1iz4RmyKGFpxeCtVVnjcAIWMz2z1AGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768011550; c=relaxed/simple; bh=6tucM9ZQ59G0xrDfMuItsfF1GTt7N8xzYil/t1gA1PQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TBUwFMh7WQ1uyVChDUc44PCGaEThDtahTH4oqpVm8k94aW0NSx3XTwdwmk7tw3f9VQirs6/R9QUoxNyRHweC8KVs1u3TbPn/2BssxKq+1t4TgoIrLv6Q0A8jGQvn53vOhnZG5Yj4TNWQVofT4CBwliHAXf0rbF7i7e16LfrjLeg= 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=RRZ//9XF; arc=none smtp.client-ip=74.125.224.66 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="RRZ//9XF" Received: by mail-yx1-f66.google.com with SMTP id 956f58d0204a3-646d9eb45afso4577671d50.2 for ; Fri, 09 Jan 2026 18:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768011544; x=1768616344; 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=RRZ//9XFWutooYFdB4GTmpzjV5zZXDbguHHvTNrat3+JjePN7DsXSBz2YEoc1sBUNr CWu19+T0PsjbWWn41lO6qbwbaQCFgEKUdQZRxI6vEVYheN8zDQV/QhDWt1gK53qaLMxV wBg6p4gCF9VZK3tj0a7cQ2ddG+jgbuShYTP4Ijfwm9A1A7+pU9pml2geDMy4xT0YWuZG BqjWeoJXTdjafCZrbOD/GX980Rkv6SR8HuaMHHTTdDLCdIlDx+KBx2QN4XIEAeFvTfW7 5usfQLENdof2Bu2Z7IWiVc121bGmVIZb6qnKORdhNx18h83RXKnRXKU7JJn4RmFRM0vI zrVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768011544; x=1768616344; 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=vaNF2qLKkOTdBGM1x7YBENEcziG2W43Hjv7q0YuOvhAUjhzJK++0gEWshQ+FM8UB4Q 0UY1JWijSEq+WenYXeaqYjcDY9rO12bFugVs3DOYmd5xK5+AzbVZOIuaVJ0WUVzPDAto +jJbBgxvcDUnqYlzKKMl5UK7FHCh3KZbF2Zxe4E2OYKQZmzaW2TJR+HZnYM/t+Lkbnp0 hWG55pcfg1Ep1od8XjIwYRv+va9gyHBtyj6n/9RFlH36a7pmw1b2ms6/VaqgPpAWxWis CEnbWrvvnTTReoEjmNZCdrqrUWjWc+EHarecXhoWPL2TsLlytxvL2vWLL25ucRZfi5vU Oo9A== X-Forwarded-Encrypted: i=1; AJvYcCWBkscg8XMFmDuRKutVyGRg1YPwehyss646v2kJP5hQvMNBgufboyBdwC9pAuD1yPE/usLXFGAhaQp5eds=@vger.kernel.org X-Gm-Message-State: AOJu0YwM74LlMQWJT9qfkjG9sImTycO+r7nD217iCk7brjQKvOKsP3tq bAowdPiFcwuRYf3cQKQy49kB7uYsXB6u2PAeU7cvICI40UEtHgp/U97T X-Gm-Gg: AY/fxX6AR+G5puLIYpgUs+YT4JdNzgOUxGGGtf7PdKaflIuxCLBffJqQVBuQA5Nrqrv 4ndiel44ACoV1WfFKC8NntZE52ihjCJgDOL2OsTr7oNAfoaELic3mx4k3AdjfeZ8O9hXFEm68Ec nnVZjxV+zt1RRAGiT11FsiGRqHb6ipsOSVbYupYmVe2XQ0nc7Hoc+CNXW8aC2hQNBX5m5AyGq9T BNU6QxZ8yZEYtKsGmXvblTUe5mMbIucAQhcN5M6XGpMG8/YzrT1d0URJ8p33P/OsOoAUrqdJ7g/ OAHBfWOe25ucEAxa9/uRrni6SU+1dNkurnEIYkqWlhHyxUUDse9ymdGVMqMsv+PybUICcWo5VT8 zRl+anl+CX1/bY7i1c9nwf88/bp/sLxL8HABY1wfuF9Rh9tcHQcCfPga7gUVm+RqfS7a75Paypc eqhLqE4chDvg== X-Google-Smtp-Source: AGHT+IGzRizbGlIsAZwDp+VnMT+8idkBjcUWkmHJRYK1pkT2bOkNYQhUeyud4a1V268OgPfep68gmw== X-Received: by 2002:a05:690e:400a:b0:646:a3cf:a2e8 with SMTP id 956f58d0204a3-64716ba374amr9762926d50.40.1768011543796; Fri, 09 Jan 2026 18:19:03 -0800 (PST) Received: from localhost ([2a03:2880:25ff:53::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-790aa672725sm47421447b3.34.2026.01.09.18.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 18:19:03 -0800 (PST) From: Bobby Eshleman Date: Fri, 09 Jan 2026 18:18:18 -0800 Subject: [PATCH net-next v9 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: <20260109-scratch-bobbyeshleman-devmem-tcp-token-upstream-v9-4-8042930d00d7@meta.com> References: <20260109-scratch-bobbyeshleman-devmem-tcp-token-upstream-v9-0-8042930d00d7@meta.com> In-Reply-To: <20260109-scratch-bobbyeshleman-devmem-tcp-token-upstream-v9-0-8042930d00d7@meta.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kuniyuki Iwashima , Willem de Bruijn , Neal Cardwell , David Ahern , Mina Almasry , Arnd Bergmann , Jonathan Corbet , Andrew Lunn , Shuah Khan , Donald Hunter Cc: Stanislav Fomichev , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, 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 Reviewed-by: Mina Almasry --- 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