linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: skb: fix kfree_skb event output error in perf
@ 2022-08-25  5:37 menglong8.dong
  2022-08-25 15:31 ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: menglong8.dong @ 2022-08-25  5:37 UTC (permalink / raw)
  To: edumazet
  Cc: rostedt, mingo, davem, imagedong, dsahern, flyingpeng,
	dongli.zhang, linux-kernel

From: Menglong Dong <imagedong@tencent.com>

As Eric reported, the 'reason' field is not presented when trace the
kfree_skb event by perf:

$ perf record -e skb:kfree_skb -a sleep 10
$ perf script
  ip_defrag 14605 [021]   221.614303:   skb:kfree_skb:
  skbaddr=0xffff9d2851242700 protocol=34525 location=0xffffffffa39346b1
  reason:

The cause seems to be passing kernel address directly to TP_printk(),
which is not right.

Therefore, fix this by adding a '__string' field to the TP_STRUCT of
kfree_skb, which is 'reason_str', and passing it to TP_printk().

(Not sure if we should still keep the 'reason' field in
TP_STRUCT__entry)

Reported-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
 include/trace/events/skb.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 45264e4bb254..7235554141c3 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -24,6 +24,7 @@ TRACE_EVENT(kfree_skb,
 		__field(void *,		location)
 		__field(unsigned short,	protocol)
 		__field(enum skb_drop_reason,	reason)
+		__string(reason_str, drop_reasons[reason])
 	),
 
 	TP_fast_assign(
@@ -31,11 +32,12 @@ TRACE_EVENT(kfree_skb,
 		__entry->location = location;
 		__entry->protocol = ntohs(skb->protocol);
 		__entry->reason = reason;
+		__assign_str(reason_str, drop_reasons[reason]);
 	),
 
 	TP_printk("skbaddr=%p protocol=%u location=%p reason: %s",
 		  __entry->skbaddr, __entry->protocol, __entry->location,
-		  drop_reasons[__entry->reason])
+		  __get_str(reason_str))
 );
 
 TRACE_EVENT(consume_skb,
-- 
2.37.2


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

end of thread, other threads:[~2022-08-28  5:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25  5:37 [PATCH net-next] net: skb: fix kfree_skb event output error in perf menglong8.dong
2022-08-25 15:31 ` Eric Dumazet
2022-08-26  4:47   ` Menglong Dong
     [not found]     ` <CANn89iKVpRMDPgiQ1O6=H1M05iXX3o7rGARa1Z6HptWnAgi_Sg@mail.gmail.com>
2022-08-26 15:44       ` Menglong Dong
2022-08-26 15:53         ` Eric Dumazet
2022-08-28  5:08           ` Menglong Dong
2022-08-28  5:21           ` Menglong Dong

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