Skip to contentSkip to conversation

add tracepoints

PATCH New Geliang Tang 1 participant 4 messages Feb 22, 2021

Subsystems (3)
lore
Share & tools
lore

Geliang Tang

author
#0 lore raw

cover add tracepoints

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 (3):
mptcp: add tracepoint for mptcp_subflow_get_send
mptcp: add tracepoint for get_mapping_status
mptcp: add tracepoint for subflow_check_data_avail

 include/trace/events/mptcp.h | 122 +++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c         |   9 ++-
 net/mptcp/subflow.c          |  15 ++---
 3 files changed, 132 insertions(+), 14 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH 1/3 mptcp: add tracepoint for mptcp_subflow_get_send

This patch added the tracepoint for the packet scheduler function mptcp_subflow_get_send.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 45 ++++++++++++++++++++++++++++++++++++
 net/mptcp/protocol.c         |  9 +++++---
 2 files changed, 51 insertions(+), 3 deletions(-)
 create mode 100644 include/trace/events/mptcp.h
include/trace/events/mptcp.h new file +45 -0
new file mode 100644
index 000000000000..b36b308f48e2
@@ -0,0 +1,45 @@
+/* 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_sock *msk, int nr_active,
+		 struct sock *ssk_0, u64 ratio_0,
+		 struct sock *ssk_1, u64 ratio_1),
+
+	TP_ARGS(msk, nr_active, ssk_0, ratio_0, ssk_1, ratio_1),
+
+	TP_STRUCT__entry(
+		__field(const void *, msk)
+		__field(__u32, nr_active)
+		__field(const void *, ssk_0)
+		__field(__u64, ratio_0)
+		__field(const void *, ssk_1)
+		__field(__u64, ratio_1)
+	),
+
+	TP_fast_assign(
+		__entry->msk = msk;
+		__entry->nr_active = nr_active;
+		__entry->ssk_0 = ssk_0;
+		__entry->ratio_0 = ratio_0;
+		__entry->ssk_1 = ssk_1;
+		__entry->ratio_1 = ratio_1;
+	),
+
+	TP_printk("msk=%p nr_active=%d ssk=%p:%lld backup=%p:%lld",
+		  __entry->msk, __entry->nr_active,
+		  __entry->ssk_0, __entry->ratio_0,
+		  __entry->ssk_1, __entry->ratio_1)
+);
+
+#endif /* _TRACE_MPTCP_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
net/mptcp/protocol.c +6 -3
index ec808187fa0e..dff3f8c96c5d 100644
@@ -27,6 +27,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;
@@ -1418,9 +1421,9 @@ 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);
+	trace_mptcp_subflow_get_send(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)
Signature · 1 line
2.29.2
author
#2 lore raw

PATCH 2/3 mptcp: add tracepoint for get_mapping_status

This patch added the tracepoint for the mapping status function get_mapping_status.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 51 ++++++++++++++++++++++++++++++++++++
 net/mptcp/subflow.c          | 13 +++------
 2 files changed, 54 insertions(+), 10 deletions(-)
include/trace/events/mptcp.h +51 -0
index b36b308f48e2..f06a7d33b237 100644
@@ -39,6 +39,57 @@ TRACE_EVENT(mptcp_subflow_get_send,
 		  __entry->ssk_1, __entry->ratio_1)
 );
 
+TRACE_EVENT(get_mapping_status,
+
+	TP_PROTO(struct mptcp_ext *mpext),
+
+	TP_ARGS(mpext),
+
+	TP_STRUCT__entry(
+		__array(char, str, 128)
+	),
+
+	TP_fast_assign(
+		memset(__entry->str, 0, 128);
+
+		if (!mpext) {
+			sprintf(__entry->str, "mpext is NULL");
+		} else {
+			if (!mpext->data_len) {
+				sprintf(__entry->str, "Infinite mapping not handled");
+			} else {
+				if (mpext->data_fin == 1) {
+					if (mpext->data_len == 1) {
+						sprintf(__entry->str,
+							"data_fin: with no payload seq=%llu",
+							mpext->data_seq);
+					} else {
+						sprintf(__entry->str,
+							"data_fin: with mapping seq=%llu dsn64=%d",
+							mpext->data_seq + mpext->data_len - 1,
+							mpext->dsn64);
+					}
+				}
+
+				if (mpext->use_map) {
+					sprintf(__entry->str + strlen(__entry->str),
+						"use_map: dsn64=%d data_seq=%llu subflow_seq=%u data_len=%u",
+						mpext->dsn64, mpext->data_seq,
+						mpext->subflow_seq, mpext->data_len);
+				}
+
+				if (mpext->use_ack) {
+					sprintf(__entry->str + strlen(__entry->str),
+						"use_ack: ack64=%d data_ack=%llu",
+						mpext->ack64, mpext->data_ack);
+				}
+			}
+		}
+	),
+
+	TP_printk("%s", __entry->str)
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/subflow.c +3 -10
index 82ec174e2bac..6f4145abd85e 100644
@@ -27,6 +27,8 @@
 
 static void mptcp_subflow_ops_undo_override(struct sock *ssk);
 
+#include <trace/events/mptcp.h>
+
 static void SUBFLOW_REQ_INC_STATS(struct request_sock *req,
 				  enum linux_mptcp_mib_field field)
 {
@@ -808,6 +810,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 		return MAPPING_DUMMY;
 
 	mpext = mptcp_get_ext(skb);
+	trace_get_mapping_status(mpext);
 	if (!mpext || !mpext->use_map) {
 		if (!subflow->map_valid && !skb->len) {
 			/* the TCP stack deliver 0 len FIN pkt to the receive
@@ -829,10 +832,6 @@ 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);
-
 	data_len = mpext->data_len;
 	if (data_len == 0) {
 		pr_err("Infinite mapping not handled");
@@ -844,7 +843,6 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 		if (data_len == 1) {
 			bool updated = mptcp_update_rcv_data_fin(msk, mpext->data_seq,
 								 mpext->dsn64);
-			pr_debug("DATA_FIN with no payload seq=%llu", mpext->data_seq);
 			if (subflow->map_valid) {
 				/* A DATA_FIN might arrive in a DSS
 				 * option before the previous mapping
@@ -869,8 +867,6 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 				data_fin_seq &= GENMASK_ULL(31, 0);
 
 			mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64);
-			pr_debug("DATA_FIN with mapping seq=%llu dsn64=%d",
-				 data_fin_seq, mpext->dsn64);
 		}
 
 		/* Adjust for DATA_FIN using 1 byte of sequence space */
