[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/main] Add lttng trace support.



commit 896c16c3b175d24b2247b37008bf61faebb6dee9
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Tue Sep 28 22:27:51 2021 +0000

    Add lttng trace support.
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/core/or/include.am        |   3 +
 src/core/or/lttng_cc.inc      | 166 ++++++++++++++++++++++++++++++++++++++++++
 src/core/or/trace_probes_cc.c |  33 +++++++++
 src/core/or/trace_probes_cc.h |  22 ++++++
 4 files changed, 224 insertions(+)

diff --git a/src/core/or/include.am b/src/core/or/include.am
index d142062216..66529b70b2 100644
--- a/src/core/or/include.am
+++ b/src/core/or/include.am
@@ -82,6 +82,7 @@ noinst_HEADERS +=					\
 	src/core/or/entry_port_cfg_st.h			\
 	src/core/or/extend_info_st.h			\
 	src/core/or/listener_connection_st.h		\
+	src/core/or/lttng_cc.inc			\
 	src/core/or/lttng_circuit.inc			\
 	src/core/or/onion.h				\
 	src/core/or/or.h				\
@@ -115,7 +116,9 @@ noinst_HEADERS +=					\
 
 if USE_TRACING_INSTRUMENTATION_LTTNG
 LIBTOR_APP_A_SOURCES += \
+	src/core/or/trace_probes_cc.c				\
 	src/core/or/trace_probes_circuit.c
 noinst_HEADERS += \
+	src/core/or/trace_probes_cc.h				\
 	src/core/or/trace_probes_circuit.h
 endif
