[PATCH v4 4/5] skb: add tracepoints to freeing skb

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Koki Sanagi
Date: Monday, August 23, 2010 - 2:46 am

This patch adds tracepoint to consume_skb and add trace_kfree_skb before
__kfree_skb in skb_free_datagram_locked and net_tx_action.
Combinating with tracepoint on dev_hard_start_xmit, we can check how long it
takes to free transmited packets. And using it, we can calculate how many
packets driver had at that time. It is useful when a drop of transmited packet
is a problem.

            sshd-6828  [000] 112689.258154: consume_skb: skbaddr=f2d99bb8

Signed-off-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
---
 include/trace/events/skb.h |   17 +++++++++++++++++
 net/core/datagram.c        |    1 +
 net/core/dev.c             |    2 ++
 net/core/skbuff.c          |    1 +
 4 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 4b2be6d..75ce9d5 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -35,6 +35,23 @@ TRACE_EVENT(kfree_skb,
 		__entry->skbaddr, __entry->protocol, __entry->location)
 );
 
+TRACE_EVENT(consume_skb,
+
+	TP_PROTO(struct sk_buff *skb),
+
+	TP_ARGS(skb),
+
+	TP_STRUCT__entry(
+		__field(	void *,	skbaddr	)
+	),
+
+	TP_fast_assign(
+		__entry->skbaddr = skb;
+	),
+
+	TP_printk("skbaddr=%p", __entry->skbaddr)
+);
+
 TRACE_EVENT(skb_copy_datagram_iovec,
 
 	TP_PROTO(const struct sk_buff *skb, int len),
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 251997a..282806b 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -243,6 +243,7 @@ void skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb)
 	unlock_sock_fast(sk, slow);
 
 	/* skb is now orphaned, can be freed outside of locked section */
+	trace_kfree_skb(skb, skb_free_datagram_locked);
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(skb_free_datagram_locked);
diff --git a/net/core/dev.c b/net/core/dev.c
index c9b026a..48f7977 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -129,6 +129,7 @@
 #include <linux/random.h>
 #include <trace/events/napi.h>
 #include <trace/events/net.h>
+#include <trace/events/skb.h>
 #include <linux/pci.h>
 
 #include "net-sysfs.h"
@@ -2589,6 +2590,7 @@ static void net_tx_action(struct softirq_action *h)
 			clist = clist->next;
 
 			WARN_ON(atomic_read(&skb->users));
+			trace_kfree_skb(skb, net_tx_action);
 			__kfree_skb(skb);
 		}
 	}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 99ef721..ef4ffa8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -466,6 +466,7 @@ void consume_skb(struct sk_buff *skb)
 		smp_rmb();
 	else if (likely(!atomic_dec_and_test(&skb->users)))
 		return;
+	trace_consume_skb(skb);
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(consume_skb);

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v4 0/5] netdev: show a process of packets, Koki Sanagi, (Mon Aug 23, 2:41 am)
[PATCH v4 1/5] irq: add tracepoint to softirq_raise, Koki Sanagi, (Mon Aug 23, 2:42 am)
[PATCH v4 4/5] skb: add tracepoints to freeing skb, Koki Sanagi, (Mon Aug 23, 2:46 am)
Re: [PATCH v4 4/5] skb: add tracepoints to freeing skb, David Miller, (Mon Aug 23, 8:53 pm)
Re: [PATCH v4 0/5] netdev: show a process of packets, Steven Rostedt, (Mon Aug 30, 4:50 pm)
Re: [PATCH v4 0/5] netdev: show a process of packets, Koki Sanagi, (Thu Sep 2, 7:10 pm)
Re: [PATCH v4 0/5] netdev: show a process of packets, David Miller, (Thu Sep 2, 7:17 pm)
Re: [PATCH v4 0/5] netdev: show a process of packets, Koki Sanagi, (Thu Sep 2, 7:55 pm)
Re: [PATCH v4 0/5] netdev: show a process of packets, Frederic Weisbecker, (Thu Sep 2, 9:46 pm)
Re: [PATCH v4 0/5] netdev: show a process of packets, Koki Sanagi, (Thu Sep 2, 10:12 pm)
Re: [PATCH v4 1/5] irq: add tracepoint to softirq_raise, Frederic Weisbecker, (Fri Sep 3, 8:29 am)
Re: [PATCH v4 1/5] irq: add tracepoint to softirq_raise, Steven Rostedt, (Fri Sep 3, 8:39 am)
Re: [PATCH v4 1/5] irq: add tracepoint to softirq_raise, Frederic Weisbecker, (Fri Sep 3, 8:42 am)
Re: [PATCH v4 1/5] irq: add tracepoint to softirq_raise, Steven Rostedt, (Fri Sep 3, 8:43 am)
Re: [PATCH v4 1/5] irq: add tracepoint to softirq_raise, Frederic Weisbecker, (Fri Sep 3, 8:50 am)
Re: [PATCH v4 5/5] perf:add a script shows a process of packet, Frederic Weisbecker, (Tue Sep 7, 9:57 am)
[tip:perf/core] irq: Add tracepoint to softirq_raise, tip-bot for Lai Jian ..., (Wed Sep 8, 1:33 am)
[tip:perf/core] napi: Convert trace_napi_poll to TRACE_EVENT, tip-bot for Neil Horman, (Wed Sep 8, 1:34 am)
[tip:perf/core] skb: Add tracepoints to freeing skb, tip-bot for Koki Sanagi, (Wed Sep 8, 1:35 am)
[tip:perf/core] perf: Add a script to show packets processing, tip-bot for Koki Sanagi, (Wed Sep 8, 1:35 am)
[PATCH] irq: Fix circular headers dependency, Frederic Weisbecker, (Wed Sep 8, 5:26 am)
[tip:perf/core] irq: Fix circular headers dependency, tip-bot for Frederic ..., (Thu Sep 9, 12:54 pm)
[PATCH] tracing: Cleanup the convoluted softirq tracepoints, Thomas Gleixner, (Tue Oct 19, 6:00 am)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Tue Oct 19, 6:22 am)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Tue Oct 19, 7:00 am)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Tue Oct 19, 7:28 am)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Tue Oct 19, 3:41 pm)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Wed Oct 20, 8:41 am)
[tip:perf/core] tracing: Cleanup the convoluted softirq tr ..., tip-bot for Thomas G ..., (Thu Oct 21, 7:52 am)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Mon Oct 25, 3:01 pm)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Mon Oct 25, 3:55 pm)
Re: [PATCH] tracing: Cleanup the convoluted softirq tracep ..., Mathieu Desnoyers, (Mon Oct 25, 6:14 pm)