@@ -912,9 +908,6 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 	subflow->map_data_len = data_len;
 	subflow->map_valid = 1;
 	subflow->mpc_map = mpext->mpc_map;
-	pr_debug("new map seq=%llu subflow_seq=%u data_len=%u",
-		 subflow->map_seq, subflow->map_subflow_seq,
-		 subflow->map_data_len);
 
 validate_seq:
 	/* we revalidate valid mapping on new skb, because we must ensure
Signature · 1 line
2.29.2
author
#3 lore raw

PATCH 3/3 mptcp: add tracepoint for subflow_check_data_avail

This patch added the tracepoint for subflow_check_data_avail to show the mapping status.

Signed-off-by Geliang Tang <geliangtang(a)gmail.com>
---
 include/trace/events/mptcp.h | 26 ++++++++++++++++++++++++++
 net/mptcp/subflow.c          |  2 +-
 2 files changed, 27 insertions(+), 1 deletion(-)
include/trace/events/mptcp.h +26 -0
index f06a7d33b237..29570009a7e4 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_sock *msk, int nr_active,
@@ -90,6 +98,24 @@ TRACE_EVENT(get_mapping_status,
 	TP_printk("%s", __entry->str)
 );
 
+TRACE_EVENT(subflow_check_data_avail,
+
+	TP_PROTO(__u8 status),
+
+	TP_ARGS(status),
+
+	TP_STRUCT__entry(
+		__field(__u8, status)
+	),
+
+	TP_fast_assign(
+		__entry->status = status;
+	),
+
+	TP_printk("mapping_status = %s",
+		  show_mapping_status(__entry->status))
+);
+
 #endif /* _TRACE_MPTCP_H */
 
 /* This part must be outside protection */
net/mptcp/subflow.c +1 -1
index 6f4145abd85e..0c5e1ec0d418 100644
@@ -975,7 +975,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);
 		if (status == MAPPING_INVALID) {
 			ssk->sk_err = EBADMSG;
 			goto fatal;
Signature · 1 line
2.29.2