Skip to contentSkip to conversation

add tracepoints

PATCH In review Geliang Tang 3 participants 9 messages Mar 31, 2021 – Apr 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover add tracepoints

v4:
- add back patch 1.
- use sk_fullsock in patch 2.

v3:
- update the patch set as Paolo suggested.
- drop the patch "mptcp: export mptcp_subflow_active".

v2:
- add two new patches.

This patchset addressed issues 131, replace some/most pr_debug with trace events. As Paolo suggested, we should add the tracepoints at "the packet scheduler and the mapping status" first.

Geliang Tang (5):
mptcp: export mptcp_subflow_active
mptcp: add tracepoint in mptcp_subflow_get_send
mptcp: add tracepoint in get_mapping_status
mptcp: add tracepoint in ack_update_msk
mptcp: add tracepoint in subflow_check_data_avail

 include/trace/events/mptcp.h | 166 +++++++++++++++++++++++++++++++++++
 net/mptcp/options.c          |   6 ++
 net/mptcp/protocol.c         |  20 +----
 net/mptcp/protocol.h         |  12 +++
 net/mptcp/subflow.c          |  10 +--
 5 files changed, 192 insertions(+), 22 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
Signature · 1 line
2.30.2
#1 lore raw

PATCH v4 1/5 mptcp: export mptcp_subflow_active

This patch moved the static function mptcp_subflow_active to protocol.h as an inline one.

---
 net/mptcp/protocol.c | 12 ------------
 net/mptcp/protocol.h | 12 ++++++++++++
 2 files changed, 12 insertions(+), 12 deletions(-)
net/mptcp/protocol.c +0 -12
index 9d7e7e13fba8..a625c4e63152 100644
@@ -399,18 +399,6 @@ static void mptcp_set_timeout(const struct sock *sk, const struct sock *ssk)
 	mptcp_sk(sk)->timer_ival = tout > 0 ? tout : TCP_RTO_MIN;
 }
 
-static bool mptcp_subflow_active(struct mptcp_subflow_context *subflow)
-{
-	struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
-
-	/* can't send if JOIN hasn't completed yet (i.e. is usable for mptcp) */
-	if (subflow->request_join && !subflow->fully_established)
-		return false;
-
-	/* only send if our side has not closed yet */
-	return ((1 << ssk->sk_state) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT));
-}
-
 static bool tcp_can_send_ack(const struct sock *ssk)
 {
 	return !((1 << inet_sk_state_load(ssk)) &
net/mptcp/protocol.h +12 -0
index 14f0114be17a..d9a489c73029 100644
@@ -539,6 +539,18 @@ void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
 			 struct sockaddr_storage *addr,
 			 unsigned short family);
 
+static inline bool mptcp_subflow_active(struct mptcp_subflow_context *subflow)
+{
+	struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+
+	/* can't send if JOIN hasn't completed yet (i.e. is usable for mptcp) */
+	if (subflow->request_join && !subflow->fully_established)
+		return false;
+
+	/* only send if our side has not closed yet */
+	return ((1 << ssk->sk_state) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT));
+}
+
 static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
 					      struct mptcp_subflow_context *ctx)
 {
Signature · 1 line
2.30.2
#2 lore raw

PATCH v4 2/5 mptcp: add tracepoint in mptcp_subflow_get_send

This patch added a tracepoint in the packet scheduler function mptcp_subflow_get_send().

---
 include/trace/events/mptcp.h | 53 ++++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c         |  8 +++---
 2 files changed, 57 insertions(+), 4 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
include/trace/events/mptcp.h new file +53 -0
new file mode 100644
index 000000000000..f1c836573744
@@ -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>
net/mptcp/protocol.c +4 -4
index a625c4e63152..2d895c3c8746 100644
@@ -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;
@@ -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;
@@ -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;
Signature · 1 line
2.30.2
#3 lore raw

PATCH v4 3/5 mptcp: add tracepoint in get_mapping_status

This patch added a tracepoint in the mapping status function get_mapping_status() to dump every mpext field.

---
 include/trace/events/mptcp.h | 52 ++++++++++++++++++++++++++++++++++++
 net/mptcp/subflow.c          |  6 ++---
 2 files changed, 55 insertions(+), 3 deletions(-)
include/trace/events/mptcp.h +52 -0
index f1c836573744..4a6cc475fb73 100644
@@ -47,6 +47,58 @@ TRACE_EVENT(mptcp_subflow_get_send,
 		  __entry->backup, __entry->ratio)
 );
 
