summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2011-03-16 19:04:29 -0400
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>2011-03-16 19:04:29 -0400
commit9b827e2545a7ef851246dc60aade9454c1fd63a8 (patch)
tree814a0fb4a8170a4cae06bda0429944cc91bff5c7
parent29f552b77e4b67e3f40f2b508289fd4a72adf03e (diff)
lttng-instrumentation/lttng-instrumentation-socket
LTTng instrumentation - socket Instrument socket creation and activity (msg send, receive). Socket "call" instrumentation should be completed. Those tracepoints are used by LTTng. About the performance impact of tracepoints (which is comparable to markers), even without immediate values optimizations, tests done by Hideo Aoki on ia64 show no regression. His test case was using hackbench on a kernel where scheduler instrumentation (about 5 events in code scheduler code) was added. See the "Tracepoints" patch header for performance result detail. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> CC: netdev@vger.kernel.org CC: David S. Miller <davem@davemloft.net> CC: Masami Hiramatsu <mhiramat@redhat.com> CC: 'Peter Zijlstra' <peterz@infradead.org> CC: "Frank Ch. Eigler" <fche@redhat.com> CC: 'Ingo Molnar' <mingo@elte.hu> CC: 'Hideo AOKI' <haoki@redhat.com> CC: Takashi Nishiie <t-nishiie@np.css.fujitsu.com> CC: 'Steven Rostedt' <rostedt@goodmis.org> CC: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
-rw-r--r--include/trace/socket.h26
-rw-r--r--net/socket.c11
2 files changed, 37 insertions, 0 deletions
diff --git a/include/trace/socket.h b/include/trace/socket.h
new file mode 100644
index 00000000000..228b5a7c944
--- /dev/null
+++ b/include/trace/socket.h
@@ -0,0 +1,26 @@
+#ifndef _TRACE_SOCKET_H
+#define _TRACE_SOCKET_H
+
+#include <net/sock.h>
+#include <linux/tracepoint.h>
+
+DECLARE_TRACE(socket_sendmsg,
+ TP_PROTO(struct socket *sock, struct msghdr *msg, size_t size, int ret),
+ TP_ARGS(sock, msg, size, ret));
+DECLARE_TRACE(socket_recvmsg,
+ TP_PROTO(struct socket *sock, struct msghdr *msg, size_t size, int flags,
+ int ret),
+ TP_ARGS(sock, msg, size, flags, ret));
+DECLARE_TRACE(socket_create,
+ TP_PROTO(struct socket *sock, int fd),
+ TP_ARGS(sock, fd));
+/*
+ * socket_call
+ *
+ * TODO : This tracepoint should be expanded to cover each element of the
+ * switch in sys_socketcall().
+ */
+DECLARE_TRACE(socket_call,
+ TP_PROTO(int call, unsigned long a0),
+ TP_ARGS(call, a0));
+#endif
diff --git a/net/socket.c b/net/socket.c
index ac2219f90d5..319a3b8f241 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -98,6 +98,7 @@
#include <net/sock.h>
#include <linux/netfilter.h>
+#include <trace/socket.h>
#include <linux/if_tun.h>
#include <linux/ipv6_route.h>
@@ -164,6 +165,11 @@ static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
static DEFINE_PER_CPU(int, sockets_in_use);
+DEFINE_TRACE(socket_sendmsg);
+DEFINE_TRACE(socket_recvmsg);
+DEFINE_TRACE(socket_create);
+DEFINE_TRACE(socket_call);
+
/*
* Support routines.
* Move socket addresses back and forth across the kernel/user
@@ -578,6 +584,7 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
ret = __sock_sendmsg(&iocb, sock, msg, size);
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&iocb);
+ trace_socket_sendmsg(sock, msg, size, ret);
return ret;
}
EXPORT_SYMBOL(sock_sendmsg);
@@ -714,6 +721,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg,
ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&iocb);
+ trace_socket_recvmsg(sock, msg, size, flags, ret);
return ret;
}
EXPORT_SYMBOL(sock_recvmsg);
@@ -1314,6 +1322,7 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
if (retval < 0)
goto out_release;
+ trace_socket_create(sock, retval);
out:
/* It may be already another descriptor 8) Not kernel problem. */
return retval;
@@ -2249,6 +2258,8 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
a0 = a[0];
a1 = a[1];
+ trace_socket_call(call, a0);
+
switch (call) {
case SYS_SOCKET:
err = sys_socket(a0, a1, a[2]);