From 8468168d7ec2eedd7ff7a2013e5bfe9d1d3ecb69 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 315a24c21151dacd4d97e3c30e6762bbe631cac9..61c7647bbcfc1b4dd943363824f1259c579f550a 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@ @@ -1082,6 +1083,8 @@ SYSTEMTAP_PROBES = \ $(srcdir)/src/systemtap/sssd_probes.d \ $(NULL) +systemtap_tap_DATA = $(builddir)/src/systemtap/sssd.stp + 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 0d2f4f06d8a3cbe44bdc190453bd0e523dd34aa5..80feb826639b653ff87a413b2eb1b3a7ddc22ff6 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -26,6 +26,7 @@ #include "util/crypto/sss_crypto.h" #include "db/sysdb_private.h" #include "confdb/confdb.h" +#include "util/probes.h" #include #define LDB_MODULES_PATH "LDB_MODULES_PATH" @@ -918,6 +919,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, @@ -929,10 +931,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); @@ -947,6 +954,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