+DECLARE_EVENT_CLASS(mptcp_dump_mpext,
+
+	TP_PROTO(struct mptcp_ext *mpext),
+
+	TP_ARGS(mpext),
+
+	TP_STRUCT__entry(
+		__field(u64, data_ack)
+		__field(u64, data_seq)
+		__field(u32, subflow_seq)
+		__field(u16, data_len)
+		__field(u8, use_map)
+		__field(u8, dsn64)
+		__field(u8, data_fin)
+		__field(u8, use_ack)
+		__field(u8, ack64)
+		__field(u8, mpc_map)
+		__field(u8, frozen)
+		__field(u8, reset_transient)
+		__field(u8, reset_reason)
+	),
+
+	TP_fast_assign(
+		__entry->data_ack = mpext->ack64 ? mpext->data_ack : mpext->data_ack32;
+		__entry->data_seq = mpext->data_seq;
+		__entry->subflow_seq = mpext->subflow_seq;
+		__entry->data_len = mpext->data_len;
+		__entry->use_map = mpext->use_map;
+		__entry->dsn64 = mpext->dsn64;
+		__entry->data_fin = mpext->data_fin;
+		__entry->use_ack = mpext->use_ack;
+		__entry->ack64 = mpext->ack64;
+		__entry->mpc_map = mpext->mpc_map;
+		__entry->frozen = mpext->frozen;
+		__entry->reset_transient = mpext->reset_transient;
+		__entry->reset_reason = mpext->reset_reason;
+	),
+
+	TP_printk("data_ack=%llu data_seq=%llu subflow_seq=%u data_len=%u use_map=%u dsn64=%u data_fin=%u use_ack=%u ack64=%u mpc_map=%u frozen=%u reset_transient=%u reset_reason=%u",
+		  __entry->data_ack, __entry->data_seq,
+		  __entry->subflow_seq, __entry->data_len,
+		  __entry->use_map, __entry->dsn64,
+		  __entry->data_fin, __entry->use_ack,
+		  __entry->ack64, __entry->mpc_map,
+		  __entry->frozen, __entry->reset_transient,
+		  __entry->reset_reason)
+);
+
+DEFINE_EVENT(mptcp_dump_mpext, get_mapping_status,
+	TP_PROTO(struct mptcp_ext *mpext),
+	TP_ARGS(mpext));
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/subflow.c +3 -3
index 3c19a5265a0f..a88c2b1e5410 100644
@@ -25,6 +25,8 @@
 #include "protocol.h"
 #include "mib.h"
 
+#include <trace/events/mptcp.h>
+
 static void mptcp_subflow_ops_undo_override(struct sock *ssk);
 
 static void SUBFLOW_REQ_INC_STATS(struct request_sock *req,
@@ -858,9 +860,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 		goto validate_seq;
 	}
 
