[RFC patch 12/12] LTTng instrumentation net tracepoint probes

From: Mathieu Desnoyers
Date: Fri Jul 04 2008 - 19:57:15 EST


Create a module which declares net tracepoint probes, using markers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxx>
CC: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
CC: 'Peter Zijlstra' <peterz@xxxxxxxxxxxxx>
CC: "Frank Ch. Eigler" <fche@xxxxxxxxxx>
CC: 'Ingo Molnar' <mingo@xxxxxxx>
CC: 'Hideo AOKI' <haoki@xxxxxxxxxx>
CC: Takashi Nishiie <t-nishiie@xxxxxxxxxxxxxxxxxx>
CC: 'Steven Rostedt' <rostedt@xxxxxxxxxxx>
CC: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
net/Makefile | 3 +
net/net-trace.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+)

Index: linux-2.6-lttng/net/Makefile
===================================================================
--- linux-2.6-lttng.orig/net/Makefile 2008-07-04 19:16:42.000000000 -0400
+++ linux-2.6-lttng/net/Makefile 2008-07-04 19:16:44.000000000 -0400
@@ -11,6 +11,9 @@ obj-$(CONFIG_NET) := socket.o core/

tmp-$(CONFIG_COMPAT) := compat.o
obj-$(CONFIG_NET) += $(tmp-y)
+ifeq ($(CONFIG_NET),y)
+obj-$(CONFIG_TRACEPROBES) += net-trace.o
+endif

# LLC has to be linked before the files in net/802/
obj-$(CONFIG_LLC) += llc/
Index: linux-2.6-lttng/net/net-trace.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-lttng/net/net-trace.c 2008-07-04 19:19:04.000000000 -0400
@@ -0,0 +1,105 @@
+/*
+ * net/net-trace.c
+ *
+ * Net tracepoint probes.
+ */
+
+#include <linux/module.h>
+#include "net-trace.h"
+
+static void probe_net_dev_xmit(struct sk_buff *skb)
+{
+ trace_mark(net_dev_xmit, "skb %p protocol #2u%hu", skb, skb->protocol);
+}
+
+static void probe_net_dev_receive(struct sk_buff *skb)
+{
+ trace_mark(net_dev_receive, "skb %p protocol #2u%hu",
+ skb, skb->protocol);
+}
+
+static void probe_net_del_ifa_ipv4(struct in_ifaddr *ifa)
+{
+ trace_mark(net_del_ifa_ipv4, "label %s", ifa->ifa_label);
+}
+
+static void probe_net_insert_ifa_ipv4(struct in_ifaddr *ifa)
+{
+ trace_mark(net_insert_ifa_ipv4, "label %s address #4u%lu",
+ ifa->ifa_label, (unsigned long)ifa->ifa_address);
+}
+
+static void probe_net_socket_sendmsg(struct socket *sock, struct msghdr *msg,
+ size_t size, int ret)
+{
+ trace_mark(net_socket_sendmsg,
+ "sock %p family %d type %d protocol %d size %zu",
+ sock, sock->sk->sk_family, sock->sk->sk_type,
+ sock->sk->sk_protocol, size);
+}
+
+static void probe_net_socket_recvmsg(struct socket *sock, struct msghdr *msg,
+ size_t size, int flags, int ret)
+{
+ trace_mark(net_socket_recvmsg,
+ "sock %p family %d type %d protocol %d size %zu",
+ sock, sock->sk->sk_family, sock->sk->sk_type,
+ sock->sk->sk_protocol, size);
+}
+
+static void probe_net_socket_create(struct socket *sock, int fd)
+{
+ trace_mark(net_socket_create,
+ "sock %p family %d type %d protocol %d fd %d",
+ sock, sock->sk->sk_family, sock->sk->sk_type,
+ sock->sk->sk_protocol, fd);
+}
+
+static void probe_net_socket_call(int call, unsigned long a0)
+{
+ trace_mark(net_socket_call, "call %d a0 %lu", call, a0);
+}
+
+int __init net_trace_init(void)
+{
+ int ret;
+
+ ret = register_trace_net_dev_xmit(probe_net_dev_xmit);
+ WARN_ON(ret);
+ ret = register_trace_net_dev_receive(probe_net_dev_receive);
+ WARN_ON(ret);
+ ret = register_trace_net_del_ifa_ipv4(probe_net_del_ifa_ipv4);
+ WARN_ON(ret);
+ ret = register_trace_net_insert_ifa_ipv4(probe_net_insert_ifa_ipv4);
+ WARN_ON(ret);
+ ret = register_trace_net_socket_sendmsg(probe_net_socket_sendmsg);
+ WARN_ON(ret);
+ ret = register_trace_net_socket_recvmsg(probe_net_socket_recvmsg);
+ WARN_ON(ret);
+ ret = register_trace_net_socket_create(probe_net_socket_create);
+ WARN_ON(ret);
+ ret = register_trace_net_socket_call(probe_net_socket_call);
+ WARN_ON(ret);
+
+ return 0;
+}
+
+module_init(net_trace_init);
+
+void __exit net_trace_exit(void)
+{
+ unregister_trace_net_socket_call(probe_net_socket_call);
+ unregister_trace_net_socket_create(probe_net_socket_create);
+ unregister_trace_net_socket_recvmsg(probe_net_socket_recvmsg);
+ unregister_trace_net_socket_sendmsg(probe_net_socket_sendmsg);
+ unregister_trace_net_insert_ifa_ipv4(probe_net_insert_ifa_ipv4);
+ unregister_trace_net_del_ifa_ipv4(probe_net_del_ifa_ipv4);
+ unregister_trace_net_dev_receive(probe_net_dev_receive);
+ unregister_trace_net_dev_xmit(probe_net_dev_xmit);
+}
+
+module_exit(net_trace_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Net Tracepoint Probes");

--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/