Message ID | 20240709230815.2717872-1-edumazet@google.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: do not inline rtnl_calcit() | expand |
On Tue, 9 Jul 2024 23:08:15 +0000 Eric Dumazet wrote: > -static u32 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh) > +static noinline_for_stack u32 rtnl_calcit(struct sk_buff *skb, > + struct nlmsghdr *nlh) We only look at a single attribute - IFLA_EXT_MASK. We can change the tb size to IFLA_EXT_MASK + 1 and pass IFLA_EXT_MASK as max_attr to parse. Parsing the other attrs is pointless, anyway. Or possibly just walk the attrs with nla_for_each_attr_type() without parsing at all.
On Tue, Jul 9, 2024 at 6:23 PM Jakub Kicinski <kuba@kernel.org> wrote: > > On Tue, 9 Jul 2024 23:08:15 +0000 Eric Dumazet wrote: > > -static u32 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh) > > +static noinline_for_stack u32 rtnl_calcit(struct sk_buff *skb, > > + struct nlmsghdr *nlh) > > We only look at a single attribute - IFLA_EXT_MASK. We can change the > tb size to IFLA_EXT_MASK + 1 and pass IFLA_EXT_MASK as max_attr to > parse. Parsing the other attrs is pointless, anyway. > > Or possibly just walk the attrs with nla_for_each_attr_type() without > parsing at all. I certainly can do this, thanks for the suggestion.
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index eabfc8290f5e29f2ef3e5c1481715ae9056ea689..842d315675d5c749a0a1b62fd67afdc1d8046812 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3969,7 +3969,8 @@ static int rtnl_dellinkprop(struct sk_buff *skb, struct nlmsghdr *nlh, return rtnl_linkprop(RTM_DELLINKPROP, skb, nlh, extack); } -static u32 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh) +static noinline_for_stack u32 rtnl_calcit(struct sk_buff *skb, + struct nlmsghdr *nlh) { struct net *net = sock_net(skb->sk); size_t min_ifinfo_dump_size = 0;
IFLA_MAX is increasing slowly but surely. Use noinline_for_stack attribute to not inline rtnl_calcit() in its unique caller (rtnetlink_rcv_msg()) to save stack space. Signed-off-by: Eric Dumazet <edumazet@google.com> --- net/core/rtnetlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)