-	pr_debug("seq=%llu is64=%d ssn=%u data_len=%u data_fin=%d",
-		 mpext->data_seq, mpext->dsn64, mpext->subflow_seq,
-		 mpext->data_len, mpext->data_fin);
+	trace_get_mapping_status(mpext);
 
 	data_len = mpext->data_len;
 	if (data_len == 0) {
Signature · 1 line
2.30.2
#4 lore raw

PATCH v4 4/5 mptcp: add tracepoint in ack_update_msk

This patch added a tracepoint in ack_update_msk() to track the incoming data_ack and window/snd_una updates.

---
 include/trace/events/mptcp.h | 32 ++++++++++++++++++++++++++++++++
 net/mptcp/options.c          |  6 ++++++
 2 files changed, 38 insertions(+)
include/trace/events/mptcp.h +32 -0
index 4a6cc475fb73..b4e6ca941bb7 100644
@@ -99,6 +99,38 @@ DEFINE_EVENT(mptcp_dump_mpext, get_mapping_status,
 	TP_PROTO(struct mptcp_ext *mpext),
 	TP_ARGS(mpext));
 
+TRACE_EVENT(ack_update_msk,
+
+	TP_PROTO(u64 data_ack, u64 old_snd_una,
+		 u64 new_snd_una, u64 new_wnd_end,
+		 u64 msk_wnd_end),
+
+	TP_ARGS(data_ack, old_snd_una,
+		new_snd_una, new_wnd_end,
+		msk_wnd_end),
+
+	TP_STRUCT__entry(
+		__field(u64, data_ack)
+		__field(u64, old_snd_una)
+		__field(u64, new_snd_una)
+		__field(u64, new_wnd_end)
+		__field(u64, msk_wnd_end)
+	),
+
+	TP_fast_assign(
+		__entry->data_ack = data_ack;
+		__entry->old_snd_una = old_snd_una;
+		__entry->new_snd_una = new_snd_una;
+		__entry->new_wnd_end = new_wnd_end;
+		__entry->msk_wnd_end = msk_wnd_end;
+	),
+
+	TP_printk("data_ack=%llu old_snd_una=%llu new_snd_una=%llu new_wnd_end=%llu msk_wnd_end=%llu",
+		  __entry->data_ack, __entry->old_snd_una,
+		  __entry->new_snd_una, __entry->new_wnd_end,
+		  __entry->msk_wnd_end)
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/options.c +6 -0
index d51c3ad54d9a..99fc21406168 100644
@@ -13,6 +13,8 @@
 #include "protocol.h"
 #include "mib.h"
 
+#include <trace/events/mptcp.h>
+
 static bool mptcp_cap_flag_sha256(u8 flags)
 {
 	return (flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA256;
@@ -943,6 +945,10 @@ static void ack_update_msk(struct mptcp_sock *msk,
 		__mptcp_data_acked(sk);
 	}
 	mptcp_data_unlock(sk);
+
+	trace_ack_update_msk(mp_opt->data_ack,
+			     old_snd_una, new_snd_una,
+			     new_wnd_end, msk->wnd_end);
 }
 
 bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, bool use_64bit)
Signature · 1 line
2.30.2
#5 lore raw

PATCH v4 5/5 mptcp: add tracepoint in subflow_check_data_avail

This patch added a tracepoint in subflow_check_data_avail() to show the mapping status.

---
 include/trace/events/mptcp.h | 29 +++++++++++++++++++++++++++++
 net/mptcp/subflow.c          |  4 +---
 2 files changed, 30 insertions(+), 3 deletions(-)
include/trace/events/mptcp.h +29 -0
index b4e6ca941bb7..902772c439dc 100644
@@ -7,6 +7,14 @@
 
 #include <linux/tracepoint.h>
 
+#define show_mapping_status(status)					\
+	__print_symbolic(status,					\
+		{ 0, "MAPPING_OK" },					\
+		{ 1, "MAPPING_INVALID" },				\
+		{ 2, "MAPPING_EMPTY" },					\
+		{ 3, "MAPPING_DATA_FIN" },				\
+		{ 4, "MAPPING_DUMMY" })
+
 TRACE_EVENT(mptcp_subflow_get_send,
 
 	TP_PROTO(struct mptcp_subflow_context *subflow),
@@ -131,6 +139,27 @@ TRACE_EVENT(ack_update_msk,
 		  __entry->msk_wnd_end)
 );
 
+TRACE_EVENT(subflow_check_data_avail,
+
+	TP_PROTO(__u8 status, struct sk_buff *skb),
+
+	TP_ARGS(status, skb),
+
+	TP_STRUCT__entry(
+		__field(u8, status)
+		__field(const void *, skb)
+	),
+
+	TP_fast_assign(
+		__entry->status = status;
+		__entry->skb = skb;
+	),
+
+	TP_printk("mapping_status=%s, skb=%p",
+		  show_mapping_status(__entry->status),
+		  __entry->skb)
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/subflow.c +1 -3
index a88c2b1e5410..d79a99c2bfc4 100644
@@ -998,8 +998,6 @@ static bool subflow_check_data_avail(struct sock *ssk)
 	struct mptcp_sock *msk;
 	struct sk_buff *skb;
 
-	pr_debug("msk=%p ssk=%p data_avail=%d skb=%p", subflow->conn, ssk,
-		 subflow->data_avail, skb_peek(&ssk->sk_receive_queue));
 	if (!skb_peek(&ssk->sk_receive_queue))
 		subflow->data_avail = 0;
 	if (subflow->data_avail)
@@ -1011,7 +1009,7 @@ static bool subflow_check_data_avail(struct sock *ssk)
 		u64 old_ack;
 
 		status = get_mapping_status(ssk, msk);
-		pr_debug("msk=%p ssk=%p status=%d", msk, ssk, status);
+		trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue));
 		if (status == MAPPING_INVALID) {
 			ssk->sk_err = EBADMSG;
 			goto fatal;
Signature · 1 line
2.30.2
maintainer
#6 lore raw

Re: [MPTCP][PATCH v4 mptcp-next 2/5] mptcp: add tracepoint in mptcp_subflow_get_send

In reply to Geliang Tang
Quoted 49 lines · Geliang Tang

This patch added a tracepoint in the packet scheduler function mptcp_subflow_get_send().

---
 include/trace/events/mptcp.h | 53 ++++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c         |  8 +++---
 2 files changed, 57 insertions(+), 4 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
include/trace/events/mptcp.h new file +32 -0
new file mode 100644
index 000000000000..f1c836573744
@@ -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);
+

include/trace/events/mptcp.h line 42

Quoted 10 lines
include/trace/events/mptcp.h new file +10 -0
+			__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);
+			}
+		}
+	),

