Skip to content

Commit

Permalink
mptcp: add tracepoint in mptcp_subflow_get_send
Browse files Browse the repository at this point in the history
This patch added a tracepoint in the packet scheduler function
mptcp_subflow_get_send().

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
  • Loading branch information
geliangtang authored and matttbe committed Apr 1, 2021
1 parent 2da1c29 commit e4421bb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -12548,6 +12548,7 @@ W: https://github.com/multipath-tcp/mptcp_net-next/wiki
B: https://github.com/multipath-tcp/mptcp_net-next/issues
F: Documentation/networking/mptcp-sysctl.rst
F: include/net/mptcp.h
F: include/trace/events/mptcp.h
F: include/uapi/linux/mptcp.h
F: net/mptcp/
F: tools/testing/selftests/net/mptcp/
Expand Down
53 changes: 53 additions & 0 deletions include/trace/events/mptcp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mptcp

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

#include <linux/tracepoint.h>

TRACE_EVENT(mptcp_subflow_get_send,

TP_PROTO(struct mptcp_subflow_context *subflow),

TP_ARGS(subflow),

TP_STRUCT__entry(
__field(bool, active)
__field(bool, free)
__field(u32, snd_wnd)
__field(u32, pace)
__field(u8, backup)
__field(u64, ratio)
),

TP_fast_assign(
bool sk = sk_fullsock(subflow->tcp_sock);

__entry->active = mptcp_subflow_active(subflow);
__entry->backup = subflow->backup;
if (sk) {
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);

__entry->free = sk_stream_memory_free(subflow->tcp_sock);
if (ssk) {
__entry->snd_wnd = tcp_sk(ssk)->snd_wnd;
__entry->pace = ssk->sk_pacing_rate;
if (__entry->pace)
__entry->ratio = div_u64((u64)ssk->sk_wmem_queued << 32,
__entry->pace);
}
}
),

TP_printk("active=%d free=%d snd_wnd=%u pace=%u backup=%u ratio=%llu",
__entry->active, __entry->free,
__entry->snd_wnd, __entry->pace,
__entry->backup, __entry->ratio)
);

#endif /* _TRACE_MPTCP_H */

/* This part must be outside protection */
#include <trace/define_trace.h>
8 changes: 4 additions & 4 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "protocol.h"
#include "mib.h"

#define CREATE_TRACE_POINTS
#include <trace/events/mptcp.h>

#if IS_ENABLED(CONFIG_MPTCP_IPV6)
struct mptcp6_sock {
struct mptcp_sock msk;
Expand Down Expand Up @@ -1381,6 +1384,7 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
send_info[i].ratio = -1;
}
mptcp_for_each_subflow(msk, subflow) {
trace_mptcp_subflow_get_send(subflow);
ssk = mptcp_subflow_tcp_sock(subflow);
if (!mptcp_subflow_active(subflow))
continue;
Expand All @@ -1401,10 +1405,6 @@ static struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
}
}

pr_debug("msk=%p nr_active=%d ssk=%p:%lld backup=%p:%lld",
msk, nr_active, send_info[0].ssk, send_info[0].ratio,
send_info[1].ssk, send_info[1].ratio);

/* pick the best backup if no other subflow is active */
if (!nr_active)
send_info[0].ssk = send_info[1].ssk;
Expand Down

0 comments on commit e4421bb

Please sign in to comment.