From: compudj@krystal.dyndns.org (Mathieu Desnoyers)
Subject: [ltt-dev] [PATCH] Fix tracepoints for network socket
Date: Tue, 3 Feb 2009 09:04:19 -0500 [thread overview]
Message-ID: <20090203140418.GA9620@Krystal> (raw)
In-Reply-To: <4987E26B.2060200@bk.jp.nec.com>
* Atsushi Tsuji (a-tsuji at bk.jp.nec.com) wrote:
> 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.
>
Hi Atsushi,
That's a great patch ! Thanks !
Benjamin noticed this problematic behavior recently and was starting to
investigate on this issue. Your patch comes timely. :)
> 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.
>
Can we use the system call exit return value instead ? This should
already be recording exactly this information.
One more comment below.
> 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);
I am just wondering about the implication of moving this trace event
across the wait_on_sync_kiocb() call. This means that the sendmsg event
will now occur before we block on kiocb. I don't think it changes
anything given we have the full syscall and scheduler instrumentation
which tells us in which state we are (which syscall) and when we are
waiting. This sendmsg event is really there to add more syscall-specific
information. The problem is that we will get the return value of
__sock_sendmsg rather than the return value of wait_on_sync_kiocb, so in
the case __sock_sendmsg returns -EIOCBQUEUED, we end up not knowing the
"real" return value of the system call.
So given we already have the syscall return value in the syscall_exit
event, I wonder if it's really useful to add this information to the
sendmsg and recvmsg tracepoints ?
Best regards,
Mathieu
> 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;
> }
>
>
>
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2009-02-03 14:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 6:21 Atsushi Tsuji
2009-02-03 14:04 ` Mathieu Desnoyers [this message]
2009-02-11 7:14 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090203140418.GA9620@Krystal \
--to=compudj@krystal.dyndns.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox