[ltt-dev] [PATCH] Fix tracepoints for network socket
Atsushi Tsuji
a-tsuji at bk.jp.nec.com
Tue Feb 3 01:21:31 EST 2009
Hi,
Currently, the tracepoints for network socket could not trace all the
network activity due to its location, sock_{send/recv}msg, because there
is the path without through sock_{send/recv}msg (like below).
Kernel path for sendmsg:
sys_write sys_{send/sendto/sendmsg}
| |
sock_aio_write sock_sendmsg
\ /
\ /
__sock_sendmsg
So I think __sock_{send/recv}msg is better tracepoints to track
network socket activity.
And I'd like to request to get the return value on those tracepoints
to track the real size of sending/recieving by user and the error status
of __sock_{send/recv}msg.
The below patch is for lttng tree to change those tracepoints.
Signed-off-by: Atsushi Tsuji <a-tsuji at bk.jp.nec.com>
---
diff --git a/ltt/probes/net-trace.c b/ltt/probes/net-trace.c
index 2c88ec6..34cef1a 100644
--- a/ltt/probes/net-trace.c
+++ b/ltt/probes/net-trace.c
@@ -79,18 +79,18 @@ void probe_socket_sendmsg(struct socket *sock, struct msghdr
*msg,
size_t size, int ret)
{
trace_mark_tp(net, socket_sendmsg, socket_sendmsg, probe_socket_sendmsg,
- "sock %p family %d type %d protocol %d size %zu",
+ "sock %p family %d type %d protocol %d size %zu ret %d",
sock, sock->sk->sk_family, sock->sk->sk_type,
- sock->sk->sk_protocol, size);
+ sock->sk->sk_protocol, size, ret);
}
void probe_socket_recvmsg(struct socket *sock, struct msghdr *msg,
size_t size, int flags, int ret)
{
trace_mark_tp(net, socket_recvmsg, socket_recvmsg, probe_socket_recvmsg,
- "sock %p family %d type %d protocol %d size %zu",
+ "sock %p family %d type %d protocol %d size %zu ret %d",
sock, sock->sk->sk_family, sock->sk->sk_type,
- sock->sk->sk_protocol, size);
+ sock->sk->sk_protocol, size, ret);
}
void probe_socket_create(struct socket *sock, int fd)
diff --git a/net/socket.c b/net/socket.c
index 2b63bab..e8b2b5d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -567,7 +567,11 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct
socket *sock,
if (err)
return err;
- return sock->ops->sendmsg(iocb, sock, msg, size);
+ err = sock->ops->sendmsg(iocb, sock, msg, size);
+ trace_socket_sendmsg(sock, msg, size, err);
+
+ return err;
+
}
int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
@@ -581,7 +585,6 @@ 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;
}
@@ -650,7 +653,11 @@ static inline int __sock_recvmsg(struct kiocb *iocb, struct
socket *sock,
if (err)
return err;
- return sock->ops->recvmsg(iocb, sock, msg, size, flags);
+ err = sock->ops->recvmsg(iocb, sock, msg, size, flags);
+ trace_socket_recvmsg(sock, msg, size, flags, err);
+
+ return err;
+
}
int sock_recvmsg(struct socket *sock, struct msghdr *msg,
@@ -666,7 +673,6 @@ 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;
}
More information about the lttng-dev
mailing list