Skip to content

Commit

Permalink
net/smc: Introduce tracepoint for fallback
Browse files Browse the repository at this point in the history
This introduces tracepoint for smc fallback to TCP, so that we can track
which connection and why it fallbacks, and map the clcsocks' pointer with
/proc/net/tcp to find more details about TCP connections. Compared with
kprobe or other dynamic tracing, tracepoints are stable and easy to use.

Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
Reviewed-by: Wen Gu <guwen@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tony Lu authored and David S. Miller committed Nov 1, 2021
1 parent 6008889 commit 4826260
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 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
6 changes: 6 additions & 0 deletions net/smc/smc_tracepoint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only

#define CREATE_TRACE_POINTS
#include "smc_tracepoint.h"

EXPORT_TRACEPOINT_SYMBOL(smc_switch_to_fallback);
49 changes: 49 additions & 0 deletions net/smc/smc_tracepoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* 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)
);

#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>

0 comments on commit 4826260

Please sign in to comment.