netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv4: remove useless arg
@ 2024-12-02  3:32 tianyu2
  2024-12-03 10:51 ` Paolo Abeni
  0 siblings, 1 reply; 5+ messages in thread
From: tianyu2 @ 2024-12-02  3:32 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

The "struct sock *sk" parameter in ip_rcv_finish_core is unused, which
leads the compiler to optimize it out. As a result, the
"struct sk_buff *skb" parameter is passed using x1. And this make kprobe
hard to use.

Signed-off-by: tianyu2 <tianyu2@kernelsoft.com>
---
 net/ipv4/ip_input.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index f0a4dda246ab..30a5e9460d00 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -314,7 +314,7 @@ static bool ip_can_use_hint(const struct sk_buff *skb, const struct iphdr *iph,
 
 int tcp_v4_early_demux(struct sk_buff *skb);
 int udp_v4_early_demux(struct sk_buff *skb);
-static int ip_rcv_finish_core(struct net *net, struct sock *sk,
+static int ip_rcv_finish_core(struct net *net,
 			      struct sk_buff *skb, struct net_device *dev,
 			      const struct sk_buff *hint)
 {
@@ -442,7 +442,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 	if (!skb)
 		return NET_RX_SUCCESS;
 
-	ret = ip_rcv_finish_core(net, sk, skb, dev, NULL);
+	ret = ip_rcv_finish_core(net, skb, dev, NULL);
 	if (ret != NET_RX_DROP)
 		ret = dst_input(skb);
 	return ret;
@@ -589,8 +589,7 @@ static struct sk_buff *ip_extract_route_hint(const struct net *net,
 	return skb;
 }
 
-static void ip_list_rcv_finish(struct net *net, struct sock *sk,
-			       struct list_head *head)
+static void ip_list_rcv_finish(struct net *net, struct list_head *head)
 {
 	struct sk_buff *skb, *next, *hint = NULL;
 	struct dst_entry *curr_dst = NULL;
@@ -607,7 +606,7 @@ static void ip_list_rcv_finish(struct net *net, struct sock *sk,
 		skb = l3mdev_ip_rcv(skb);
 		if (!skb)
 			continue;
-		if (ip_rcv_finish_core(net, sk, skb, dev, hint) == NET_RX_DROP)
+		if (ip_rcv_finish_core(net, skb, dev, hint) == NET_RX_DROP)
 			continue;
 
 		dst = skb_dst(skb);
@@ -633,7 +632,7 @@ static void ip_sublist_rcv(struct list_head *head, struct net_device *dev,
 {
 	NF_HOOK_LIST(NFPROTO_IPV4, NF_INET_PRE_ROUTING, net, NULL,
 		     head, dev, NULL, ip_rcv_finish);
-	ip_list_rcv_finish(net, NULL, head);
+	ip_list_rcv_finish(net, head);
 }
 
 /* Receive a list of IP packets */
-- 
2.27.0


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

* Re: [PATCH] ipv4: remove useless arg
  2024-12-02  3:32 [PATCH] ipv4: remove useless arg tianyu2
@ 2024-12-03 10:51 ` Paolo Abeni
  2024-12-04  3:16   ` tianyu2
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2024-12-03 10:51 UTC (permalink / raw)
  To: tianyu2, eric.dumazet, Pablo Neira Ayuso; +Cc: netdev

On 12/2/24 04:32, tianyu2 wrote:
> The "struct sock *sk" parameter in ip_rcv_finish_core is unused, which
> leads the compiler to optimize it out. As a result, the
> "struct sk_buff *skb" parameter is passed using x1. And this make kprobe
> hard to use.
> 
> Signed-off-by: tianyu2 <tianyu2@kernelsoft.com>

The patch code good, but the above does not look like a real name?!?

If so, please re-submit, using your real full name and including the
target tree (net-next in this case) in the subj prefix.

See:
https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/submitting-patches.rst#L440
https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/maintainer-netdev.rst#L12

@Pablo: after this change will be merged, I *think* that a possible
follow-up could drop the 'sk' arg from NF_HOOK_LIST and ip_rcv_finish() too.

Thanks!

Paolo


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

* Re: [PATCH] ipv4: remove useless arg
  2024-12-03 10:51 ` Paolo Abeni
