From cf5023fb9a29cd11a4e7bee82055530c11486424 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Tue, 23 Jun 2009 15:51:48 -0400 Subject: Add the bkl.stp and bkl_stats.stp examples. --- testsuite/systemtap.examples/locks/bkl_stats.stp | 85 ++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 testsuite/systemtap.examples/locks/bkl_stats.stp (limited to 'testsuite/systemtap.examples/locks/bkl_stats.stp') diff --git a/testsuite/systemtap.examples/locks/bkl_stats.stp b/testsuite/systemtap.examples/locks/bkl_stats.stp new file mode 100644 index 00000000..4481e493 --- /dev/null +++ b/testsuite/systemtap.examples/locks/bkl_stats.stp @@ -0,0 +1,85 @@ +#! /usr/bin/env stap + +/* + * Copyright (C) 2009 Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Print out the amount of time spent in the read and write systemcall + * when a process closes each file is closed. Note that the systemtap + * script needs to be running before the open operations occur for + * the script to record data. + * + * Description: displays statisics for waiting and holding big kernel lock (BKL) + * + * Run: stap bkl_stats.stap + * + * Author: William Cohen + */ + +global holder_time, wait_time +global holder_stats, wait_stats +global names + +probe begin { printf("biglock_stats running\n"); } + +probe end, timer.s(5) { + print_stats() +} + +function print_stats() { + # print out time waiting and time lock held + printf("big kernel lock waiting statistics\n"); + printf("%-16s %6s %6s %6s %6s %6s\n", + "name", "tid", "count", "min", "avg", "max"); + foreach (p+ in names) { + if (@count(wait_stats[p])) + printf("%16s %6d %6d %6d %6d %6d\n", names[p], p, + @count(wait_stats[p]), @min(wait_stats[p]), + @avg(wait_stats[p]), @max(wait_stats[p])); + } + + printf("\n\nbig kernel lock holder statistics\n"); + printf("%-16s %6s %6s %6s %6s %6s\n", + "name", "tid", "count", "min", "avg", "max"); + foreach (p+ in names) { + if (@count(holder_stats[p])) + printf("%16s %6d %6d %6d %6d %6d\n", names[p], p, + @count(holder_stats[p]), @min(holder_stats[p]), + @avg(holder_stats[p]), @max(holder_stats[p])); + } +} + +probe kernel.function("lock_kernel") { + t = gettimeofday_us() + wait_time[tid()] = t +} + +probe kernel.function("lock_kernel").return { + t = gettimeofday_us() + s = wait_time[tid()] + holder_time[tid()] = t + # record the amount of time waiting for the lock + if (s) { + wait_stats[tid()] <<< t - s + names[tid()] = execname() + } +} + +probe kernel.function("unlock_kernel") { + # record the amount of time the process held the lock + t = gettimeofday_us() + s = holder_time[tid()] + holder_time[tid()] = t + # record the amount of time waiting for the lock + if (s) { + holder_stats[tid()] <<< t - s + names[tid()] = execname() + } +} -- cgit From 04106d61105dc517e71cad10652cd46ce604f16c Mon Sep 17 00:00:00 2001 From: William Cohen Date: Tue, 23 Jun 2009 15:52:51 -0400 Subject: Make blk.stp and blk_stats.stp executable. --- testsuite/systemtap.examples/locks/bkl_stats.stp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 testsuite/systemtap.examples/locks/bkl_stats.stp (limited to 'testsuite/systemtap.examples/locks/bkl_stats.stp') diff --git a/testsuite/systemtap.examples/locks/bkl_stats.stp b/testsuite/systemtap.examples/locks/bkl_stats.stp old mode 100644 new mode 100755 -- cgit