From: Steven Rostedt <rostedt@goodmis.org>
To: Yunhui Cui <cuiyunhui@bytedance.com>
Cc: mhiramat@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, duanxiongchun@bytedance.com,
kuniyu@amazon.com, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sock: add tracepoint for send recv length
Date: Thu, 5 Jan 2023 09:08:07 -0500 [thread overview]
Message-ID: <20230105090807.51213cea@gandalf.local.home> (raw)
In-Reply-To: <20230105100014.1935-1-cuiyunhui@bytedance.com>
On Thu, 5 Jan 2023 18:00:14 +0800
Yunhui Cui <cuiyunhui@bytedance.com> wrote:
> @@ -715,6 +716,10 @@ static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
> inet_sendmsg, sock, msg,
> msg_data_left(msg));
> BUG_ON(ret == -EIOCBQUEUED);
> +
> + trace_sock_sendmsg_length(sock->sk, sock->sk->sk_family,
> + sock->sk->sk_protocol,
> + ret > 0 ? ret : 0, ret > 0 ? 0 : ret, 0);
The length and error seem confusing. Basically, length is ret > 0 and error
is ret < 0, right?
That means we don't need both. We could simply have:
> + TP_ARGS(sk, family, protocol, length, error, flags),
TP_ARGS(sk, family, protocol, ret, flags)
> +
> + TP_STRUCT__entry(
> + __field(void *, sk)
> + __field(__u16, family)
> + __field(__u16, protocol)
> + __field(int, length)
> + __field(int, error)
> + __field(int, flags)
> + ),
> +
> + TP_fast_assign(
> + __entry->sk = sk;
> + __entry->family = sk->sk_family;
> + __entry->protocol = sk->sk_protocol;
> + __entry->length = length;
__entry->length = ret > 0 ? ret : 0;
> + __entry->error = error;
__entry->error = ret < 0 ? ret : 0;
> + __entry->flags = flags;
> + ),
> +
> return ret;
> }
>
> @@ -992,9 +997,17 @@ INDIRECT_CALLABLE_DECLARE(int inet6_recvmsg(struct socket *, struct msghdr *,
> static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
> int flags)
> {
> - return INDIRECT_CALL_INET(sock->ops->recvmsg, inet6_recvmsg,
> + int ret = INDIRECT_CALL_INET(sock->ops->recvmsg, inet6_recvmsg,
> inet_recvmsg, sock, msg, msg_data_left(msg),
> flags);
> +
> + trace_sock_recvmsg_length(sock->sk, sock->sk->sk_family,
> + sock->sk->sk_protocol,
> + (ret > 0 && !(flags & MSG_PEEK)) ?
> + ret : 0,
> + (ret > 0 && !(flags & MSG_PEEK)) ? 0 : ret,
Since both length and error are zero when flags has MSG_PEEK set:
trace_sock_recvmsg_length(sock->sk, sock->sk->sk_family,
sock->sk->sk_protocol,
!(flags & MSG_PEEK) ? ret : 0,
-- Steve
> + flags);
> + return ret;
> }
>
> /**
> @@ -1044,6 +1057,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
> {
> struct socket *sock;
> int flags;
> + int ret;
>
> sock = file->private_data;
>
> @@ -1051,7 +1065,12 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
> /* more is a combination of MSG_MORE and MSG_SENDPAGE_NOTLAST */
> flags |= more;
>
> - return kernel_sendpage(sock, page, offset, size, flags);
> + ret = kernel_sendpage(sock, page, offset, size, flags);
> +
> + trace_sock_sendmsg_length(sock->sk, sock->sk->sk_family,
> + sock->sk->sk_protocol,
> + ret > 0 ? ret : 0, ret > 0 ? 0 : ret, 0);
> + return ret;
> }
>
> static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
next prev parent reply other threads:[~2023-01-05 14:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 10:00 [PATCH v2] sock: add tracepoint for send recv length Yunhui Cui
2023-01-05 12:02 ` Paolo Abeni
2023-01-06 2:57 ` [External] " 运辉崔
2023-01-05 14:08 ` Steven Rostedt [this message]
2023-01-06 3:24 ` 运辉崔
2023-01-06 4:07 ` Steven Rostedt
2023-01-06 4:23 ` 运辉崔
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=20230105090807.51213cea@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=cuiyunhui@bytedance.com \
--cc=davem@davemloft.net \
--cc=duanxiongchun@bytedance.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).