* [PATCH net-next] net: generalize calculation of skb extensions length
@ 2023-08-22 6:51 Thomas Weißschuh
2023-08-23 1:46 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2023-08-22 6:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Robert Marko, Thomas Weißschuh
Remove the necessity to modify skb_ext_total_length() when new extension
types are added.
Also reduces the line count a bit.
With optimizations enabled the function is folded down to a constant
value as before.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
net/core/skbuff.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index faa6c86da2a5..45707059082f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4785,23 +4785,13 @@ static const u8 skb_ext_type_len[] = {
static __always_inline unsigned int skb_ext_total_length(void)
{
- return SKB_EXT_CHUNKSIZEOF(struct skb_ext) +
-#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
- skb_ext_type_len[SKB_EXT_BRIDGE_NF] +
-#endif
-#ifdef CONFIG_XFRM
- skb_ext_type_len[SKB_EXT_SEC_PATH] +
-#endif
-#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
- skb_ext_type_len[TC_SKB_EXT] +
-#endif
-#if IS_ENABLED(CONFIG_MPTCP)
- skb_ext_type_len[SKB_EXT_MPTCP] +
-#endif
-#if IS_ENABLED(CONFIG_MCTP_FLOWS)
- skb_ext_type_len[SKB_EXT_MCTP] +
-#endif
- 0;
+ unsigned int l = SKB_EXT_CHUNKSIZEOF(struct skb_ext);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(skb_ext_type_len); i++)
+ l += skb_ext_type_len[i];
+
+ return l;
}
static void skb_extensions_init(void)
---
base-commit: 90308679c297ffcbb317c715ef434e9fb3c881dc
change-id: 20230822-skb_ext-simplify-3d93ceb95f62
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: generalize calculation of skb extensions length
2023-08-22 6:51 [PATCH net-next] net: generalize calculation of skb extensions length Thomas Weißschuh
@ 2023-08-23 1:46 ` Jakub Kicinski
2023-08-23 8:14 ` linux
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2023-08-23 1:46 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, netdev, linux-kernel,
Robert Marko
On Tue, 22 Aug 2023 08:51:57 +0200 Thomas Weißschuh wrote:
> Remove the necessity to modify skb_ext_total_length() when new extension
> types are added.
> Also reduces the line count a bit.
>
> With optimizations enabled the function is folded down to a constant
> value as before.
Could you include more info about the compiler versions you tried
and maybe some objdump? We'll have to take your word for it getting
optimized out, would be great if we had more proof in the commit msg.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: generalize calculation of skb extensions length
2023-08-23 1:46 ` Jakub Kicinski
@ 2023-08-23 8:14 ` linux
2023-08-23 14:53 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: linux @ 2023-08-23 8:14 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Thomas Weißschuh, David S. Miller, Eric Dumazet, Paolo Abeni,
netdev, linux-kernel, Robert Marko
Hi Jakub,
Aug 23, 2023 03:46:48 Jakub Kicinski <kuba@kernel.org>:
> On Tue, 22 Aug 2023 08:51:57 +0200 Thomas Weißschuh wrote:
>> Remove the necessity to modify skb_ext_total_length() when new extension
>> types are added.
>> Also reduces the line count a bit.
>>
>> With optimizations enabled the function is folded down to a constant
>> value as before.
>
> Could you include more info about the compiler versions you tried
> and maybe some objdump? We'll have to take your word for it getting
> optimized out, would be great if we had more proof in the commit msg.
> --
> pw-bot: cr
Thanks for the feedback.
I'll send a v2 with more background soon.
On the other hand this function is only ever
executed once, so even if it is slightly inefficient
it shouldn't matter.
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: generalize calculation of skb extensions length
2023-08-23 8:14 ` linux
@ 2023-08-23 14:53 ` Jakub Kicinski
2023-08-24 13:02 ` Sabrina Dubroca
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2023-08-23 14:53 UTC (permalink / raw)
To: linux
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, netdev, linux-kernel,
Robert Marko
On Wed, 23 Aug 2023 10:14:48 +0200 (GMT+02:00) linux@weissschuh.net
wrote:
> > Could you include more info about the compiler versions you tried
> > and maybe some objdump? We'll have to take your word for it getting
> > optimized out, would be great if we had more proof in the commit msg.
> > --
> > pw-bot: cr
>
> Thanks for the feedback.
> I'll send a v2 with more background soon.
>
> On the other hand this function is only ever
> executed once, so even if it is slightly inefficient
> it shouldn't matter.
Oh you're right, somehow I thought it was for every alloc.
You can mention it's only run at init in the commit msg if
that's easier.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: generalize calculation of skb extensions length
2023-08-23 14:53 ` Jakub Kicinski
@ 2023-08-24 13:02 ` Sabrina Dubroca
0 siblings, 0 replies; 5+ messages in thread
From: Sabrina Dubroca @ 2023-08-24 13:02 UTC (permalink / raw)
To: Jakub Kicinski
Cc: linux, David S. Miller, Eric Dumazet, Paolo Abeni, netdev,
linux-kernel, Robert Marko
2023-08-23, 07:53:18 -0700, Jakub Kicinski wrote:
> On Wed, 23 Aug 2023 10:14:48 +0200 (GMT+02:00) linux@weissschuh.net
> wrote:
> > > Could you include more info about the compiler versions you tried
> > > and maybe some objdump? We'll have to take your word for it getting
> > > optimized out, would be great if we had more proof in the commit msg.
> > > --
> > > pw-bot: cr
> >
> > Thanks for the feedback.
> > I'll send a v2 with more background soon.
> >
> > On the other hand this function is only ever
> > executed once, so even if it is slightly inefficient
> > it shouldn't matter.
>
> Oh you're right, somehow I thought it was for every alloc.
> You can mention it's only run at init in the commit msg if
> that's easier.
We could also add __init annotations to skb_ext_total_length and
skb_extensions_init to make that clearer.
--
Sabrina
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-24 13:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 6:51 [PATCH net-next] net: generalize calculation of skb extensions length Thomas Weißschuh
2023-08-23 1:46 ` Jakub Kicinski
2023-08-23 8:14 ` linux
2023-08-23 14:53 ` Jakub Kicinski
2023-08-24 13:02 ` Sabrina Dubroca
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).