From c1a4fba84679bb4ce10badcc9458088e4a94d281 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 29 Feb 2016 13:20:28 +0100 Subject: [PATCH 04/10] SYSDB: Add systemtap probes to track sysdb transactions Actually adds marks for sysdb transactions that receive the transaction nesting level as an argument. The nesting is passed on from probes to marks along with a human-friendly description. The transaction commit is decorated with two probes, before and after. This would allow the caller to distinguish between the time we spend in the transaction (which might be important, because if a transaction is active on an ldb context, even the readers are blocked before the transaction completes) and the time we spend commiting the transaction (which is important because that's when the disk writes occur) The probes would be installed into /usr/share/systemtap/tapset on RHEL and Fedora. This is in line with systemtap's paths which are described in detail in "man 7 stappaths". --- Makefile.am | 4 +++- configure.ac | 1 + src/db/sysdb.c | 8 ++++++++ src/systemtap/sssd.stp.in | 32 ++++++++++++++++++++++++++++++++ src/systemtap/sssd_probes.d | 4 ++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/systemtap/sssd.stp.in diff --git a/Makefile.am b/Makefile.am index 33930759ab82b65643a9a0a071fd92b025dab145..1b4ba3cc651b29c55f7b43c90bc479f584a911e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -81,6 +81,7 @@ krb5rcachedir = @krb5rcachedir@ sudolibdir = @sudolibpath@ polkitdir = @polkitdir@ pamconfdir = $(sysconfdir)/pam.d +systemtap_tapdir = @tapset_dir@ UNICODE_LIBS=@UNICODE_LIBS@ @@ -1081,6 +1082,8 @@ SYSTEMTAP_PROBES = \ $(srcdir)/src/systemtap/sssd_probes.d \ $(NULL) +dist_systemtap_tap_DATA = $(builddir)/src/systemtap/sssd.stp + if BUILD_SYSTEMTAP stap_generated_probes.h: $(srcdir)/src/systemtap/sssd_probes.d $(AM_V_GEN)$(DTRACE) -C -h -s $< -o $@ @@ -1103,7 +1106,6 @@ CLEANFILES += stap_generated_probes.h \ stap_generated_probes.o \ stap_generated_probes.lo \ $(NULL) - endif #################### diff --git a/configure.ac b/configure.ac index 2c208cd483db977c0b1f3902b1f3c35c649cd89c..f91150e018850f4ee7753c4d257febc29531012b 100644 --- a/configure.ac +++ b/configure.ac @@ -457,5 +457,6 @@ AC_CONFIG_FILES([Makefile contrib/sssd.spec src/examples/rwtab src/doxy.config src/lib/sifp/sss_simpleifp.doxy src/config/setup.py src/responder/ifp/org.freedesktop.sssd.infopipe.service + src/systemtap/sssd.stp src/config/SSSDConfig/__init__.py]) AC_OUTPUT diff --git a/src/db/sysdb.c b/src/db/sysdb.c index f9b9b3ff864eef187eb0d3d79796e4000e56addf..dca8332e2d313dc53f334337ff41d1bcb503b9be 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -25,6 +25,7 @@ #include "util/sss_utf8.h" #include "db/sysdb_private.h" #include "confdb/confdb.h" +#include "util/probes.h" #include #define LDB_MODULES_PATH "LDB_MODULES_PATH" @@ -896,6 +897,7 @@ int sysdb_transaction_start(struct sysdb_ctx *sysdb) ret = ldb_transaction_start(sysdb->ldb); if (ret == LDB_SUCCESS) { + PROBE(SYSDB_TRANSACTION_START, sysdb->transaction_nesting); sysdb->transaction_nesting++; } else { DEBUG(SSSDBG_CRIT_FAILURE, @@ -907,10 +909,15 @@ int sysdb_transaction_start(struct sysdb_ctx *sysdb) int sysdb_transaction_commit(struct sysdb_ctx *sysdb) { int ret; +#ifdef HAVE_SYSTEMTAP + int commit_nesting = sysdb->transaction_nesting-1; +#endif + PROBE(SYSDB_TRANSACTION_COMMIT_BEFORE, commit_nesting); ret = ldb_transaction_commit(sysdb->ldb); if (ret == LDB_SUCCESS) { sysdb->transaction_nesting--; + PROBE(SYSDB_TRANSACTION_COMMIT_AFTER, sysdb->transaction_nesting); } else { DEBUG(SSSDBG_CRIT_FAILURE, "Failed to commit ldb transaction! (%d)\n", ret); @@ -925,6 +932,7 @@ int sysdb_transaction_cancel(struct sysdb_ctx *sysdb) ret = ldb_transaction_cancel(sysdb->ldb); if (ret == LDB_SUCCESS) { sysdb->transaction_nesting--; + PROBE(SYSDB_TRANSACTION_CANCEL, sysdb->transaction_nesting); } else { DEBUG(SSSDBG_CRIT_FAILURE, "Failed to cancel ldb transaction! (%d)\n", ret); diff --git a/src/systemtap/sssd.stp.in b/src/systemtap/sssd.stp.in new file mode 100644 index 0000000000000000000000000000000000000000..2bd45aeb88f2a2052221ef4890aaa580330334ec --- /dev/null +++ b/src/systemtap/sssd.stp.in @@ -0,0 +1,32 @@ +# Database transaction probes +probe sssd_transaction_start = process("@libdir@/sssd/libsss_util.so").mark("sysdb_transaction_start") +{ + nesting = $arg1; + probestr = sprintf("-> %s(nesting=%d)", + $$name, + nesting); +} + +probe sssd_transaction_commit_before = process("@libdir@/sssd/libsss_util.so").mark("sysdb_transaction_commit_before") +{ + nesting = $arg1; + probestr = sprintf("<- %s(pre)(nesting=%d)", + $$name, + nesting); +} + +probe sssd_transaction_commit_after = process("@libdir@/sssd/libsss_util.so").mark("sysdb_transaction_commit_after") +{ + nesting = $arg1; + probestr = sprintf("<- %s(post)(nesting=%d)", + $$name, + nesting); +} + +probe sssd_transaction_cancel = process("@libdir@/sssd/libsss_util.so").mark("sysdb_transaction_cancel") +{ + nesting = $arg1; + probestr = sprintf("<- %s(nesting=%d)", + $$name, + nesting); +} diff --git a/src/systemtap/sssd_probes.d b/src/systemtap/sssd_probes.d index 7579577c8661e862d83b9fc7c9fe205d25be30ed..f4890ddfdd82e67a30a955634b57b97fcaea4491 100644 --- a/src/systemtap/sssd_probes.d +++ b/src/systemtap/sssd_probes.d @@ -1,2 +1,6 @@ provider sssd { + probe sysdb_transaction_start(int nesting); + probe sysdb_transaction_commit_before(int nesting); + probe sysdb_transaction_commit_after(int nesting); + probe sysdb_transaction_cancel(int nesting); } -- 2.4.11