Skip to content

Commit

Permalink
net/sock: Introduce trace_sk_data_ready()
Browse files Browse the repository at this point in the history
As suggested by Cong, introduce a tracepoint for all ->sk_data_ready()
callback implementations.  For example:

<...>
  dpkg-deb-7752    [000] .....   145.660735: sk_data_ready: family=16 protocol=16 func=sock_def_readable
  dpkg-deb-7757    [000] .....   145.759168: sk_data_ready: family=16 protocol=16 func=sock_def_readable
  dpkg-deb-7758    [000] .....   145.763956: sk_data_ready: family=16 protocol=16 func=sock_def_readable
<...>

Suggested-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
  • Loading branch information
ypl-coffee authored and intel-lab-lkp committed Oct 7, 2022
1 parent 0326074 commit 5f951b8
Show file tree
Hide file tree
Showing 28 changed files with 116 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/infiniband/hw/erdma/erdma_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/types.h>
#include <linux/workqueue.h>
#include <net/addrconf.h>
#include <trace/events/sock.h>

#include <rdma/ib_user_verbs.h>
#include <rdma/ib_verbs.h>
Expand Down Expand Up @@ -933,6 +934,8 @@ static void erdma_cm_llp_data_ready(struct sock *sk)
{
struct erdma_cep *cep;

trace_sk_data_ready(sk, __func__);

read_lock(&sk->sk_callback_lock);

cep = sk_to_cep(sk);
Expand Down
5 changes: 5 additions & 0 deletions drivers/infiniband/sw/siw/siw_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <net/tcp.h>
#include <linux/inet.h>
#include <linux/tcp.h>
#include <trace/events/sock.h>

#include <rdma/iw_cm.h>
#include <rdma/ib_verbs.h>
Expand Down Expand Up @@ -109,6 +110,8 @@ static void siw_rtr_data_ready(struct sock *sk)
struct siw_qp *qp = NULL;
read_descriptor_t rd_desc;

trace_sk_data_ready(sk, __func__);

read_lock(&sk->sk_callback_lock);

cep = sk_to_cep(sk);
Expand Down Expand Up @@ -1216,6 +1219,8 @@ static void siw_cm_llp_data_ready(struct sock *sk)
{
struct siw_cep *cep;

trace_sk_data_ready(sk, __func__);

read_lock(&sk->sk_callback_lock);

cep = sk_to_cep(sk);
Expand Down
3 changes: 3 additions & 0 deletions drivers/infiniband/sw/siw/siw_qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/llist.h>
#include <asm/barrier.h>
#include <net/tcp.h>
#include <trace/events/sock.h>

#include "siw.h"
#include "siw_verbs.h"
Expand Down Expand Up @@ -94,6 +95,8 @@ void siw_qp_llp_data_ready(struct sock *sk)
{
struct siw_qp *qp;

trace_sk_data_ready(sk, __func__);

read_lock(&sk->sk_callback_lock);

if (unlikely(!sk->sk_user_data || !sk_to_qp(sk)))
Expand Down
3 changes: 3 additions & 0 deletions drivers/nvme/host/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/blk-mq.h>
#include <crypto/hash.h>
#include <net/busy_poll.h>
#include <trace/events/sock.h>

#include "nvme.h"
#include "fabrics.h"
Expand Down Expand Up @@ -906,6 +907,8 @@ static void nvme_tcp_data_ready(struct sock *sk)
{
struct nvme_tcp_queue *queue;

trace_sk_data_ready(sk, __func__);

read_lock_bh(&sk->sk_callback_lock);
queue = sk->sk_user_data;
if (likely(queue && queue->rd_enabled) &&
Expand Down
5 changes: 5 additions & 0 deletions drivers/nvme/target/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/inet.h>
#include <linux/llist.h>
#include <crypto/hash.h>
#include <trace/events/sock.h>

#include "nvmet.h"

Expand Down Expand Up @@ -1467,6 +1468,8 @@ static void nvmet_tcp_data_ready(struct sock *sk)
{
struct nvmet_tcp_queue *queue;

trace_sk_data_ready(sk, __func__);

read_lock_bh(&sk->sk_callback_lock);
queue = sk->sk_user_data;
if (likely(queue))
Expand Down Expand Up @@ -1664,6 +1667,8 @@ static void nvmet_tcp_listen_data_ready(struct sock *sk)
{
struct nvmet_tcp_port *port;

trace_sk_data_ready(sk, __func__);

read_lock_bh(&sk->sk_callback_lock);
port = sk->sk_user_data;
if (!port)
Expand Down
3 changes: 3 additions & 0 deletions drivers/scsi/iscsi_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <scsi/scsi.h>
#include <scsi/scsi_transport_iscsi.h>
#include <trace/events/iscsi.h>
#include <trace/events/sock.h>

#include "iscsi_tcp.h"

Expand Down Expand Up @@ -170,6 +171,8 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk)
struct iscsi_tcp_conn *tcp_conn;
struct iscsi_conn *conn;

trace_sk_data_ready(sk, __func__);

read_lock_bh(&sk->sk_callback_lock);
conn = sk->sk_user_data;
if (!conn) {
Expand Down
3 changes: 3 additions & 0 deletions drivers/soc/qcom/qmi_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/string.h>
#include <net/sock.h>
#include <linux/workqueue.h>
#include <trace/events/sock.h>
#include <linux/soc/qcom/qmi.h>

static struct socket *qmi_sock_create(struct qmi_handle *qmi,
Expand Down Expand Up @@ -569,6 +570,8 @@ static void qmi_data_ready(struct sock *sk)
{
struct qmi_handle *qmi = sk->sk_user_data;

trace_sk_data_ready(sk, __func__);

/*
* This will be NULL if we receive data while being in
* qmi_handle_release()
Expand Down
2 changes: 2 additions & 0 deletions drivers/target/iscsi/iscsi_target_nego.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/slab.h>
#include <linux/sched/signal.h>
#include <net/sock.h>
#include <trace/events/sock.h>
#include <scsi/iscsi_proto.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
Expand Down Expand Up @@ -384,6 +385,7 @@ static void iscsi_target_sk_data_ready(struct sock *sk)
struct iscsit_conn *conn = sk->sk_user_data;
bool rc;

trace_sk_data_ready(sk, __func__);
pr_debug("Entering iscsi_target_sk_data_ready: conn: %p\n", conn);

write_lock_bh(&sk->sk_callback_lock);
Expand Down
5 changes: 5 additions & 0 deletions drivers/xen/pvcalls-back.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <net/inet_common.h>
#include <net/inet_connection_sock.h>
#include <net/request_sock.h>
#include <trace/events/sock.h>

#include <xen/events.h>
#include <xen/grant_table.h>
Expand Down Expand Up @@ -300,6 +301,8 @@ static void pvcalls_sk_data_ready(struct sock *sock)
struct sock_mapping *map = sock->sk_user_data;
struct pvcalls_ioworker *iow;

trace_sk_data_ready(sock, __func__);

if (map == NULL)
return;

Expand Down Expand Up @@ -588,6 +591,8 @@ static void pvcalls_pass_sk_data_ready(struct sock *sock)
unsigned long flags;
int notify;

trace_sk_data_ready(sock, __func__);

if (mappass == NULL)
return;

Expand Down
5 changes: 5 additions & 0 deletions fs/dlm/lowcomms.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <net/ipv6.h>

#include <trace/events/dlm.h>
#include <trace/events/sock.h>

#include "dlm_internal.h"
#include "lowcomms.h"
Expand Down Expand Up @@ -507,13 +508,17 @@ static void lowcomms_data_ready(struct sock *sk)
{
struct connection *con;

trace_sk_data_ready(sk, __func__);

con = sock2con(sk);
if (con && !test_and_set_bit(CF_READ_PENDING, &con->flags))
queue_work(recv_workqueue, &con->rwork);
}

static void lowcomms_listen_data_ready(struct sock *sk)
{
trace_sk_data_ready(sk, __func__);

if (!dlm_allow_conn)
return;

Expand Down
5 changes: 5 additions & 0 deletions fs/ocfs2/cluster/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <linux/net.h>
#include <linux/export.h>
#include <net/tcp.h>
#include <trace/events/sock.h>

#include <linux/uaccess.h>

Expand Down Expand Up @@ -585,6 +586,8 @@ static void o2net_data_ready(struct sock *sk)
void (*ready)(struct sock *sk);
struct o2net_sock_container *sc;

trace_sk_data_ready(sk, __func__);

read_lock_bh(&sk->sk_callback_lock);
sc = sk->sk_user_data;
if (sc) {
Expand Down Expand Up @@ -645,6 +648,8 @@ static void o2net_state_change(struct sock *sk)
static void o2net_register_callbacks(struct sock *sk,
struct o2net_sock_container *sc)
{
trace_sk_data_ready(sk, __func__);

write_lock_bh(&sk->sk_callback_lock);

/* accepted sockets inherit the old listen socket data ready */
Expand Down
24 changes: 24 additions & 0 deletions include/trace/events/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,30 @@ TRACE_EVENT(inet_sk_error_report,
__entry->error)
);

TRACE_EVENT(sk_data_ready,

TP_PROTO(const struct sock *sk, const char *func),

TP_ARGS(sk, func),

TP_STRUCT__entry(
__field(const void *, skaddr)
__field(__u16, family)
__field(__u16, protocol)
__string(func, func)
),

TP_fast_assign(
__entry->skaddr = sk;
__entry->family = sk->sk_family;
__entry->protocol = sk->sk_protocol;
__assign_str(func, func)
),

TP_printk("family=%u protocol=%u func=%s",
__entry->family, __entry->protocol, __get_str(func))
);

#endif /* _TRACE_SOCK_H */

/* This part must be outside protection */
Expand Down
4 changes: 4 additions & 0 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#endif /* CONFIG_BLOCK */
#include <linux/dns_resolver.h>
#include <net/tcp.h>
#include <trace/events/sock.h>

#include <linux/ceph/ceph_features.h>
#include <linux/ceph/libceph.h>
Expand Down Expand Up @@ -344,6 +345,9 @@ static void con_sock_state_closed(struct ceph_connection *con)
static void ceph_sock_data_ready(struct sock *sk)
{
struct ceph_connection *con = sk->sk_user_data;

trace_sk_data_ready(sk, __func__);

if (atomic_read(&con->msgr->stopping)) {
return;
}
Expand Down
3 changes: 3 additions & 0 deletions net/core/skmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <net/sock.h>
#include <net/tcp.h>
#include <net/tls.h>
#include <trace/events/sock.h>

static bool sk_msg_try_coalesce_ok(struct sk_msg *msg, int elem_first_coalesce)
{
Expand Down Expand Up @@ -1210,6 +1211,8 @@ static void sk_psock_verdict_data_ready(struct sock *sk)
{
struct socket *sock = sk->sk_socket;

trace_sk_data_ready(sk, __func__);

if (unlikely(!sock || !sock->ops || !sock->ops->read_skb))
return;
sock->ops->read_skb(sk, sk_psock_verdict_recv);
Expand Down
2 changes: 2 additions & 0 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,8 @@ void sock_def_readable(struct sock *sk)
{
struct socket_wq *wq;

trace_sk_data_ready(sk, __func__);

rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (skwq_has_sleeper(wq))
Expand Down
3 changes: 3 additions & 0 deletions net/kcm/kcmsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <net/netns/generic.h>
#include <net/sock.h>
#include <uapi/linux/kcm.h>
#include <trace/events/sock.h>

unsigned int kcm_net_id;

Expand Down Expand Up @@ -344,6 +345,8 @@ static void psock_data_ready(struct sock *sk)
{
struct kcm_psock *psock;

trace_sk_data_ready(sk, __func__);

read_lock_bh(&sk->sk_callback_lock);

psock = (struct kcm_psock *)sk->sk_user_data;
Expand Down
3 changes: 3 additions & 0 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mib.h"

#include <trace/events/mptcp.h>
#include <trace/events/sock.h>

static void mptcp_subflow_ops_undo_override(struct sock *ssk);

Expand Down Expand Up @@ -1349,6 +1350,8 @@ static void subflow_data_ready(struct sock *sk)
struct sock *parent = subflow->conn;
struct mptcp_sock *msk;

trace_sk_data_ready(sk, __func__);

msk = mptcp_sk(parent);
if (state & TCPF_LISTEN) {
/* MPJ subflow are removed from accept queue before reaching here,
Expand Down
3 changes: 3 additions & 0 deletions net/qrtr/ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "qrtr.h"

#include <trace/events/sock.h>
#define CREATE_TRACE_POINTS
#include <trace/events/qrtr.h>

Expand Down Expand Up @@ -752,6 +753,8 @@ static void qrtr_ns_worker(struct work_struct *work)

static void qrtr_ns_data_ready(struct sock *sk)
{
trace_sk_data_ready(sk, __func__);

queue_work(qrtr_ns.workqueue, &qrtr_ns.work);
}

Expand Down
2 changes: 2 additions & 0 deletions net/rds/tcp_listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/gfp.h>
#include <linux/in.h>
#include <net/tcp.h>
#include <trace/events/sock.h>

#include "rds.h"
#include "tcp.h"
Expand Down Expand Up @@ -234,6 +235,7 @@ void rds_tcp_listen_data_ready(struct sock *sk)
{
void (*ready)(struct sock *sk);

trace_sk_data_ready(sk, __func__);
rdsdebug("listen data ready sk %p\n", sk);

read_lock_bh(&sk->sk_callback_lock);
Expand Down
2 changes: 2 additions & 0 deletions net/rds/tcp_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <net/tcp.h>
#include <trace/events/sock.h>

#include "rds.h"
#include "tcp.h"
Expand Down Expand Up @@ -309,6 +310,7 @@ void rds_tcp_data_ready(struct sock *sk)
struct rds_conn_path *cp;
struct rds_tcp_connection *tc;

trace_sk_data_ready(sk, __func__);
rdsdebug("data ready sk %p\n", sk);

read_lock_bh(&sk->sk_callback_lock);
Expand Down
Loading

0 comments on commit 5f951b8

Please sign in to comment.