Messages in this thread | | | From | 运辉崔 <> | Date | Wed, 11 Jan 2023 11:53:24 +0800 | Subject | Re: [External] Re: [PATCH v5] sock: add tracepoint for send recv length |
| |
On Tue, Jan 10, 2023 at 11:44 PM Steven Rostedt <rostedt@goodmis.org> wrote: > > > 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->ret > 0 ? ret : 0, __entry->ret < 0 ? ret : 0, > __entry->flags) > ); > > DEFINE_EVENT(sock_msg_length, sock_send_length, > TP_PROTO(struct sock *sk, int ret, int flags), > > TP_ARGS(sk, ret, flags) > ); > > DEFINE_EVENT_PRINT(sock_msg_length, sock_recv_length, > TP_PROTO(struct sock *sk, int ret, int flags), > > TP_ARGS(sk, ret, 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 : __entry->ret > 0 ? ret : 0, > __entry->ret < 0 ? ret : 0, > __entry->flags) > ); > #endif /* _TRACE_SOCK_H */ > > As DEFINE_EVENT_PRINT() uses the class template, but overrides the > TP_printk() portion (still saving memory). >
Hi Steve, Based on your suggestion, can we use the following code instead of using DEFINE_EVENT_PRINT ?
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) );
DEFINE_EVENT(sock_msg_length, sock_send_length, TP_PROTO(struct sock *sk, int ret, int flags),
TP_ARGS(sk, ret, flags) );
DEFINE_EVENT(sock_msg_length, sock_recv_length, TP_PROTO(struct sock *sk, int ret, int flags),
TP_ARGS(sk, ret, flags) );
> And then both calls can just do: > > trace_sock_send_length(sk, ret, 0); > > trace_sock_recv_length(sock->sk, ret, flags); > > And I bet that will also solve all the gcc being smart waste. > > -- Steve >
Btw, we still need noinline helpers, right? Otherwise the following code would be inlined into sock_recvmsg: mov 0x18(%r13),%rsi mov %gs:0x7e832d87(%rip),%eax # 0x2e68c <pcpu_hot+12> mov %eax,%eax bt %rax,0xdca591(%rip) # 0xffffffff825c5ea0 <__cpu_online_mask>
Thanks, Yunhui
| |