Skip to content

Commit 4826260

Browse files
Tony Ludavem330
authored andcommitted
net/smc: Introduce tracepoint for fallback
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 <[email protected]> Reviewed-by: Wen Gu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6008889 commit 4826260

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

net/smc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2+
ccflags-y += -I$(src)
23
obj-$(CONFIG_SMC) += smc.o
34
obj-$(CONFIG_SMC_DIAG) += smc_diag.o
45
smc-y := af_smc.o smc_pnet.o smc_ib.o smc_clc.o smc_core.o smc_wr.o smc_llc.o
56
smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o smc_stats.o
7+
smc-y += smc_tracepoint.o

net/smc/af_smc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "smc_rx.h"
5151
#include "smc_close.h"
5252
#include "smc_stats.h"
53+
#include "smc_tracepoint.h"
5354

5455
static DEFINE_MUTEX(smc_server_lgr_pending); /* serialize link group
5556
* creation on server
@@ -564,6 +565,7 @@ static void smc_switch_to_fallback(struct smc_sock *smc, int reason_code)
564565
smc->use_fallback = true;
565566
smc->fallback_rsn = reason_code;
566567
smc_stat_fallback(smc);
568+
trace_smc_switch_to_fallback(smc, reason_code);
567569
if (smc->sk.sk_socket && smc->sk.sk_socket->file) {
568570
smc->clcsock->file = smc->sk.sk_socket->file;
569571
smc->clcsock->file->private_data = smc->clcsock;

net/smc/smc_tracepoint.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#define CREATE_TRACE_POINTS
4+
#include "smc_tracepoint.h"
5+
6+
EXPORT_TRACEPOINT_SYMBOL(smc_switch_to_fallback);

net/smc/smc_tracepoint.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#undef TRACE_SYSTEM
4+
#define TRACE_SYSTEM smc
5+
6+
#if !defined(_TRACE_SMC_H) || defined(TRACE_HEADER_MULTI_READ)
7+
#define _TRACE_SMC_H
8+
9+
#include <linux/ipv6.h>
10+
#include <linux/tcp.h>
11+
#include <linux/tracepoint.h>
12+
#include <net/ipv6.h>
13+
#include "smc.h"
14+
#include "smc_core.h"
15+
16+
TRACE_EVENT(smc_switch_to_fallback,
17+
18+
TP_PROTO(const struct smc_sock *smc, int fallback_rsn),
19+
20+
TP_ARGS(smc, fallback_rsn),
21+
22+
TP_STRUCT__entry(
23+
__field(const void *, sk)
24+
__field(const void *, clcsk)
25+
__field(int, fallback_rsn)
26+
),
27+
28+
TP_fast_assign(
29+
const struct sock *sk = &smc->sk;
30+
const struct sock *clcsk = smc->clcsock->sk;
31+
32+
__entry->sk = sk;
33+
__entry->clcsk = clcsk;
34+
__entry->fallback_rsn = fallback_rsn;
35+
),
36+
37+
TP_printk("sk=%p clcsk=%p fallback_rsn=%d",
38+
__entry->sk, __entry->clcsk, __entry->fallback_rsn)
39+
);
40+
41+
#endif /* _TRACE_SMC_H */
42+
43+
#undef TRACE_INCLUDE_PATH
44+
#define TRACE_INCLUDE_PATH .
45+
46+
#undef TRACE_INCLUDE_FILE
47+
#define TRACE_INCLUDE_FILE smc_tracepoint
48+
49+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)