Skip to contentSkip to conversation

netdev: Add tracepoint to network/driver interface

RFC PATCH In review Koki Sanagi 2 participants 5 messages Apr 9, 2010 – Apr 12, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover netdev: Add tracepoint to network/driver interface

These patches add tracepoints to network/driver interface.

These tracepoints are helpful to investigate whether a packet passes or not. For example, when Heart Beat is disconnected, that information is helpful to investigate the cause is whether driver/device side or not.

An output is below.

  sshd-2443  [001] 68238.415621: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
<idle>-0     [001] 68238.417058: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0     [001] 68238.704363: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
  sshd-2443  [001] 68238.705459: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
<idle>-0     [001] 68238.706891: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0     [001] 68238.878736: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
  sshd-2443  [001] 68238.880361: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114

As other use case I have, we can get throughput per interface with some sort of perf scripts. I plan to create it.

Thanks
Koki Sanagi

#1 lore raw

RFC PATCH 1/2 netdev: Add tracepoint to dev_hard_start_xmit

This patch adds tracepoint to dev_hard_start_xmit. It notices that xmit packet passes network/driver interface. An output is below.

  sshd-2443  [001] 68238.415621: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
  sshd-2443  [001] 68238.705459: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
  sshd-2443  [001] 68238.880361: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
---
 include/trace/events/skb.h |   28 ++++++++++++++++++++++++++++
 net/core/dev.c             |    3 +++
 2 files changed, 31 insertions(+), 0 deletions(-)
