diff mbox series

[net-next] net: do not inline rtnl_calcit()

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

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 18 this patch: 18
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 821 this patch: 821
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 821 this patch: 821
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 6 this patch: 6
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet July 9, 2024, 11:08 p.m. UTC
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(-)

Comments

Jakub Kicinski July 10, 2024, 1:23 a.m. UTC | #1
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.
Eric Dumazet July 10, 2024, 3:08 p.m. UTC | #2
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 mbox series

Patch

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;