trace: use TP_STORE_ADDRS macro
Subsystems (4)
cover trace: use TP_STORE_ADDRS macro
From: Jason Xing <[email protected]>
Using the macro for other tracepoints use to be more concise. No functional change.
Jason Xing (3):
trace: move to TP_STORE_ADDRS related macro to net_probe_common.h
trace: use TP_STORE_ADDRS() macro in inet_sk_error_report()
trace: use TP_STORE_ADDRS() macro in inet_sock_set_state()
include/trace/events/net_probe_common.h | 29 ++++++++++++++++++++ include/trace/events/sock.h | 35 ++++--------------------- include/trace/events/tcp.h | 29 -------------------- 3 files changed, 34 insertions(+), 59 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/3 trace: move to TP_STORE_ADDRS related macro to net_probe_common.h
From: Jason Xing <[email protected]>
Put the macro into another standalone file for better extension. Some tracepoints can use this common part in the future.
--- include/trace/events/net_probe_common.h | 29 +++++++++++++++++++++++++ include/trace/events/tcp.h | 29 ------------------------- 2 files changed, 29 insertions(+), 29 deletions(-)
include/trace/events/net_probe_common.h +29 -0
@@ -41,4 +41,33 @@#endif +#define TP_STORE_V4MAPPED (__entry, saddr, daddr) \ + do { \ + struct in6_addr *pin6; \ + \ + pin6 = (struct in6_addr *)__entry->saddr_v6; \ + ipv6_addr_set_v4mapped(saddr, pin6); \ + pin6 = (struct in6_addr *)__entry->daddr_v6; \ + ipv6_addr_set_v4mapped(daddr, pin6); \ + } while (0) + +#if IS_ENABLED (CONFIG_IPV6 ) +#define TP_STORE_ADDRS (__entry, saddr, daddr, saddr6, daddr6) \ + do { \ + if (sk->sk_family == AF_INET6) { \ + struct in6_addr *pin6; \ + \ + pin6 = (struct in6_addr *)__entry->saddr_v6; \ + *pin6 = saddr6; \ + pin6 = (struct in6_addr *)__entry->daddr_v6; \ + *pin6 = daddr6; \ + } else { \ + TP_STORE_V4MAPPED(__entry, saddr, daddr); \ + } \ + } while (0) +#else +#define TP_STORE_ADDRS (__entry, saddr, daddr, saddr6, daddr6) \ + TP_STORE_V4MAPPED(__entry, saddr, daddr) +#endif +#endif
include/trace/events/tcp.h +0 -29
@@ -12,35 +12,6 @@#include <net/tcp.h> #include <linux/sock_diag.h> -#define TP_STORE_V4MAPPED (__entry, saddr, daddr) \ - do { \ - struct in6_addr *pin6; \ - \ - pin6 = (struct in6_addr *)__entry->saddr_v6; \ - ipv6_addr_set_v4mapped(saddr, pin6); \ - pin6 = (struct in6_addr *)__entry->daddr_v6; \ - ipv6_addr_set_v4mapped(daddr, pin6); \ - } while (0) - -#if IS_ENABLED (CONFIG_IPV6 ) -#define TP_STORE_ADDRS (__entry, saddr, daddr, saddr6, daddr6) \ - do { \ - if (sk->sk_family == AF_INET6) { \ - struct in6_addr *pin6; \ - \ - pin6 = (struct in6_addr *)__entry->saddr_v6; \ - *pin6 = saddr6; \ - pin6 = (struct in6_addr *)__entry->daddr_v6; \ - *pin6 = daddr6; \ - } else { \ - TP_STORE_V4MAPPED(__entry, saddr, daddr); \ - } \ - } while (0) -#else -#define TP_STORE_ADDRS (__entry, saddr, daddr, saddr6, daddr6) \ - TP_STORE_V4MAPPED(__entry, saddr, daddr) -#endif -/* * tcp event with arguments sk and skb *
Signature · 1 line
2.37.3
PATCH 2/3 trace: use TP_STORE_ADDRS() macro in inet_sk_error_report()
In reply to Jason XingFrom: Jason Xing <[email protected]>
As the title said, use the macro directly like the patch[1] did to avoid those duplications. No functional change.
[1]
commit 6a6b0b9914e7 ("tcp: Avoid preprocessor directives in tracepoint macro args")
--- include/trace/events/sock.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
include/trace/events/sock.h +3 -15
@@ -10,6 +10,7 @@#include <linux/tracepoint.h> #include <linux/ipv6.h> #include <linux/tcp.h> +#include <trace/events/net_probe_common.h> #define family_names \ EM(AF_INET) \
@@ -223,7 +224,6 @@ TRACE_EVENT(inet_sk_error_report,TP_fast_assign ( const struct inet_sock *inet = inet_sk(sk); -struct in6_addr *pin6;__be32 *p32; __entry->error = sk->sk_err;
@@ -238,20 +238,8 @@ TRACE_EVENT(inet_sk_error_report, p32 = (__be32 *) __entry->daddr; *p32 = inet->inet_daddr; -#if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->saddr_v6; - *pin6 = sk->sk_v6_rcv_saddr; - pin6 = (struct in6_addr *)__entry->daddr_v6; - *pin6 = sk->sk_v6_daddr; - } else -#endif - { - pin6 = (struct in6_addr *)__entry->saddr_v6; -ipv6_addr_set_v4mapped (inet->inet_saddr, pin6); - pin6 = (struct in6_addr *)__entry->daddr_v6; -ipv6_addr_set_v4mapped (inet->inet_daddr, pin6); - } +TP_STORE_ADDRS (__entry, inet->inet_saddr, inet->inet_daddr, + sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); ), TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c error=%d",
Signature · 1 line
2.37.3
PATCH 3/3 trace: use TP_STORE_ADDRS() macro in inet_sock_set_state()
In reply to Jason XingFrom: Jason Xing <[email protected]>
As the title said, use the macro directly like the patch[1] did to avoid those duplications. No functional change.
[1]
commit 6a6b0b9914e7 ("tcp: Avoid preprocessor directives in tracepoint macro args")
--- include/trace/events/sock.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
include/trace/events/sock.h +2 -15
@@ -160,7 +160,6 @@ TRACE_EVENT(inet_sock_set_state,TP_fast_assign ( const struct inet_sock *inet = inet_sk(sk); -struct in6_addr *pin6;__be32 *p32; __entry->skaddr = sk;
@@ -178,20 +177,8 @@ TRACE_EVENT(inet_sock_set_state, p32 = (__be32 *) __entry->daddr; *p32 = inet->inet_daddr; -#if IS_ENABLED (CONFIG_IPV6 ) -if (sk->sk_family ==AF_INET6 ) { - pin6 = (struct in6_addr *)__entry->saddr_v6; - *pin6 = sk->sk_v6_rcv_saddr; - pin6 = (struct in6_addr *)__entry->daddr_v6; - *pin6 = sk->sk_v6_daddr; - } else -#endif - { - pin6 = (struct in6_addr *)__entry->saddr_v6; -ipv6_addr_set_v4mapped (inet->inet_saddr, pin6); - pin6 = (struct in6_addr *)__entry->daddr_v6; -ipv6_addr_set_v4mapped (inet->inet_daddr, pin6); - } +TP_STORE_ADDRS (__entry, inet->inet_saddr, inet->inet_daddr, + sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); ), TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
Signature · 1 line
2.37.3
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
Using the macro for other tracepoints use to be more concise. No functional change.
Quoted 7 lines
Jason Xing (3):
trace: move toTP_STORE_ADDRSrelated macro tonet_probe_common.h
trace: useTP_STORE_ADDRS()macro ininet_sk_error_report()
trace: useTP_STORE_ADDRS()macro ininet_sock_set_state()include/trace/events/net_probe_common.h | 29 ++++++++++++++++++++ include/trace/events/sock.h | 35 ++++---------------------
I just noticed that some trace files in include/trace directory (like net_probe_common.h, sock.h, skb.h, net.h, sock.h, udp.h, sctp.h, qdisc.h, neigh.h, napi.h, icmp.h, ...) are not owned by networking folks while some files (like tcp.h) have been maintained by specific maintainers/experts (like Eric) because they belong to one specific area. I wonder if we can get more networking guys involved in net tracing.
I'm not sure if 1) we can put those files into the "NETWORKING [GENERAL]" category, or 2) we can create a new category to include them all.
I know people start using BPF to trace them all instead, but I can see some good advantages of those hooks implemented in the kernel, say:
1) help those machines which are not easy to use BPF tools.
2) insert the tracepoint in the middle of some functions which cannot be replaced by bpf kprobe.
3) if we have enough tracepoints, we can generate a timeline to know/detect which flow/skb spends unexpected time at which point.
...
We can do many things in this area, I think :)
What do you think about this, Jakub, Paolo, Eric ?
Thanks,
Jason
Quoted 6 lines
include/trace/events/tcp.h | 29 -------------------- 3 files changed, 34 insertions(+), 59 deletions(-)--
2.37.3
Paolo Abeni
maintainerQuoted 23 lines · Jason Xing
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
Using the macro for other tracepoints use to be more concise. No functional change.
Quoted 7 lines
Jason Xing (3):
trace: move toTP_STORE_ADDRSrelated macro tonet_probe_common.h
trace: useTP_STORE_ADDRS()macro ininet_sk_error_report()
trace: useTP_STORE_ADDRS()macro ininet_sock_set_state()include/trace/events/net_probe_common.h | 29 ++++++++++++++++++++ include/trace/events/sock.h | 35 ++++---------------------I just noticed that some trace files in
include/tracedirectory (likenet_probe_common.h,sock.h,skb.h,net.h,sock.h,udp.h,sctp.h,qdisc.h,neigh.h,napi.h,icmp.h, ...) are not owned by networking folks while some files (liketcp.h) have been maintained by specific maintainers/experts (like Eric) because they belong to one specific area. I wonder if we can get more networking guys involved in net tracing.
Quoted 3 lines
I'm not sure if 1) we can put those files into the "NETWORKING [GENERAL]" category, or 2) we can create a new category to include them all.
I think all the file you mentioned are not under networking because of MAINTAINER file inaccuracy, and we could move there them accordingly.
Quoted 11 lines
I know people start using BPF to trace them all instead, but I can see some good advantages of those hooks implemented in the kernel, say:
1) help those machines which are not easy to use BPF tools.
2) insert the tracepoint in the middle of some functions which cannot be replaced by bpf kprobe.
3) if we have enough tracepoints, we can generate a timeline to know/detect which flow/skb spends unexpected time at which point.
...
We can do many things in this area, I think :)
Quoted 1 line
What do you think about this, Jakub, Paolo, Eric ?
I agree tracepoints are useful, but I think the general agreement is that they are the 'old way', we should try to avoid their proliferation.
Cheers,
Paolo
Quoted 25 lines · Paolo Abeni
Quoted 23 lines · Jason Xing
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
Using the macro for other tracepoints use to be more concise. No functional change.
Quoted 7 lines
Jason Xing (3):
trace: move toTP_STORE_ADDRSrelated macro tonet_probe_common.h
trace: useTP_STORE_ADDRS()macro ininet_sk_error_report()
trace: useTP_STORE_ADDRS()macro ininet_sock_set_state()include/trace/events/net_probe_common.h | 29 ++++++++++++++++++++ include/trace/events/sock.h | 35 ++++---------------------I just noticed that some trace files in
include/tracedirectory (likenet_probe_common.h,sock.h,skb.h,net.h,sock.h,udp.h,sctp.h,qdisc.h,neigh.h,napi.h,icmp.h, ...) are not owned by networking folks while some files (liketcp.h) have been maintained by specific maintainers/experts (like Eric) because they belong to one specific area. I wonder if we can get more networking guys involved in net tracing.
Quoted 6 lines
Quoted 3 lines
I'm not sure if 1) we can put those files into the "NETWORKING [GENERAL]" category, or 2) we can create a new category to include them all.
I think all the file you mentioned are not under networking because of MAINTAINER file inaccuracy, and we could move there them accordingly.
Yes, they are not under the networking category currently. So how could we move them? The MAINTAINER file doesn't have all the specific categories which are suitable for each of the trace files.
Quoted 11 lines
Quoted 11 lines
I know people start using BPF to trace them all instead, but I can see some good advantages of those hooks implemented in the kernel, say:
1) help those machines which are not easy to use BPF tools.
2) insert the tracepoint in the middle of some functions which cannot be replaced by bpf kprobe.
3) if we have enough tracepoints, we can generate a timeline to know/detect which flow/skb spends unexpected time at which point.
...
We can do many things in this area, I think :)
Quoted 5 lines
Quoted 1 line
What do you think about this, Jakub, Paolo, Eric ?
I agree tracepoints are useful, but I think the general agreement is that they are the 'old way', we should try to avoid their proliferation.
Well, it's a pity that it seems that we are about to abandon this method but it's not that friendly to the users who are unable to deploy BPF... Well, I came up with more ideas about how to improve the trace function in recent days. The motivation of doing this is that I encountered some issues which could be traced/diagnosed by using trace effortlessly without writing some bpftrace codes again and again. The status of trace seems not active but many people are still using it, I believe.
Thanks,
Jason
Quoted 5 lines
Cheers,
Paolo
Paolo Abeni
maintainerQuoted 30 lines · Jason Xing
Quoted 29 lines · Paolo Abeni
Quoted 26 lines · Jason Xing
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
Using the macro for other tracepoints use to be more concise. No functional change.
Quoted 7 lines
Jason Xing (3):
trace: move toTP_STORE_ADDRSrelated macro tonet_probe_common.h
trace: useTP_STORE_ADDRS()macro ininet_sk_error_report()
trace: useTP_STORE_ADDRS()macro ininet_sock_set_state()include/trace/events/net_probe_common.h | 29 ++++++++++++++++++++ include/trace/events/sock.h | 35 ++++---------------------I just noticed that some trace files in
include/tracedirectory (likenet_probe_common.h,sock.h,skb.h,net.h,sock.h,udp.h,sctp.h,qdisc.h,neigh.h,napi.h,icmp.h, ...) are not owned by networking folks while some files (liketcp.h) have been maintained by specific maintainers/experts (like Eric) because they belong to one specific area. I wonder if we can get more networking guys involved in net tracing.I'm not sure if 1) we can put those files into the "NETWORKING [GENERAL]" category, or 2) we can create a new category to include them all.
Quoted 6 lines
Quoted 2 lines
I think all the file you mentioned are not under networking because of MAINTAINER file inaccuracy, and we could move there them accordingly.
Yes, they are not under the networking category currently. So how could we move them? The MAINTAINER file doesn't have all the specific categories which are suitable for each of the trace files.
I think there is no need to other categories: adding the explicit 'F:' entries for such files in the NETWORKING [GENERAL] section should fit.
Quoted 16 lines
Quoted 10 lines
Quoted 10 lines
I know people start using BPF to trace them all instead, but I can see some good advantages of those hooks implemented in the kernel, say:
1) help those machines which are not easy to use BPF tools.
2) insert the tracepoint in the middle of some functions which cannot be replaced by bpf kprobe.
3) if we have enough tracepoints, we can generate a timeline to know/detect which flow/skb spends unexpected time at which point.
...
We can do many things in this area, I think :)Quoted 5 lines
Quoted 1 line
What do you think about this, Jakub, Paolo, Eric ?
I agree tracepoints are useful, but I think the general agreement is that they are the 'old way', we should try to avoid their proliferation.
Quoted 8 lines
Well, it's a pity that it seems that we are about to abandon this method but it's not that friendly to the users who are unable to deploy BPF... Well, I came up with more ideas about how to improve the trace function in recent days. The motivation of doing this is that I encountered some issues which could be traced/diagnosed by using trace effortlessly without writing some bpftrace codes again and again. The status of trace seems not active but many people are still using it, I believe.
I don't think we should abandon it completely. My understanding is that we should thing carefully before adding new tracepoints, and generally speaking, avoid adding 'too many' of them.
Cheers,
Paolo
Quoted 3 lines · Jason Xing
Well, it's a pity that it seems that we are about to abandon this method but it's not that friendly to the users who are unable to deploy BPF...
It is a pity these tracepoint patches are consuming a lot of reviewer time, just because
some people 'can not deploy BPF'
Well, I came up with more ideas about how to improve the
Quoted 5 lines
trace function in recent days. The motivation of doing this is that I encountered some issues which could be traced/diagnosed by using trace effortlessly without writing some bpftrace codes again and again. The status of trace seems not active but many people are still using it, I believe.
'Writing bpftrace codes again and again' is not a good reason to add maintenance costs
to linux networking stack.
Quoted 10 lines · Eric Dumazet
Quoted 3 lines · Jason Xing
Well, it's a pity that it seems that we are about to abandon this method but it's not that friendly to the users who are unable to deploy BPF...
It is a pity these tracepoint patches are consuming a lot of reviewer time, just because
some people 'can not deploy BPF'
Sure, not everyone can do this easily. The phenomenon still exists and we cannot ignore it. Do you remember that about a month ago someone submitted one patch introducing a new tracepoint and then I replied to/asked you if it's necessary that we replace most of the tracepoints with BPF? Now I realise and accept the fact...
I'll keep reviewing such patches and hope it can give you maintainers a break. I don't mind taking some time to do it, after all it's not a bad thing to help some people.
Quoted 11 lines
Well, I came up with more ideas about how to improve the
Quoted 5 lines
trace function in recent days. The motivation of doing this is that I encountered some issues which could be traced/diagnosed by using trace effortlessly without writing some bpftrace codes again and again. The status of trace seems not active but many people are still using it, I believe.
'Writing bpftrace codes again and again' is not a good reason to add maintenance costs
to linux networking stack.
I'm just saying :)
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Mon, 25 Mar 2024 11:43:44 +0800 you wrote:
From: Jason Xing <[email protected]>
Using the macro for other tracepoints use to be more concise. No functional change.
Jason Xing (3):
trace: move toTP_STORE_ADDRSrelated macro tonet_probe_common.h
trace: useTP_STORE_ADDRS()macro ininet_sk_error_report()
trace: useTP_STORE_ADDRS()macro ininet_sock_set_state()[...]
Here is the summary with links:
- [net-next,1/3] trace: move to TP_STORE_ADDRS related macro to net_probe_common.h
https://git.kernel.org/netdev/net-next/c/b3af9045b482 - [net-next,2/3] trace: use TP_STORE_ADDRS() macro in inet_sk_error_report() https://git.kernel.org/netdev/net-next/c/a24c855a5ef2 - [net-next,3/3] trace: use TP_STORE_ADDRS() macro in inet_sock_set_state() https://git.kernel.org/netdev/net-next/c/646700ce23f4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html