include/trace/events/skb.h +28 -0
index 4b2be6d..425a062 100644
@@ -9,6 +9,34 @@
 #include <linux/tracepoint.h>
 
 /*
+ *  netdev_start_xmit - invoked when skb is passed to the driver
+ *  @skb:		pointer to struct sk_buff
+ *  @dev:		pointer to struct net_device
+ */
+TRACE_EVENT(netdev_start_xmit,
+
+	TP_PROTO(struct sk_buff *skb,
+		 struct net_device *dev),
+
+	TP_ARGS(skb, dev),
+
+	TP_STRUCT__entry(
+		__field(	const void *, 	skbaddr		)
+		__field(	unsigned int, 	len		)
+		__string(	name, 		dev->name	)
+       ),
+
+	TP_fast_assign(
+		__entry->skbaddr = skb;
+		__entry->len = skb->len;
+		__assign_str(name, dev->name);
+	),
+
+	TP_printk("dev=%s skbaddr=%p len=%u",
+		__get_str(name), __entry->skbaddr, __entry->len)
+);
+
+/*
  * Tracepoint for free an sk_buff:
  */
 TRACE_EVENT(kfree_skb,
net/core/dev.c +3 -0
index 2a9b7dd..4667a96 100644
@@ -129,6 +129,7 @@
 #include <linux/jhash.h>
 #include <linux/random.h>
 #include <trace/events/napi.h>
+#include <trace/events/skb.h>
 #include <linux/pci.h>
 
 #include "net-sysfs.h"
@@ -1903,6 +1904,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 		if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
 			skb_dst_drop(skb);
 
+		trace_netdev_start_xmit(skb, dev);
 		rc = ops->ndo_start_xmit(skb, dev);
 		if (rc == NETDEV_TX_OK)
 			txq_trans_update(txq);
@@ -1937,6 +1939,7 @@ gso:
 		if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
 			skb_dst_drop(nskb);
 
+		trace_netdev_start_xmit(nskb, dev);
 		rc = ops->ndo_start_xmit(nskb, dev);
 		if (unlikely(rc != NETDEV_TX_OK)) {
 			if (rc & ~NETDEV_TX_MASK)
#2 lore raw

RFC PATCH 2/2 netdev: Add tracepoint to netif_receive_skb

In reply to Koki Sanagi

This patch adds tracepoint to netif_receive_skb.
It notices that receive packet passes network/driver interface. An output is below.

<idle>-0     [001] 68238.417058: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0     [001] 68238.704363: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
<idle>-0     [001] 68238.706891: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0     [001] 68238.878736: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
---
 include/trace/events/skb.h |   28 ++++++++++++++++++++++++++++
 net/core/dev.c             |    1 +
 2 files changed, 29 insertions(+), 0 deletions(-)
include/trace/events/skb.h +28 -0
index 425a062..ca78d49 100644
@@ -37,6 +37,34 @@ TRACE_EVENT(netdev_start_xmit,
 );
 
 /*
+ * netdev_receive_skb - invoked when skb is received from the driver
+ * @skb:		pointer to struct sk_buff
+ * @dev:		pointer to struct net_device
+ */
+TRACE_EVENT(netdev_receive_skb,
+
+	TP_PROTO(struct sk_buff *skb,
+		 struct net_device *dev),
+
+	TP_ARGS(skb, dev),
+
+	TP_STRUCT__entry(
+		__field(	const void *, 	skbaddr		)
+		__field(	unsigned int, 	len		)
+		__string(	name, 		dev->name	)
+       ),
+
+	TP_fast_assign(
+		__entry->skbaddr = skb;
+		__entry->len = skb->len;
+		__assign_str(name, dev->name);
+	),
+
+	TP_printk("dev=%s skbaddr=%p len=%u",
+		__get_str(name), __entry->skbaddr, __entry->len)
+);
+
+/*
  * Tracepoint for free an sk_buff:
  */
 TRACE_EVENT(kfree_skb,
net/core/dev.c +1 -0
index 4667a96..7281286 100644
@@ -2683,6 +2683,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
 
 	__get_cpu_var(netdev_rx_stat).total++;
 
+	trace_netdev_receive_skb(skb, orig_dev);
 	skb_reset_network_header(skb);
 	skb_reset_transport_header(skb);
 	skb->mac_len = skb->network_header - skb->mac_header;
#3 lore raw
In reply to Koki Sanagi
Quoted 16 lines · Koki Sanagi

These patches add tracepoints to network/driver interface.

These tracepoints are helpful to investigate whether a packet passes or not. For example, when Heart Beat is disconnected, that information is helpful to investigate the cause is whether driver/device side or not.

An output is below.

  sshd-2443  [001] 68238.415621: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
<idle>-0     [001] 68238.417058: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0     [001] 68238.704363: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
  sshd-2443  [001] 68238.705459: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
<idle>-0     [001] 68238.706891: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0     [001] 68238.878736: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
  sshd-2443  [001] 68238.880361: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
Quoted 6 lines

As other use case I have, we can get throughput per interface with some sort of perf scripts. I plan to create it.

Thanks
Koki Sanagi

You can get a reasonable estimate of per-interface throughput using ethtool or even ifconfig in a script. What are the tracepoints needed for that? Don't get me wrong, I think these tracepoints could have some potential use thats not covered by other tools, I just don't see the above as a conclusive reason to add them.

Regards
Neil

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 20 lines · Neil Horman
Quoted 19 lines · Koki Sanagi

These patches add tracepoints to network/driver interface.

These tracepoints are helpful to investigate whether a packet passes or not. For example, when Heart Beat is disconnected, that information is helpful to investigate the cause is whether driver/device side or not.

An output is below.

   sshd-2443  [001] 68238.415621: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114

<idle>-0 [001] 68238.417058: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0 [001] 68238.704363: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
sshd-2443 [001] 68238.705459: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114
<idle>-0 [001] 68238.706891: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=52
<idle>-0 [001] 68238.878736: netdev_receive_skb: dev=eth3 skbaddr=f3c81540 len=100
sshd-2443 [001] 68238.880361: netdev_start_xmit: dev=eth3 skbaddr=f3db5138 len=114

As other use case I have, we can get throughput per interface with some sort of perf scripts. I plan to create it.

Quoted 8 lines
Quoted 3 lines

Thanks
Koki Sanagi

You can get a reasonable estimate of per-interface throughput using ethtool or even ifconfig in a script. What are the tracepoints needed for that? Don't get me wrong, I think these tracepoints could have some potential use thats not covered by other tools, I just don't see the above as a conclusive reason to add them.

Yeah, a script using ethtool or ifconfig can do same thing. But it must be poll driven. By contrast this implement using tracepoint is event-driven. It means that a record leaves on memory certainly whenever kernel crashes. It is useful to investigate network record from dump.
This is superior to ethtool or ifconfig scripts.