Change in osmo-bts[master]: initial support for static userspace probes via systemtap

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Oct 25 10:06:09 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/22641 )

Change subject: initial support for static userspace probes via systemtap
......................................................................

initial support for static userspace probes via systemtap

This adds a --enable-systemtap configure option, which will then
add static tracepoints to the generated osmo-bts-* binary.

At this point, only two sets of tracepoints are supported, and
only in osmo-bts-trx: ul_data_{start,done} and dl_rts_{start,done}.

The probes are intended to be used for analyzing the amount of time
needed for processing of uplink bursts / generation of downlink bursts.

Change-Id: Ibb4962253f1a195dc1a54405bac058ccb2545799
---
M configure.ac
M src/common/Makefile.am
A src/common/probes.d
M src/osmo-bts-trx/Makefile.am
A src/osmo-bts-trx/probes.d
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-trx/trx_if.c
7 files changed, 97 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/configure.ac b/configure.ac
index 4f2e889..91fe244 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,6 +367,38 @@
 AC_MSG_RESULT([$enable_ext_tests])
 AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
 
+#
+# SystemTap support
+#
+AC_MSG_CHECKING([whether to include systemtap tracing support])
+AC_ARG_ENABLE([systemtap],
+	      [AS_HELP_STRING([--enable-systemtap],
+			      [Enable inclusion of systemtap trace support])],
+	      [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no'])
+AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
+AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
+
+if test "x${ENABLE_SYSTEMTAP}" = xyes; then
+  # Additional configuration for --enable-systemtap is HERE
+  AC_CHECK_PROGS(DTRACE, dtrace)
+  if test -z "$DTRACE"; then
+    AC_MSG_ERROR([dtrace not found])
+  fi
+  AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'],
+                [SDT_H_FOUND='no';
+                   AC_MSG_ERROR([systemtap support needs sys/sdt.h header])])
+  AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using SystemTap probes.])
+  AC_ARG_WITH([tapset-install-dir],
+	      [AS_HELP_STRING([--with-tapset-install-dir],
+	         [The absolute path where the tapset dir will be installed])],
+	      [if test "x${withval}" = x; then
+		 ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"
+	       else
+		 ABS_TAPSET_DIR="${withval}"
+	       fi], [ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"])
+  AC_SUBST(ABS_TAPSET_DIR)
+fi
+
 # https://www.freedesktop.org/software/systemd/man/daemon.html
 AC_ARG_WITH([systemdsystemunitdir],
      [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 72438c6..5b69b5c 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)/include
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOCODEC_CFLAGS)
 LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOCODEC_LIBS)
 
@@ -44,6 +44,18 @@
 	nm_bb_transc_fsm.c \
 	nm_channel_fsm.c \
 	nm_radio_carrier_fsm.c \
+	probes.d \
 	$(NULL)
 
 libl1sched_a_SOURCES = scheduler.c
+
+if ENABLE_SYSTEMTAP
+probes.h: probes.d
+	$(DTRACE) -C -h -s $< -o $@
+
+probes.lo: probes.d
+	$(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -C -G -s $< -o $@
+
+BUILT_SOURCES = probes.h probes.lo
+libbts_la_LDADD = probes.lo
+endif
diff --git a/src/common/probes.d b/src/common/probes.d
new file mode 100644
index 0000000..aaf9030
--- /dev/null
+++ b/src/common/probes.d
@@ -0,0 +1,2 @@
+provider osmo_bts {
+};
diff --git a/src/osmo-bts-trx/Makefile.am b/src/osmo-bts-trx/Makefile.am
index 54d1af9..afa5414 100644
--- a/src/osmo-bts-trx/Makefile.am
+++ b/src/osmo-bts-trx/Makefile.am
@@ -1,6 +1,7 @@
 AM_CPPFLAGS = \
 	$(all_includes) \
 	-I$(top_srcdir)/include \
+	-I$(top_builddir)/include \
 	$(NULL)
 
 AM_CFLAGS = \
@@ -51,6 +52,7 @@
 	trx_provision_fsm.c \
 	trx_vty.c \
 	loops.c \
+	probes.d \
 	$(NULL)
 
 osmo_bts_trx_LDADD = \
@@ -58,3 +60,14 @@
 	$(top_builddir)/src/common/libbts.a \
 	$(LDADD) \
 	$(NULL)
+
+if ENABLE_SYSTEMTAP
+probes.h: probes.d
+	$(DTRACE) -C -h -s $< -o $@
+
+probes.lo: probes.d
+	$(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -C -G -s $< -o $@
+
+BUILT_SOURCES = probes.h probes.lo
+osmo_bts_trx_LDADD += probes.lo
+endif
diff --git a/src/osmo-bts-trx/probes.d b/src/osmo-bts-trx/probes.d
new file mode 100644
index 0000000..2f905bd
--- /dev/null
+++ b/src/osmo-bts-trx/probes.d
@@ -0,0 +1,7 @@
+provider osmo_bts_trx {
+	probe ul_data_start(int, int, int); /* trx_nr, ts_nr, fn */
+	probe ul_data_done(int, int, int); /* trx_nr, ts_nr, fn */
+
+	probe dl_rts_start(int, int, int); /* trx_nr, ts_nr, fn */
+	probe dl_rts_done(int, int, int); /* trx_nr, ts_nr, fn */
+};
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 6136b14..1159e59 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -50,6 +50,19 @@
 #include "l1_if.h"
 #include "trx_if.h"
 
+#include "btsconfig.h"
+
+#ifdef HAVE_SYSTEMTAP
+/* include the generated probes header and put markers in code */
+#include "probes.h"
+#define TRACE(probe) probe
+#define TRACE_ENABLED(probe) probe ## _ENABLED()
+#else
+/* Wrap the probe to allow it to be removed when no systemtap available */
+#define TRACE(probe)
+#define TRACE_ENABLED(probe) (0)
+#endif /* HAVE_SYSTEMTAP */
+
 #define SCHED_FH_PARAMS_FMT "hsn=%u, maio=%u, ma_len=%u"
 #define SCHED_FH_PARAMS_VALS(ts) \
 	(ts)->hopping.hsn, (ts)->hopping.maio, (ts)->hopping.arfcn_num
@@ -280,8 +293,10 @@
 			struct trx_dl_burst_req *br;
 
 			/* ready-to-send */
+			TRACE(OSMO_BTS_TRX_DL_RTS_START(trx->nr, tn, fn));
 			_sched_rts(l1ts, GSM_TDMA_FN_SUM(fn, plink->u.osmotrx.clock_advance
 							   + plink->u.osmotrx.rts_advance));
+			TRACE(OSMO_BTS_TRX_DL_RTS_DONE(trx->nr, tn, fn));
 
 			/* pre-initialized buffer for the Downlink burst */
 			br = &pinst->u.osmotrx.br[tn];
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 914d0e1..9232e64 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -51,6 +51,19 @@
 #include "trx_if.h"
 #include "trx_provision_fsm.h"
 
+#include "btsconfig.h"
+
+#ifdef HAVE_SYSTEMTAP
+/* include the generated probes header and put markers in code */
+#include "probes.h"
+#define TRACE(probe) probe
+#define TRACE_ENABLED(probe) probe ## _ENABLED()
+#else
+/* Wrap the probe to allow it to be removed when no systemtap available */
+#define TRACE(probe)
+#define TRACE_ENABLED(probe) (0)
+#endif /* HAVE_SYSTEMTAP */
+
 /*
  * socket helper functions
  */
@@ -1083,7 +1096,9 @@
 		bi._num_pdus++;
 
 		/* feed received burst into scheduler code */
+		TRACE(OSMO_BTS_TRX_UL_DATA_START(l1h->phy_inst->trx->nr, bi.tn, bi.fn));
 		trx_sched_route_burst_ind(l1h->phy_inst->trx, &bi);
+		TRACE(OSMO_BTS_TRX_UL_DATA_DONE(l1h->phy_inst->trx->nr, bi.tn, bi.fn));
 	} while (bi.flags & TRX_BI_F_BATCH_IND);
 
 	return 0;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/22641
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ibb4962253f1a195dc1a54405bac058ccb2545799
Gerrit-Change-Number: 22641
Gerrit-PatchSet: 9
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211025/0966373f/attachment.htm>


More information about the gerrit-log mailing list