From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796304718; b=ikDRmC9idZLDAlsury+u0siG+zoO8b0YIf7BPsyLCxDK5kx4zPLQiD5IVnyN+JFgys1k SlqBZt/l+xXZZer3rHWKzzo/Gz9RofazO2/OBt1otWrGxYHSUAUU99c7xjJ8Q4LCfajBD C54zzV4EPtMb6LoIIneiyafzzJ3XmUzjbcfS/Sm/iaHtMPjyiVzlHCwPqFkhc50VNsY8l M4OXycqw3Tty19NbQFq/BW0T1X+7Lfi4Vr4f7QjTJXOk26yEv2RzWZG2r+9iSmEQQmbXq fntFUBeix5tbvhSZuE2EcIOmlGjsirN2aVR52gSXdAM5BzGtUyPF8VxhdqZvirRVNVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796304718; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=+ma0Q05okcC3OgktQEbhrre5hJOqd5L1WhUFydBw84A=; b=aimhtIOgJia2JZz8bcEcnra6VMkaEzIqNndHqcVqpw0rew48E/zxZKbKE3XLdekWSpAo JeH6+kove891hhnCv76Mkkdo43G4sCjK4SNUf+ak+2/7Krf68fwuJhU8OqbsHJqUy8fCB FB2wBhmx4jgBQqPrO611iEYYrhJakVgLzrFyUfSF2uY4DwzpKbALI0ujIJJlvf7uTXeVW vDJZlO9lcPo7eStG8VJIqWEi481psjVd93I/D1io2aop8O5cDOL6PZ48FBPEdkHk881iu seww44ji/aqaI48rxdRWSW5JeH+O6E3xbPSzgmYdxnLT+5fkpErp74tnTDPzKcL738Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FMKTGt0B; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 913E3606A335 for ; Thu, 3 Dec 2026 13:31:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FMKTGt0B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 938901F00893; Thu, 3 Dec 2026 13:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796304718; bh=+ma0Q05okcC3OgktQEbhrre5hJOqd5L1WhUFydBw84A=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FMKTGt0BdZxeEZVTF577hHdVA/gnjpuCKRxu6lOMFbVarMYpN4c2d1X5IEmiOmd16 7zGm1CnS+msyRRHaF2xIczJ+6xwERmzkBsEWrAQSZ2RYpBKJzUAKQlk0rvq2Iyo9+S GPy3An2lsibW9cE4WWmWHTU6j/C7tBeOSYQQdhRBFQbD84ZyuMKCYz0LeuQjcyEIWc cdd4kL95kWXeqPhLcFtdeGxvhZFlZ3w+smo4rYUJJTtXhiS3iTjpigzbiwLA+6UGgk 4A23wdXjDRTj01RKnxEjcBpz2JJ46VxTtVxHIWLmbar1rXcsqF2KasSaaX2xZlQFTU aLADoPQXDtKiw== Subject: Re: [PATCH net 3/3] devlink: make room for many nested instances in a dev message From: netdev-bot+sashiko@kernel.org To: przemyslaw.kitszel@intel.com Cc: netdev@vger.kernel.org, pabeni@redhat.com, willemb@google.com, donald.hunter@gmail.com, jiri@resnulli.us, intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, horms@kernel.org, andrew+netdev@lunn.ch, poros@redhat.com Date: Thu, 03 Dec 2026 13:31:57 +0000 Message-ID: <179630471718.3146.7791163240760595954@kernel.org> In-Reply-To: <20261202124956.18277-4-przemyslaw.kitszel@intel.com> References: <20261202124956.18277-4-przemyslaw.kitszel@intel.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] In `devlink_nl_get_pre_dumpit()` (net/devlink/dev.c), `cb->min_dump_alloc` is set to the largest size estimate of any… -- devlink: make room for many nested instances in a dev message This commit sizes the DEVLINK_CMD_GET doit reply and the NEW/DEL notification so they include the handles of all nested devlink instances. For the dump, it adds a start callback that sets min_dump_alloc to the largest estimated message size among the instances. It also makes devlink dumps fail with -EMSGSIZE when an instance does not fit in an empty skb. Closes: https://lore.kernel.org/netdev/20261126094321.40071-1-poros@redhat.com > diff --git a/net/devlink/dev.c b/net/devlink/dev.c > index b7e5aebf13be5..07fad82d9e1c1 100644 > --- a/net/devlink/dev.c > +++ b/net/devlink/dev.c > @@ -156,6 +156,21 @@ static int devlink_nl_nested_fill(struct sk_buff *msg, struct devlink *devlink) > return 0; > } > > +static size_t devlink_nl_dev_msg_size(struct devlink *devlink, size_t size) > +{ > + unsigned long rel_index; > + void *unused; > + > + xa_for_each(&devlink->nested_rels, rel_index, unused) > + size += devlink_rel_devlink_handle_size(rel_index); > + return size; > +} > + > +static size_t devlink_nl_dev_dump_size(struct devlink *devlink) > +{ > + return devlink_nl_dev_msg_size(devlink, 512); > +} > + [ ... ] > @@ -240,13 +257,34 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info) > return genlmsg_reply(msg, info); > } > > +int devlink_nl_get_pre_dumpit(struct netlink_callback *cb) > +{ > + struct net *net = sock_net(cb->skb->sk); > + struct devlink *devlink; > + unsigned long index; > + > + /* no instance lock, the size is only a hint for the first dump skb */ > + devlinks_xa_for_each_registered_get(net, index, devlink) { > + cb->min_dump_alloc = max(cb->min_dump_alloc, > + devlink_nl_dev_dump_size(devlink)); > + devlink_put(devlink); > + } > + return 0; > +} [Severity: Medium] Can this make "devlink dev show" fail for readers with a page-sized buffer, in setups where it worked before this patch? min_dump_alloc ends up as the largest estimate over all instances in the netns. netlink_dump() then uses it for every skb of the dump, not only the first one: net/netlink/af_netlink.c:netlink_dump() { ... alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE); max_recvmsg_len = READ_ONCE(nlk->max_recvmsg_len); if (alloc_min_size < max_recvmsg_len) { alloc_size = max_recvmsg_len; ... if (!skb) { alloc_size = alloc_min_size; ... skb_reserve(skb, skb_tailroom(skb) - alloc_size); ... } So once one instance's estimate goes over 4096, every dump skb is sized above a page. Each skb is packed with as many messages as fit, including skbs that only carry small instances with no nested devlinks. The estimate is also noticeably higher than what actually gets put. The 512 byte base in devlink_nl_dev_dump_size() is about 240 bytes more than the rest of the message (~270 bytes). devlink_nl_nested_handle_size() always counts a u64 DEVLINK_ATTR_INDEX and DEVLINK_ATTR_NETNS_ID. The put side looks like this: net/devlink/devl_internal.h:devlink_nl_put_handle() { ... if (nla_put_uint(msg, DEVLINK_ATTR_INDEX, devlink->index)) return -EMSGSIZE; ... } devlink->index is a u32, so it gets a 4 byte payload. devlink_nl_put_nested_handle() only adds the netns id when the netns differs. That is about 12 bytes of slack per same-netns handle. As a rough example, take an ice PF with about 70 SF devlinks ("auxiliary" and "ice.sf.N", about 44 bytes per handle). Its real message is about 272 + 44 * 70 = 3350 bytes, which even fit the old NLMSG_DEFAULT_SIZE buffer. Its estimate is about 512 + 56 * 70 = 4430 bytes. The SF instances are in the same netns, at about 250 bytes per message. So about 17 of them get packed into one 4430 byte skb, and iproute2 gets ENOSPC on the first recv. Before the patch, alloc_size was max_recvmsg_len (4096) and every message fit. Would it make sense to raise min_dump_alloc only for the skb that needs it? Or could the estimate be tightened so it does not cross a page when the real message does not? For the larger counts this patch targets (more than ~80 SFs, and later 256 VFs), the devlink_nl_get_doit() reply is now delivered, but it is larger than a page. So iproute2 gets ENOSPC instead of EMSGSIZE. The dump also now fails outright. Before, it listed the instances that come before the large one. Given the Closes: tag, should the commit message say that iproute2 still can't show these setups? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202124956.18277-1-przemyslaw.kitszel%40intel.com