On Wed, Jan 21, 2026 at 08:21:36PM -0800, Mina Almasry wrote: > On Tue, Jan 20, 2026 at 5:07 PM Jakub Kicinski <[email protected]> wrote: > > > > On Thu, 15 Jan 2026 21:02:11 -0800 Bobby Eshleman wrote: > > > This series improves the CPU cost of RX token management by adding an > > > attribute to NETDEV_CMD_BIND_RX that configures sockets using the > > > binding to avoid the xarray allocator and instead use a per-binding niov > > > array and a uref field in niov. > > > > > > Improvement is ~13% cpu util per RX user thread. > > > > > > Using kperf, the following results were observed: > > > > > > Before: > > > Average RX worker idle %: 13.13, flows 4, test runs 11 > > > After: > > > Average RX worker idle %: 26.32, flows 4, test runs 11 > > > > > > Two other approaches were tested, but with no improvement. Namely, 1) > > > using a hashmap for tokens and 2) keeping an xarray of atomic counters > > > but using RCU so that the hotpath could be mostly lockless. Neither of > > > these approaches proved better than the simple array in terms of CPU. > > > > > > The attribute NETDEV_A_DMABUF_AUTORELEASE is added to toggle the > > > optimization. It is an optional attribute and defaults to 0 (i.e., > > > optimization on). > > > > IDK if the cmsg approach is still right for this flow TBH. > > IIRC when Stan talked about this a while back we were considering doing > > this via Netlink. Anything that proves that the user owns the binding > > would work. IIUC the TCP socket in this design just proves that socket > > has received a token from a given binding right? > > Doesn't 'doing this via netlink' imply it's a control path operation > that acquires rtnl_lock or netdev_lock or some heavy lock expecting > you to do some config change? Returning tokens is a data-path > operation, IIRC we don't even lock the socket to do it in the > setsockopt. > > Is there precedent/path to doing fast data-path operations via netlink? > There may be value in not biting more than we can chew in one series. > Maybe an alternative non-setsockopt dontneeding scheme should be its > own patch series. >
I'm onboard with improving what we have since it helps all of us currently using this API, though I'm not opposed to discussing a redesign in another thread/RFC. I do see the attraction to locating the core logic in one place and possibly reducing some complexity around socket/binding relationships. FWIW regarding nl, I do see it supports rtnl lock-free operations via '62256f98f244 rtnetlink: add RTNL_FLAG_DOIT_UNLOCKED' and routing was recently made lockless with that. I don't see / know of any fast path precedent. I'm aware there are some things I'm not sure about being relevant performance-wise, like hitting skb alloc an additional time every release batch. I'd want to do some minimal latency comparisons between that path and sockopt before diving head-first. Best, Bobby
