Skip to content

Commit

Permalink
Merge branch 'SMC-tracepoints'
Browse files Browse the repository at this point in the history
Tony Lu says:

====================
Tracepoints for SMC

This patch set introduces tracepoints for SMC, including the tracepoints
basic code. The tracepoitns would help us to track SMC's behaviors by
automatic tools, or other BPF tools, and zero overhead if not enabled.

Compared with kprobe and other dymatic tools, the tracepoints are
considered as stable API, and less overhead for tracing with easy-to-use
API.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Nov 1, 2021
2 parents 6008889 + a3a0e81 commit d4a07dc
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 2 deletions.
2 changes: 2 additions & 0 deletions net/smc/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
ccflags-y += -I$(src)
obj-$(CONFIG_SMC) += smc.o
obj-$(CONFIG_SMC_DIAG) += smc_diag.o
smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o
smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o smc_stats.o
smc-y += smc_tracepoint.o
2 changes: 2 additions & 0 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "smc_rx.h"
#include "smc_close.h"
#include "smc_stats.h"
#include "smc_tracepoint.h"

static DEFINE_MUTEX(smc_server_lgr_pending); /* serialize link group
* creation on server
Expand Down Expand Up @@ -564,6 +565,7 @@ static void smc_switch_to_fallback(struct smc_sock *smc, int reason_code)
smc->use_fallback = true;
smc->fallback_rsn = reason_code;
smc_stat_fallback(smc);
trace_smc_switch_to_fallback(smc, reason_code);
if (smc->sk.sk_socket && smc->sk.sk_socket->file) {
smc->clcsock->file = smc->sk.sk_socket->file;
smc->clcsock->file->private_data = smc->clcsock;
Expand Down
9 changes: 7 additions & 2 deletions net/smc/smc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "smc_ism.h"
#include "smc_netlink.h"
#include "smc_stats.h"
#include "smc_tracepoint.h"

#define SMC_LGR_NUM_INCR 256
#define SMC_LGR_FREE_DELAY_SERV (600 * HZ)
Expand Down Expand Up @@ -1620,15 +1621,19 @@ static void smcr_link_down(struct smc_link *lnk)
/* must be called under lgr->llc_conf_mutex lock */
void smcr_link_down_cond(struct smc_link *lnk)
{
if (smc_link_downing(&lnk->state))
if (smc_link_downing(&lnk->state)) {
trace_smcr_link_down(lnk, __builtin_return_address(0));
smcr_link_down(lnk);
}
}

/* will get the lgr->llc_conf_mutex lock */
void smcr_link_down_cond_sched(struct smc_link *lnk)
{
if (smc_link_downing(&lnk->state))
if (smc_link_downing(&lnk->state)) {
trace_smcr_link_down(lnk, __builtin_return_address(0));
schedule_work(&lnk->link_down_wrk);
}
}

void smcr_port_err(struct smc_ib_device *smcibdev, u8 ibport)
Expand Down
3 changes: 3 additions & 0 deletions net/smc/smc_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "smc_tx.h" /* smc_tx_consumer_update() */
#include "smc_rx.h"
#include "smc_stats.h"
#include "smc_tracepoint.h"

/* callback implementation to wakeup consumers blocked with smc_rx_wait().
* indirectly called by smc_cdc_msg_recv_action().
Expand Down Expand Up @@ -438,6 +439,8 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,
if (msg && smc_rx_update_consumer(smc, cons, copylen))
goto out;
}

trace_smc_rx_recvmsg(smc, copylen);
} while (read_remaining);
out:
return read_done;
Expand Down
9 changes: 9 additions & 0 deletions net/smc/smc_tracepoint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-only

#define CREATE_TRACE_POINTS
#include "smc_tracepoint.h"

EXPORT_TRACEPOINT_SYMBOL(smc_switch_to_fallback);
EXPORT_TRACEPOINT_SYMBOL(smc_tx_sendmsg);
EXPORT_TRACEPOINT_SYMBOL(smc_rx_recvmsg);
EXPORT_TRACEPOINT_SYMBOL(smcr_link_down);
116 changes: 116 additions & 0 deletions net/smc/smc_tracepoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/* SPDX-License-Identifier: GPL-2.0 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM smc

#if !defined(_TRACE_SMC_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SMC_H

#include <linux/ipv6.h>
#include <linux/tcp.h>
#include <linux/tracepoint.h>
#include <net/ipv6.h>
#include "smc.h"
#include "smc_core.h"

TRACE_EVENT(smc_switch_to_fallback,

TP_PROTO(const struct smc_sock *smc, int fallback_rsn),

TP_ARGS(smc, fallback_rsn),

TP_STRUCT__entry(
__field(const void *, sk)
__field(const void *, clcsk)
__field(int, fallback_rsn)
),

TP_fast_assign(
const struct sock *sk = &smc->sk;
const struct sock *clcsk = smc->clcsock->sk;

__entry->sk = sk;
__entry->clcsk = clcsk;
__entry->fallback_rsn = fallback_rsn;
),

TP_printk("sk=%p clcsk=%p fallback_rsn=%d",
__entry->sk, __entry->clcsk, __entry->fallback_rsn)
);

DECLARE_EVENT_CLASS(smc_msg_event,

TP_PROTO(const struct smc_sock *smc, size_t len),

TP_ARGS(smc, len),

TP_STRUCT__entry(
__field(const void *, smc)
__field(size_t, len)
__string(name, smc->conn.lnk->ibname)
),

TP_fast_assign(
__entry->smc = smc;
__entry->len = len;
__assign_str(name, smc->conn.lnk->ibname);
),

TP_printk("smc=%p len=%zu dev=%s",
__entry->smc, __entry->len,
__get_str(name))
);

DEFINE_EVENT(smc_msg_event, smc_tx_sendmsg,

TP_PROTO(const struct smc_sock *smc, size_t len),

TP_ARGS(smc, len)
);

DEFINE_EVENT(smc_msg_event, smc_rx_recvmsg,

TP_PROTO(const struct smc_sock *smc, size_t len),

TP_ARGS(smc, len)
);

TRACE_EVENT(smcr_link_down,

TP_PROTO(const struct smc_link *lnk, void *location),

TP_ARGS(lnk, location),

TP_STRUCT__entry(
__field(const void *, lnk)
__field(const void *, lgr)
__field(int, state)
__string(name, lnk->ibname)
__field(void *, location)
),

TP_fast_assign(
const struct smc_link_group *lgr = lnk->lgr;

__entry->lnk = lnk;
__entry->lgr = lgr;
__entry->state = lnk->state;
__assign_str(name, lnk->ibname);
__entry->location = location;
),

TP_printk("lnk=%p lgr=%p state=%d dev=%s location=%p",
__entry->lnk, __entry->lgr,
__entry->state, __get_str(name),
__entry->location)
);

#endif /* _TRACE_SMC_H */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .

#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE smc_tracepoint

#include <trace/define_trace.h>
3 changes: 3 additions & 0 deletions net/smc/smc_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "smc_ism.h"
#include "smc_tx.h"
#include "smc_stats.h"
#include "smc_tracepoint.h"

#define SMC_TX_WORK_DELAY 0
#define SMC_TX_CORK_DELAY (HZ >> 2) /* 250 ms */
Expand Down Expand Up @@ -245,6 +246,8 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
SMC_TX_CORK_DELAY);
else
smc_tx_sndbuf_nonempty(conn);

trace_smc_tx_sendmsg(smc, copylen);
} /* while (msg_data_left(msg)) */

return send_done;
Expand Down

0 comments on commit d4a07dc

Please sign in to comment.