@ 2024-12-04  3:16   ` tianyu2
  2024-12-04  9:16     ` Paolo Abeni
  0 siblings, 1 reply; 5+ messages in thread
From: tianyu2 @ 2024-12-04  3:16 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: eric.dumazet, Pablo Neira Ayuso, netdev




> On 12/2/24 04:32, tianyu2 wrote:
> > The "struct sock *sk" parameter in ip_rcv_finish_core is unused, which
> > leads the compiler to optimize it out. As a result, the
> > "struct sk_buff *skb" parameter is passed using x1. And this make kprobe
> > hard to use.
> > 
> > Signed-off-by: tianyu2 <tianyu2@kernelsoft.com>
> 
> The patch code good, but the above does not look like a real name?!?
> 
> If so, please re-submit, using your real full name and including the
> target tree (net-next in this case) in the subj prefix.
> 
> See:
> https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/submitting-patches.rst#L440
> https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/maintainer-netdev.rst#L12
> 
> @Pablo: after this change will be merged, I *think* that a possible
> follow-up could drop the 'sk' arg from NF_HOOK_LIST and ip_rcv_finish() too.
> 
> Thanks!
> 
> Paolo

Thank you for the reminder. I’ll adjust the patch format in the next version.

If ip_rcv_finish is modified,  NF_HOOK/NF_HOOK_LIST also needs to be adjusted. I noticed that many places use NF_HOOK. These modifications should be fine, right?

However, I found that the ip_rcv_finish function doesn’t seem to be optimized by the compiler.
(ARM64)( gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) )

ffff800080faaf9c t ip_rcv_core.isra.26
ffff800080fab334 t ip_rcv_finish_core
ffff800080fab758 t ip_rcv_finish
ffff800080fab7b4 t ip_sublist_rcv

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

* Re: [PATCH] ipv4: remove useless arg
  2024-12-04  3:16   ` tianyu2
@ 2024-12-04  9:16     ` Paolo Abeni
  2024-12-05  3:23       ` tianyu2
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2024-12-04  9:16 UTC (permalink / raw)
  To: tianyu2; +Cc: eric.dumazet, Pablo Neira Ayuso, netdev

On 12/4/24 04:16, tianyu2 wrote:
>> On 12/2/24 04:32, tianyu2 wrote:
>>> The "struct sock *sk" parameter in ip_rcv_finish_core is unused, which
>>> leads the compiler to optimize it out. As a result, the
>>> "struct sk_buff *skb" parameter is passed using x1. And this make kprobe
>>> hard to use.
>>>
>>> Signed-off-by: tianyu2 <tianyu2@kernelsoft.com>
>>
>> The patch code good, but the above does not look like a real name?!?
>>
>> If so, please re-submit, using your real full name and including the
>> target tree (net-next in this case) in the subj prefix.
>>
>> See:
>> https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/submitting-patches.rst#L440
>> https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/maintainer-netdev.rst#L12
>>
>> @Pablo: after this change will be merged, I *think* that a possible
>> follow-up could drop the 'sk' arg from NF_HOOK_LIST and ip_rcv_finish() too.
>>
>> Thanks!
>>
>> Paolo
> 
> Thank you for the reminder. I’ll adjust the patch format in the next version.
> 
> If ip_rcv_finish is modified,  NF_HOOK/NF_HOOK_LIST also needs to be adjusted. I noticed that many places use NF_HOOK. These modifications should be fine, right?

Ouch, I missed the NF_HOOK implication. Touching all NF_HOOK()
call-sites looks IMHO way to invasive to justify this change.

> However, I found that the ip_rcv_finish function doesn’t seem to be optimized by the compiler.
> (ARM64)( gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) )

FTR, that is quite an old one :) You should try with gcc 13.

Thanks,

Paolo


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

* Re: [PATCH] ipv4: remove useless arg
  2024-12-04  9:16     ` Paolo Abeni
