Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: a-tsuji@bk.jp.nec.com (Atsushi Tsuji)
Subject: [ltt-dev] [PATCH] Fix tracepoints for network socket
Date: Tue, 03 Feb 2009 15:21:31 +0900	[thread overview]
Message-ID: <4987E26B.2060200@bk.jp.nec.com> (raw)

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;
  }








             reply	other threads:[~2009-02-03  6:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-03  6:21 Atsushi Tsuji [this message]
2009-02-03 14:04 ` Mathieu Desnoyers
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=4987E26B.2060200@bk.jp.nec.com \
    --to=a-tsuji@bk.jp.nec.com \
    /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