Minor nit: I think we can reduce the indentation level and probably we should zeroed the uninitialized fields, but I think we can do that eventually later with a squash-to patch. I suggest to merge this as is and than eventually improve later.

Thanks!

Paolo

#7 lore raw

Re: [MPTCP][PATCH v4 mptcp-next 2/5] mptcp: add tracepoint in mptcp_subflow_get_send

Quoted 58 lines · Paolo Abeni <[email protected]> 于2021年4月1日周四 下午6:18写道:
Quoted 56 lines · Geliang Tang

This patch added a tracepoint in the packet scheduler function mptcp_subflow_get_send().

---
 include/trace/events/mptcp.h | 53 ++++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c         |  8 +++---
 2 files changed, 57 insertions(+), 4 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
include/trace/events/mptcp.h new file +39 -0
new file mode 100644
index 000000000000..f1c836573744
@@ -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);
Quoted 8 lines

include/trace/events/mptcp.h line 42

Quoted 3 lines
include/trace/events/mptcp.h new file +3 -0
+                     }
+             }
+     ),

Minor nit: I think we can reduce the indentation level and probably we should zeroed the uninitialized fields, but I think we can do that eventually later with a squash-to patch. I suggest to merge this as is and than eventually improve later.

Thanks Paolo, I'll send the squash-to patch later.

-Geliang

Quoted 5 lines

Thanks!

Paolo

#8 lore raw
In reply to Geliang Tang

Hi Geliang, Paolo,

Quoted 8 lines · Geliang Tang

v4:
- add back patch 1.
- use sk_fullsock in patch 2.

v3:
- update the patch set as Paolo suggested.
- drop the patch "mptcp: export mptcp_subflow_active".

Quoted 8 lines

v2:
- add two new patches.

This patchset addressed issues 131, replace some/most pr_debug with trace events. As Paolo suggested, we should add the tracepoints at "the packet scheduler and the mapping status" first.

I already closed it, even if there is still one pending squash-to patch.

Quoted 6 lines

Geliang Tang (5):
mptcp: export mptcp_subflow_active
mptcp: add tracepoint in mptcp_subflow_get_send
mptcp: add tracepoint in get_mapping_status
mptcp: add tracepoint in ack_update_msk
mptcp: add tracepoint in subflow_check_data_avail

Thank you for the patches and reviews!

Just applied in our tree with Paolo's ACK + a modification of the MAINTAINERS file in patch 2/5

- 00ed6f03febe: mptcp: export mptcp_subflow_active
- e4421bbffd09: mptcp: add tracepoint in mptcp_subflow_get_send
- 12abe4c31032: mptcp: add tracepoint in get_mapping_status
- 88a550c12ce4: mptcp: add tracepoint in ack_update_msk
- 769badb3d5a3: mptcp: add tracepoint in subflow_check_data_avail

Tests + export are in progress!

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net