@ 2024-12-05  3:23       ` tianyu2
  0 siblings, 0 replies; 5+ messages in thread
From: tianyu2 @ 2024-12-05  3:23 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: eric.dumazet, Pablo Neira Ayuso, netdev



> On 12/4/24 04:16, tianyu2 wrote:
> >> On 12/2/24 04:32, tianyu2 wrote:
> >>> The "struct sock *sk" parameter in ip_rcv_finish_core is unused, which
> >>> leads the compiler to optimize it out. As a result, the
> >>> "struct sk_buff *skb" parameter is passed using x1. And this make kprobe
> >>> hard to use.
> >>>
> >>> Signed-off-by: tianyu2 <tianyu2@kernelsoft.com>
> >>
> >> The patch code good, but the above does not look like a real name?!?
> >>
> >> If so, please re-submit, using your real full name and including the
> >> target tree (net-next in this case) in the subj prefix.
> >>
> >> See:
> >> https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/submitting-patches.rst#L440
> >> https://elixir.bootlin.com/linux/v6.12.1/source/Documentation/process/maintainer-netdev.rst#L12
> >>
> >> @Pablo: after this change will be merged, I *think* that a possible
> >> follow-up could drop the 'sk' arg from NF_HOOK_LIST and ip_rcv_finish() too.
> >>
> >> Thanks!
> >>
> >> Paolo
> > 
> > Thank you for the reminder. I’ll adjust the patch format in the next version.
> > 
> > If ip_rcv_finish is modified,  NF_HOOK/NF_HOOK_LIST also needs to be adjusted. I noticed that many places use NF_HOOK. These modifications should be fine, right?
> 
> Ouch, I missed the NF_HOOK implication. Touching all NF_HOOK()
> call-sites looks IMHO way to invasive to justify this change.
> 
> > However, I found that the ip_rcv_finish function doesn’t seem to be optimized by the compiler.
> > (ARM64)( gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) )
> 
> FTR, that is quite an old one :) You should try with gcc 13.


I applied my patch to the v6.13-rc1 version.And I compiled it on x86 using GCC 13.
It seems that ip_rcv_finish was not optimized.
(gcc version 13.1.0 (Ubuntu 13.1.0-8ubuntu1~22.04))


ffffffff81cc6e40 <ip_rcv_finish>:
ffffffff81cc6e40:       f3 0f 1e fa             endbr64
ffffffff81cc6e44:       48 85 d2                test   %rdx,%rdx
ffffffff81cc6e47:       74 3a                   je     ffffffff81cc6e83 <ip_rcv_finish+0x43>
ffffffff81cc6e49:       53                      push   %rbx
ffffffff81cc6e4a:       48 89 d3                mov    %rdx,%rbx
ffffffff81cc6e4d:       48 8b 52 10             mov    0x10(%rdx),%rdx
ffffffff81cc6e51:       31 c9                   xor    %ecx,%ecx
ffffffff81cc6e53:       48 89 de                mov    %rbx,%rsi
ffffffff81cc6e56:       e8 05 f0 ff ff          call   ffffffff81cc5e60 <ip_rcv_finish_core>



> 
> Thanks,
> 
> Paolo

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

end of thread, other threads:[~2024-12-05  3:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02  3:32 [PATCH] ipv4: remove useless arg tianyu2
2024-12-03 10:51 ` Paolo Abeni
2024-12-04  3:16   ` tianyu2
2024-12-04  9:16     ` Paolo Abeni
2024-12-05  3:23       ` tianyu2

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