From e91568d6ebcdfe7777024f7b6fe752d1d6a40b13 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 | 5 +++++ src/systemtap/sssd.stp.in | 32 ++++++++++++++++++++++++++++++++ src/systemtap/sssd_probes.d | 4 ++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/systemtap/sssd.stp.in diff --git a/Makefile.am b/Makefile.am index 0cdfd54e7e7bc685e712b2ff01cc5c551f1c05cf..87f0741c3dac0de57542c365daa5eb95d5e3fe2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,6 +79,7 @@ pkgconfigdir = $(libdir)/pkgconfig krb5rcachedir = @krb5rcachedir@ sudolibdir = @sudolibpath@ polkitdir = @polkitdir@ +systemtap_tapdir = @tapset_dir@ UNICODE_LIBS=@UNICODE_LIBS@ @@ -1078,6 +1079,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 $@ @@ -1100,7 +1103,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 0c1dda7b888a80912eeee7bbbda4584a4bd6344e..56a1901677a9ef2585582b6643df06031aef0bba 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, @@ -908,9 +910,11 @@ int sysdb_transaction_commit(struct sysdb_ctx *sysdb) { int ret; + PROBE(SYSDB_TRANSACTION_COMMIT_BEFORE, sysdb->transaction_nesting-1); 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 +929,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