diff --git a/src/core/or/lttng_cc.inc b/src/core/or/lttng_cc.inc
new file mode 100644
index 0000000000..b7bf58e196
--- /dev/null
+++ b/src/core/or/lttng_cc.inc
@@ -0,0 +1,166 @@
+/* Copyright (c) 2021, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file lttng_cc.inc
+ * \brief LTTng tracing probe declaration for the congestion control subsystem.
+ *        It is in this .inc file due to the non C standard syntax and the way
+ *        we guard the header with the LTTng specific
+ *        TRACEPOINT_HEADER_MULTI_READ.
+ **/
+
+#include "orconfig.h"
+
+/* We only build the following if LTTng instrumentation has been enabled. */
+#ifdef USE_TRACING_INSTRUMENTATION_LTTNG
+
+/* The following defines are LTTng-UST specific. */
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tor_cc
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./src/core/or/lttng_cc.inc"
+
+#if !defined(LTTNG_CC_INC) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define LTTNG_CC_INC
+
+#include <lttng/tracepoint.h>
+
+/*
+ * Flow Control
+ */
+
+/* Emitted everytime the flow_control_decide_xon() function is called. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xon,
+  TP_ARGS(const edge_connection_t *, stream, size_t, n_written),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(size_t, written_bytes, n_written)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/* Emitted when flow control starts measuring the drain rate. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xon_drain_start,
+  TP_ARGS(const edge_connection_t *, stream),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/* Emitted when the drain rate is updated. The new_drain_rate value is what was
+ * just computed. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xon_drain_update,
+  TP_ARGS(const edge_connection_t *, stream, uint32_t, drain_rate),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, new_drain_rate, drain_rate)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/* Emitted when an XON cell is sent due to a notice in a drain rate change. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xon_rate_change,
+  TP_ARGS(const edge_connection_t *, stream),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/* Emitted when an XON cell is sent because we partially or fully drained the
+ * edge connection buffer. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xon_partial_drain,
+  TP_ARGS(const edge_connection_t *, stream),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/* Emitted when we double the drain rate which is an attempt to see if we can
+ * speed things up. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xon_drain_doubled,
+  TP_ARGS(const edge_connection_t *, stream),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/* XOFF */
+
+/* Emitted when we send an XOFF cell. */
+TRACEPOINT_EVENT(tor_cc, flow_decide_xoff_sending,
+  TP_ARGS(const edge_connection_t *, stream),
+  TP_FIELDS(
+    ctf_integer(uint64_t, stream_id, TO_CONN(stream)->global_identifier)
+    ctf_integer(uint32_t, drained_bytes_current, stream->drained_bytes)
+    ctf_integer(uint32_t, drained_bytes_previous, stream->prev_drained_bytes)
+    ctf_integer(uint32_t, ewma_drain_rate_last, stream->ewma_rate_last_sent)
+    ctf_integer(uint32_t, ewma_drain_rate_current, stream->ewma_drain_rate)
+    ctf_integer(size_t, outbuf_len,
+                connection_get_outbuf_len(TO_CONN(stream)))
+  )
+)
+
+/*
+ * Congestion Control
+ */
+
+/* Emitted when the BDP value has been updated. */
+TRACEPOINT_EVENT(tor_cc, bdp_update,
+  TP_ARGS(const circuit_t *, circ, const congestion_control_t *, cc,
+          uint64_t, curr_rtt_usec, uint64_t, sendme_rate_bdp),
+  TP_FIELDS(
+    ctf_integer(uint64_t, circuit_ptr, circ)
+    ctf_integer(uint32_t, n_circ_id, circ->n_circ_id)
+    ctf_integer(uint64_t, min_rtt_usec, cc->min_rtt_usec)
+    ctf_integer(uint64_t, curr_rtt_usec, curr_rtt_usec)
+    ctf_integer(uint64_t, ewma_rtt_usec, cc->ewma_rtt_usec)
+    ctf_integer(uint64_t, max_rtt_usec, cc->max_rtt_usec)
+    ctf_integer(uint64_t, bdp_inflight_rtt, cc->bdp[BDP_ALG_INFLIGHT_RTT])
+    ctf_integer(uint64_t, bdp_cwnd_rtt, cc->bdp[BDP_ALG_CWND_RTT])
+    ctf_integer(uint64_t, bdp_sendme_rate, cc->bdp[BDP_ALG_SENDME_RATE])
+    ctf_integer(uint64_t, bdp_piecewise, cc->bdp[BDP_ALG_PIECEWISE])
+    ctf_integer(uint64_t, sendme_rate_bdp, sendme_rate_bdp)
+  )
+)
+
+#endif /* LTTNG_CC_INC || TRACEPOINT_HEADER_MULTI_READ */
+
+/* Must be included after the probes declaration. */
+#include <lttng/tracepoint-event.h>
+
+#endif /* USE_TRACING_INSTRUMENTATION_LTTNG */
diff --git a/src/core/or/trace_probes_cc.c b/src/core/or/trace_probes_cc.c
new file mode 100644
index 0000000000..d52646da4f
--- /dev/null
+++ b/src/core/or/trace_probes_cc.c
@@ -0,0 +1,33 @@
+/* Copyright (c) 2021, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file trace_probes_cc.c
+ * \brief Tracepoint provider source file for the cc subsystem. Probes
+ *        are generated within this C file for LTTng-UST
+ **/
+
+#include "orconfig.h"
+
+/*
+ * Following section is specific to LTTng-UST.
+ */
+#ifdef USE_TRACING_INSTRUMENTATION_LTTNG
+
+/* Header files that the probes need. */
+#include "core/or/or.h"
+#include "core/or/channel.h"
+#include "core/or/circuit_st.h"
+#include "core/or/circuitlist.h"
+#include "core/or/congestion_control_st.h"
+#include "core/or/connection_st.h"
+#include "core/or/edge_connection_st.h"
+#include "core/or/or_circuit_st.h"
+#include "core/or/origin_circuit_st.h"
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+
+#include "core/or/trace_probes_cc.h"
+
+#endif /* defined(USE_TRACING_INSTRUMENTATION_LTTNG) */
diff --git a/src/core/or/trace_probes_cc.h b/src/core/or/trace_probes_cc.h
new file mode 100644
index 0000000000..1f87528723
--- /dev/null
+++ b/src/core/or/trace_probes_cc.h
@@ -0,0 +1,22 @@
+/* Copyright (c) 2021, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file trace_probes_cc.c
+ * \brief The tracing probes for the congestion control subsystem.
+ *        Currently, only LTTng-UST probes are available.
+ **/
+
+#ifndef TOR_TRACE_PROBES_CC_H
+#define TOR_TRACE_PROBES_CC_H
+
+#include "lib/trace/events.h"
+
+/* We only build the following if LTTng instrumentation has been enabled. */
+#ifdef USE_TRACING_INSTRUMENTATION_LTTNG
+
+#include "core/or/lttng_cc.inc"
+
+#endif /* USE_TRACING_INSTRUMENTATION_LTTNG */
+
+#endif /* !defined(TOR_TRACE_PROBES_CC_H) */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits