net: do not inline rtnl_calcit()
Subsystems (2)
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
@@ -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
Jakub Kicinski
maintainernet/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.
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 toIFLA_EXT_MASK+ 1 and passIFLA_EXT_MASKasmax_attrto 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.