Re: [External] Re: [PATCH v5] sock: add tracepoint for send recv length

From: Steven Rostedt
Date: Tue Jan 10 2023 - 23:12:19 EST


On Wed, 11 Jan 2023 11:53:24 +0800
运辉崔 <cuiyunhui@xxxxxxxxxxxxx> wrote:

> Hi Steve, Based on your suggestion, can we use the following code
> instead of using DEFINE_EVENT_PRINT ?

I only suggested it because you didn't have that logic for the
sock_send_length trace event. But if you don't care about that one, then
sure, use it for both.

-- Steve


>
> DECLARE_EVENT_CLASS(sock_msg_length,
>
> TP_PROTO(struct sock *sk, int ret, int flags),
>
> TP_ARGS(sk, ret, flags),
>
> TP_STRUCT__entry(
> __field(void *, sk)
> __field(__u16, family)
> __field(__u16, protocol)
> __field(int, ret)
> __field(int, flags)
> ),
>
> TP_fast_assign(
> __entry->sk = sk;
> __entry->family = sk->sk_family;
> __entry->protocol = sk->sk_protocol;
> __entry->ret = ret;
> __entry->flags = flags;
> ),
>
> TP_printk("sk address = %p, family = %s protocol = %s, length
> = %d, error = %d, flags = 0x%x",
> __entry->sk, show_family_name(__entry->family),
> show_inet_protocol_name(__entry->protocol),
> !(__entry->flags & MSG_PEEK) ?
> (__entry->ret > 0 ? __entry->ret : 0) : 0,
> __entry->ret < 0 ? __entry->ret : 0,
> __entry->flags)
> );