netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: do not inline rtnl_calcit()
@ 2024-07-09 23:08 Eric Dumazet
  2024-07-10  1:23 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2024-07-09 23:08 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: netdev, eric.dumazet, Eric Dumazet

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(-)

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;
-- 
2.45.2.993.g49e7a77208-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: do not inline rtnl_calcit()
  2024-07-09 23:08 [PATCH net-next] net: do not inline rtnl_calcit() Eric Dumazet
@ 2024-07-10  1:23 ` Jakub Kicinski
  2024-07-10 15:08   ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2024-07-10  1:23 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, Paolo Abeni, netdev, eric.dumazet

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: do not inline rtnl_calcit()
  2024-07-10  1:23 ` Jakub Kicinski
@ 2024-07-10 15:08   ` Eric Dumazet
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-07-10 15:08 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: David S . Miller, Paolo Abeni, netdev, eric.dumazet

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-10 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-09 23:08 [PATCH net-next] net: do not inline rtnl_calcit() Eric Dumazet
2024-07-10  1:23 ` Jakub Kicinski
2024-07-10 15:08   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).