Skip to contentSkip to conversation

net: do not inline rtnl_calcit()

PATCH In review Eric Dumazet 2 participants 3 messages Jul 9, 2024 – Jul 10, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: do not inline rtnl_calcit()

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.

---
 net/core/rtnetlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/rtnetlink.c +2 -1
index eabfc8290f5e29f2ef3e5c1481715ae9056ea689..842d315675d5c749a0a1b62fd67afdc1d8046812 100644
@@ -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;
Signature · 1 line
2.45.2.993.g49e7a77208-goog
maintainer
#1 lore raw

net/core/rtnetlink.c static int rtnl_dellinkprop(struct sk_buff *skb, struct nlmsghdr *nlh, · line 3973

Quoted 3 lines · On Tue, 9 Jul 2024 23:08:15 +0000 Eric Dumazet wrote:
net/core/rtnetlink.c +2 -1
-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.

#2 lore raw
Quoted 10 lines · Jakub Kicinski

net/core/rtnetlink.c static int rtnl_dellinkprop(struct sk_buff *skb, struct nlmsghdr *nlh, · line 3973

Quoted 3 lines · On Tue, 9 Jul 2024 23:08:15 +0000 Eric Dumazet wrote:
net/core/rtnetlink.c +2 -1
-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.

Quoted 2 lines

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.