ftrace: change the export format of trace_kfree_skb()
Subsystems (3)
PATCH RESEND 1/1 ftrace: change the export format of trace_kfree_skb()
Use %pf instead of %p to output the function's address, use 0x%04X instead of %u to output the skb's protocol
Before patch:
<idle>-0 [000] 60144.542521: kfree_skb: skbaddr=de7b8240 protocol=2048 location=c1365429
<idle>-0 [000] 60164.488153: kfree_skb: skbaddr=da66f900 protocol=2048 location=c1365429
<idle>-0 [000] 60193.493933: kfree_skb: skbaddr=deaeb480 protocol=4 location=c134ec25
<idle>-0 [000] 60253.118421: kfree_skb: skbaddr=de7c4900 protocol=4 location=c134ec25After patch:
bash-2587 [001] 97685.781173: kfree_skb: skbaddr=deb9cc00 protocol=0x0000 location=netlink_unicast
bash-2587 [000] 97686.501121: kfree_skb: skbaddr=df9bb840 protocol=0x0000 location=netlink_unicast
<idle>-0 [000] 97696.200184: kfree_skb: skbaddr=df741240 protocol=0x0800 location=ip_rcv
<idle>-0 [000] 97696.200198: kfree_skb: skbaddr=dfb3de40 protocol=0x0800 location=ip_rcv---
Recover the file mode of include/trace/events/skb.h
--- include/trace/events/skb.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/trace/events/skb.h +1 -1
@@ -30,7 +30,7 @@ TRACE_EVENT(kfree_skb, __entry->location = location; ), -TP_printk ("skbaddr=%p protocol=%u location=%p" , +TP_printk ("skbaddr=%p protocol=0x%04X location=%pf" , __entry->skbaddr, __entry->protocol, __entry->location) );
Signature · 1 line
1.6.1.2
Quoted 10 lines · Xiao Guangrong
Use %pf instead of %p to output the function's address, use 0x%04X instead of %u to output the skb's protocol
Before patch:
<idle>-0 [000] 60144.542521: kfree_skb: skbaddr=de7b8240 protocol=2048 location=c1365429 <idle>-0 [000] 60164.488153: kfree_skb: skbaddr=da66f900 protocol=2048 location=c1365429 <idle>-0 [000] 60193.493933: kfree_skb: skbaddr=deaeb480 protocol=4 location=c134ec25 <idle>-0 [000] 60253.118421: kfree_skb: skbaddr=de7c4900 protocol=4 location=c134ec25
Quoted 8 lines
After patch:
bash-2587 [001] 97685.781173: kfree_skb: skbaddr=deb9cc00 protocol=0x0000 location=netlink_unicast bash-2587 [000] 97686.501121: kfree_skb: skbaddr=df9bb840 protocol=0x0000 location=netlink_unicast <idle>-0 [000] 97696.200184: kfree_skb: skbaddr=df741240 protocol=0x0800 location=ip_rcv <idle>-0 [000] 97696.200198: kfree_skb: skbaddr=dfb3de40 protocol=0x0800 location=ip_rcvSigned-off-by Xiao Guangrong <[email protected]>
Would you also be interested in adding the conversion from raw numeric protocol to its name defined in include/linux/if_ether.h
I guess __print_flags() can be used for that.
Thanks,
Frederic.
Quoted 24 lines
---
Recover the file mode of
include/trace/events/skb.h--- include/trace/events/skb.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)include/trace/events/skb.h +1
-1@@ -30,7 +30,7 @@ TRACE_EVENT(kfree_skb, __entry->location = location; ), -TP_printk ("skbaddr=%p protocol=%u location=%p" , +TP_printk ("skbaddr=%p protocol=0x%04X location=%pf" , __entry->skbaddr, __entry->protocol, __entry->location) );Signature · 1 line
1.6.1.2
Quoted 6 lines · Frederic Weisbecker
Would you also be interested in adding the conversion from raw numeric protocol to its name defined in
include/linux/if_ether.h
Hi Frederic:
OK, I'll do it.
Quoted 2 lines
I guess
__print_flags()can be used for that.
Thanks for you suggestion.
IMHO, __print_symbolic() is more suitable for this. :-)
Quoted 6 lines
Thanks,
Frederic.
Steven Rostedt
maintainerQuoted 12 lines · Xiao Guangrong
Quoted 6 lines · Frederic Weisbecker
Would you also be interested in adding the conversion from raw numeric protocol to its name defined in
include/linux/if_ether.hHi Frederic:
Quoted 7 lines
OK, I'll do it.
Quoted 2 lines
I guess
__print_flags()can be used for that.Thanks for you suggestion.
IMHO,__print_symbolic()is more suitable for this. :-)
BTW, you might want to take a look at what is coming:
http://marc.info/?l=linux-kernel&m=124458472931447&w=2
-- Steve
Quoted 5 lines · Xiao Guangrong
Quoted 1 line · Frederic Weisbecker
Quoted 8 lines
Quoted 5 lines
Would you also be interested in adding the conversion from raw numeric protocol to its name defined in
include/linux/if_ether.hHi Frederic:
OK, I'll do it.
Thanks!
Quoted 6 lines
Quoted 3 lines
I guess
__print_flags()can be used for that.Thanks for you suggestion.
IMHO,__print_symbolic()is more suitable for this. :-)
Heh, indeed :)
Quoted 6 lines
Quoted 6 lines
Thanks,
Frederic.
PATCH v2 1/1 ftrace: change the export format of trace_kfree_skb()
Use %pf instead of %p to output the function's address and print the protocol's name.
Before patch:
<idle>-0 [000] 60144.542521: kfree_skb: skbaddr=de7b8240 protocol=2048 location=c1365429 <idle>-0 [000] 60164.488153: kfree_skb: skbaddr=da66f900 protocol=2048 location=c1365429 <idle>-0 [000] 60193.493933: kfree_skb: skbaddr=deaeb480 protocol=4 location=c134ec25 <idle>-0 [000] 60253.118421: kfree_skb: skbaddr=de7c4900 protocol=4 location=c134ec25
After patch:
<idle>-0 [000] 169.979205: kfree_skb: skbaddr=ceddc240 protocol=ETH_P_802_2 location=netif_receive_skb
<idle>-0 [000] 172.587000: kfree_skb: skbaddr=ceddc300 protocol=ETH_P_802_2 location=netif_receive_skb
ping-3391 [000] 192.109803: kfree_skb: skbaddr=ceddc900 protocol=ETH_P_IP location=icmp_rcv
ping-3391 [000] 192.109902: kfree_skb: skbaddr=ceddc780 protocol=ETH_P_IP location=icmp_rcvChangelog v1->v2:
Convert protocol from raw numeric to its name as Frederic's suggestion
--- include/trace/events/skb.h | 70 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 68 insertions(+), 2 deletions(-)
include/trace/events/skb.h +68 -2
@@ -7,6 +7,71 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM skb +#define protocol_name (protocol) { protocol, #protocol } +#define show_protocol_name (val) \ + __print_symbolic(val, \ + protocol_name(ETH_P_LOOP), \ + protocol_name(ETH_P_PUP), \ + protocol_name(ETH_P_PUPAT), \ + protocol_name(ETH_P_IP), \ + protocol_name(ETH_P_X25), \ + protocol_name(ETH_P_ARP), \ + protocol_name(ETH_P_BPQ), \ + protocol_name(ETH_P_IEEEPUP), \ + protocol_name(ETH_P_IEEEPUPAT), \ + protocol_name(ETH_P_DEC), \ + protocol_name(ETH_P_DNA_DL), \ + protocol_name(ETH_P_DNA_RC), \ + protocol_name(ETH_P_DNA_RT), \ + protocol_name(ETH_P_LAT), \ + protocol_name(ETH_P_DIAG), \ + protocol_name(ETH_P_CUST), \ + protocol_name(ETH_P_SCA), \ + protocol_name(ETH_P_TEB), \ + protocol_name(ETH_P_RARP), \ + protocol_name(ETH_P_ATALK), \ + protocol_name(ETH_P_AARP), \ + protocol_name(ETH_P_8021Q), \ + protocol_name(ETH_P_IPX), \ + protocol_name(ETH_P_IPV6), \ + protocol_name(ETH_P_PAUSE), \ + protocol_name(ETH_P_SLOW), \ + protocol_name(ETH_P_WCCP), \ + protocol_name(ETH_P_PPP_DISC), \ + protocol_name(ETH_P_PPP_SES), \ + protocol_name(ETH_P_MPLS_UC), \ + protocol_name(ETH_P_MPLS_MC), \ + protocol_name(ETH_P_ATMMPOA), \ + protocol_name(ETH_P_ATMFATE), \ + protocol_name(ETH_P_PAE), \ + protocol_name(ETH_P_AOE), \ + protocol_name(ETH_P_TIPC), \ + protocol_name(ETH_P_FCOE), \ + protocol_name(ETH_P_FIP), \ + protocol_name(ETH_P_EDSA), \ + protocol_name(ETH_P_802_3), \ + protocol_name(ETH_P_AX25), \ + protocol_name(ETH_P_ALL), \ + protocol_name(ETH_P_802_2), \ + protocol_name(ETH_P_SNAP), \ + protocol_name(ETH_P_DDCMP), \ + protocol_name(ETH_P_WAN_PPP), \ + protocol_name(ETH_P_PPP_MP), \ + protocol_name(ETH_P_LOCALTALK), \ + protocol_name(ETH_P_CAN), \ + protocol_name(ETH_P_PPPTALK), \ + protocol_name(ETH_P_TR_802_2), \ + protocol_name(ETH_P_MOBITEX), \ + protocol_name(ETH_P_CONTROL), \ + protocol_name(ETH_P_IRDA), \ + protocol_name(ETH_P_ECONET), \ + protocol_name(ETH_P_HDLC), \ + protocol_name(ETH_P_ARCNET), \ + protocol_name(ETH_P_DSA), \ + protocol_name(ETH_P_TRAILER), \ + protocol_name(ETH_P_PHONET), \ + protocol_name(ETH_P_IEEE802154)) +/* * Tracepoint for free an sk_buff: */
@@ -30,8 +95,9 @@ TRACE_EVENT(kfree_skb, __entry->location = location; ), -TP_printk ("skbaddr=%p protocol=%u location=%p" , - __entry->skbaddr, __entry->protocol, __entry->location) +TP_printk ("skbaddr=%p protocol=%s location=%pf" , + __entry->skbaddr,show_protocol_name (__entry->protocol), + __entry->location) );#endif /* _TRACE_SKB_H */
Signature · 1 line
1.6.1.2
Quoted 31 lines · Xiao Guangrong
Use %pf instead of %p to output the function's address and print the protocol's name.
Before patch:
<idle>-0 [000] 60144.542521: kfree_skb: skbaddr=de7b8240 protocol=2048 location=c1365429 <idle>-0 [000] 60164.488153: kfree_skb: skbaddr=da66f900 protocol=2048 location=c1365429 <idle>-0 [000] 60193.493933: kfree_skb: skbaddr=deaeb480 protocol=4 location=c134ec25 <idle>-0 [000] 60253.118421: kfree_skb: skbaddr=de7c4900 protocol=4 location=c134ec25After patch:
<idle>-0 [000] 169.979205: kfree_skb: skbaddr=ceddc240 protocol=ETH_P_802_2 location=netif_receive_skb <idle>-0 [000] 172.587000: kfree_skb: skbaddr=ceddc300 protocol=ETH_P_802_2 location=netif_receive_skb ping-3391 [000] 192.109803: kfree_skb: skbaddr=ceddc900 protocol=ETH_P_IP location=icmp_rcv ping-3391 [000] 192.109902: kfree_skb: skbaddr=ceddc780 protocol=ETH_P_IP location=icmp_rcvChangelog
v1->v2:
Convert protocol from raw numeric to its name as Frederic's suggestionSigned-off-by Xiao Guangrong <[email protected]>--- include/trace/events/skb.h | 70 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 68 insertions(+), 2 deletions(-)include/trace/events/skb.h +0
-0
include/trace/events/skb.h line 12
Quoted 6 lines
include/trace/events/skb.h +3
-0@@ -7,6 +7,71 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM skb +#define protocol_name (protocol) { protocol, #protocol } +#define show_protocol_name (val) \ + __print_symbolic(val, \
Don't you need to include ftrace.h to pull in the __print_symbolic definition? Or is that always guaranteed to be included from tracepoint.h?
Neil
Quoted 1 line
Steven Rostedt
maintainerQuoted 9 lines · Neil Horman
Quoted 9 lines
include/trace/events/skb.h +0
-0@@ -7,6 +7,71 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM skb
Quoted 6 lines
include/trace/events/skb.h line 12
Quoted 3 lines
include/trace/events/skb.h +3
-0+#define protocol_name (protocol) { protocol, #protocol } +#define show_protocol_name (val) \ + __print_symbolic(val, \Don't you need to include
ftrace.hto pull in the__print_symbolicdefinition? Or is that always guaranteed to be included fromtracepoint.h?
Its use is in one of the fields of TRACE_EVENT that are only used by define_trace.h. All other users will ignore it.
#define TRACE_EVENT(name, proto, args, struct, assign, print) \
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
Only name, proto, args is used. The define_trace.h will include trace/ftrace.h and that will use the struct, assign and print args.
So the answer is "no" ;-)
-- Steve
Neil Horman
Acked-byQuoted 24 lines · Steven Rostedt
Quoted 9 lines · Neil Horman
Quoted 9 lines
include/trace/events/skb.h +0
-0@@ -7,6 +7,71 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM skbQuoted 6 lines
include/trace/events/skb.h line 12
Quoted 3 lines
include/trace/events/skb.h +3
-0+#define protocol_name (protocol) { protocol, #protocol } +#define show_protocol_name (val) \ + __print_symbolic(val, \Don't you need to include
ftrace.hto pull in the__print_symbolicdefinition? Or is that always guaranteed to be included fromtracepoint.h?Its use is in one of the fields of
TRACE_EVENTthat are only used bydefine_trace.h. All other users will ignore it.#define
TRACE_EVENT(name, proto, args, struct, assign, print)\
DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
Quoted 8 lines
Only name, proto, args is used. The
define_trace.hwill includetrace/ftrace.hand that will use the struct, assign and print args.So the answer is "no" ;-)
-- Steve
Ok, thanks
Steven Rostedt
maintainerQuoted 17 lines · Xiao Guangrong
Use %pf instead of %p to output the function's address and print the protocol's name.
Before patch:
<idle>-0 [000] 60144.542521: kfree_skb: skbaddr=de7b8240 protocol=2048 location=c1365429 <idle>-0 [000] 60164.488153: kfree_skb: skbaddr=da66f900 protocol=2048 location=c1365429 <idle>-0 [000] 60193.493933: kfree_skb: skbaddr=deaeb480 protocol=4 location=c134ec25 <idle>-0 [000] 60253.118421: kfree_skb: skbaddr=de7c4900 protocol=4 location=c134ec25After patch:
<idle>-0 [000] 169.979205: kfree_skb: skbaddr=ceddc240 protocol=ETH_P_802_2 location=netif_receive_skb <idle>-0 [000] 172.587000: kfree_skb: skbaddr=ceddc300 protocol=ETH_P_802_2 location=netif_receive_skb ping-3391 [000] 192.109803: kfree_skb: skbaddr=ceddc900 protocol=ETH_P_IP location=icmp_rcv ping-3391 [000] 192.109902: kfree_skb: skbaddr=ceddc780 protocol=ETH_P_IP location=icmp_rcv
Quoted 5 lines
Changelog
v1->v2:
Convert protocol from raw numeric to its name as Frederic's suggestionSigned-off-by Xiao Guangrong <[email protected]>
I get this:
CC net/core/net-traces.o
In file included from include/trace/ftrace.h:262,
from include/trace/define_trace.h:57,
from include/trace/events/skb.h:107,
from net/core/net-traces.c:28:include/trace/events/skb.h: In function 'ftrace_raw_output_kfree_skb':include/trace/events/skb.h:78: error: 'ETH_P_IEEE802154' undeclared (first use in this function)include/trace/events/skb.h:78: error: (Each undeclared identifier is reported only onceinclude/trace/events/skb.h:78: error: for each function it appears in.)
-- Steve
Quoted 13 lines · Steven Rostedt
Quoted 5 lines
Changelog
v1->v2:
Convert protocol from raw numeric to its name as Frederic's suggestionSigned-off-by Xiao Guangrong <[email protected]>I get this:
CC
net/core/net-traces.o
In file included frominclude/trace/ftrace.h:262,from include/trace/define_trace.h:57, from include/trace/events/skb.h:107, from net/core/net-traces.c:28:
Quoted 7 lines
include/trace/events/skb.h: In function 'ftrace_raw_output_kfree_skb':include/trace/events/skb.h:78: error: 'ETH_P_IEEE802154' undeclared (first use in this function)include/trace/events/skb.h:78: error: (Each undeclared identifier is reported only onceinclude/trace/events/skb.h:78: error: for each function it appears in.)
I use Ingo's tip tree and this build error not occur in my test, I also find ETH_P_IEEE802154 is added by Sergey Lapin's patch, it's merged recently, can be found here:
http://marc.info/?l=git-commits-head&m=124515655608598&w=2
Could you check ETH_P_IEEE802154 is defined in include/linux/if_ether.h and your code is the latest?
Thanks,
Xiao Guangrong
Quoted 3 lines
-- Steve
Steven Rostedt
maintainerQuoted 25 lines · Xiao Guangrong
Quoted 13 lines · Steven Rostedt
Quoted 5 lines
Changelog
v1->v2:
Convert protocol from raw numeric to its name as Frederic's suggestionSigned-off-by Xiao Guangrong <[email protected]>I get this:
CC
net/core/net-traces.o
In file included frominclude/trace/ftrace.h:262,from include/trace/define_trace.h:57, from include/trace/events/skb.h:107, from net/core/net-traces.c:28:Quoted 7 lines
include/trace/events/skb.h: In function 'ftrace_raw_output_kfree_skb':include/trace/events/skb.h:78: error: 'ETH_P_IEEE802154' undeclared (first use in this function)include/trace/events/skb.h:78: error: (Each undeclared identifier is reported only onceinclude/trace/events/skb.h:78: error: for each function it appears in.)
Quoted 7 lines
I use Ingo's tip tree and this build error not occur in my test, I also find
ETH_P_IEEE802154is added by Sergey Lapin's patch, it's merged recently, can be found here:http://marc.info/?l=git-commits-head&m=124515655608598&w=2Could you check
ETH_P_IEEE802154is defined ininclude/linux/if_ether.hand your code is the latest?
Hmm, I just work with the tracing/* branches. If this depends on another branch, then I'll let Ingo take care of it.
-- Steve
David Miller
maintainerFWIW there are parts I don't like about this change.
It's just the show_protocol_name() bit, it's designed to always be out of date.
Nobody is going to look at trace/events/skb.h when they add a new ETH_P_* value.
We could make some include/linux/eth_protos.def file, that has lines like:
ETHERNET_PROTOCOL(ETH_P_FOO, N)
then headers that want to instantiate something like the usual ETH_P_FOO defines or this symbolic printing table define "ETHERNET_PROTOCOL" to a suitable macro and then include linux/eth_protos.def to make the expansions.
Quoted 11 lines · David Miller
FWIW there are parts I don't like about this change.
It's just the
show_protocol_name()bit, it's designed to always be out of date.Nobody is going to look at
trace/events/skb.hwhen they add a new ETH_P_* value.We could make some
include/linux/eth_protos.deffile, that has lines like:
Quoted 7 lines
ETHERNET_PROTOCOL(ETH_P_FOO, N)then headers that want to instantiate something like the usual
ETH_P_FOOdefines or this symbolic printing table define "ETHERNET_PROTOCOL" to a suitable macro and then include linux/eth_protos.def to make the expansions.
Thanks for your review and your nice solution.
I will fix it in next version. ;-)
Thanks,
Xiao