From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23315 invoked by alias); 21 Sep 2018 14:56:21 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 23238 invoked by uid 89); 21 Sep 2018 14:56:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Sep 2018 14:56:18 +0000 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04F443082B06 for ; Fri, 21 Sep 2018 14:56:17 +0000 (UTC) Received: from cervelo.rdu.redhat.com (dhcp129-44.rdu.redhat.com [10.13.129.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id B29A3308BDA0; Fri, 21 Sep 2018 14:56:16 +0000 (UTC) From: William Cohen To: systemtap@sourceware.org Cc: William Cohen Subject: [PATCH 4/4] Convert the various systemtap examples to use the syscall any tapset Date: Fri, 21 Sep 2018 14:56:00 -0000 Message-Id: <20180921145607.5484-5-wcohen@redhat.com> In-Reply-To: <20180921145607.5484-1-wcohen@redhat.com> References: <20180921145607.5484-1-wcohen@redhat.com> X-IsSubscribed: yes X-SW-Source: 2018-q3/txt/msg00196.txt.bz2 To make the examples cleaner use the new syscall any tapset. This avoids exposing the systemtap internal function _stp_syscall_nr() and makes the instrumentation look a bit more like the traditional syscall.* probe points. --- testsuite/systemtap.examples/general/eventcount.meta | 2 +- testsuite/systemtap.examples/general/stopwatches.stp | 4 ++-- .../systemtap.examples/lwtools/syscallbypid-nd.stp | 3 +-- .../systemtap.examples/process/syscalls_by_pid.stp | 2 +- .../systemtap.examples/process/syscalls_by_proc.stp | 2 +- testsuite/systemtap.examples/process/syscalltimes | 7 +++---- .../systemtap.examples/process/thread-business.stp | 4 ++-- .../systemtap.examples/profiling/container_check.stp | 7 +++---- testsuite/systemtap.examples/profiling/errno.stp | 5 ++--- .../profiling/syscallerrorsbypid.stp | 10 +++++----- .../systemtap.examples/profiling/syscalllatency.stp | 6 +++--- .../systemtap.examples/profiling/syscallsbypid.stp | 4 ++-- testsuite/systemtap.examples/profiling/topsys.stp | 3 +-- 13 files changed, 27 insertions(+), 32 deletions(-) diff --git a/testsuite/systemtap.examples/general/eventcount.meta b/testsuite/systemtap.examples/general/eventcount.meta index 6567a3ea5..cd0dd0df8 100644 --- a/testsuite/systemtap.examples/general/eventcount.meta +++ b/testsuite/systemtap.examples/general/eventcount.meta @@ -10,4 +10,4 @@ output: batch on-exit scope: system-wide description: The script periodically prints a count of specified events and their related tid's over the course of execution. Numerous configuration options exist to control filtering / reporting, some of which can be modified at runtime. See the script source for more information. test_check: stap -p4 eventcount.stp -test_installcheck: stap eventcount.stp 'kernel.trace("sys_enter")' -c 'sleep 3' +test_installcheck: stap eventcount.stp 'syscall_any' -c 'sleep 3' diff --git a/testsuite/systemtap.examples/general/stopwatches.stp b/testsuite/systemtap.examples/general/stopwatches.stp index 8c28f3a5f..23e96a719 100755 --- a/testsuite/systemtap.examples/general/stopwatches.stp +++ b/testsuite/systemtap.examples/general/stopwatches.stp @@ -12,14 +12,14 @@ probe begin stop_stopwatch("system") } -probe kernel.trace("sys_enter") +probe syscall_any { if (pid() != target()) next stop_stopwatch("user") start_stopwatch("system") } -probe kernel.trace("sys_exit") +probe syscall_any.return { if (pid() != target()) next start_stopwatch("user") diff --git a/testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp b/testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp index 4ed64908c..f1f4f6e3c 100755 --- a/testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp +++ b/testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp @@ -27,9 +27,8 @@ probe begin printf("Tracing syscall completions... Hit Ctrl-C to end.\n"); } -probe kernel.trace("sys_exit") +probe syscall_any.return { - name = syscall_name(_stp_syscall_nr()) num[pid(), execname(), name] <<< 1; } diff --git a/testsuite/systemtap.examples/process/syscalls_by_pid.stp b/testsuite/systemtap.examples/process/syscalls_by_pid.stp index 5cf64be12..adef67537 100755 --- a/testsuite/systemtap.examples/process/syscalls_by_pid.stp +++ b/testsuite/systemtap.examples/process/syscalls_by_pid.stp @@ -17,7 +17,7 @@ probe begin { print ("Collecting data... Type Ctrl-C to exit and display results\n") } -probe kernel.trace("sys_enter") { +probe syscall_any { syscalls[pid()]++ } diff --git a/testsuite/systemtap.examples/process/syscalls_by_proc.stp b/testsuite/systemtap.examples/process/syscalls_by_proc.stp index dcf480611..941da9ae0 100755 --- a/testsuite/systemtap.examples/process/syscalls_by_proc.stp +++ b/testsuite/systemtap.examples/process/syscalls_by_proc.stp @@ -18,7 +18,7 @@ probe begin { print ("Collecting data... Type Ctrl-C to exit and display results\n") } -probe kernel.trace("sys_enter") { +probe syscall_any { syscalls[execname()]++ } diff --git a/testsuite/systemtap.examples/process/syscalltimes b/testsuite/systemtap.examples/process/syscalltimes index 08d11ea99..a0b356e06 100755 --- a/testsuite/systemtap.examples/process/syscalltimes +++ b/testsuite/systemtap.examples/process/syscalltimes @@ -138,12 +138,11 @@ probe begin { } } -probe kernel.trace("sys_enter") { - starttime[syscall_name($id), tid()] = gettimeofday_ns() +probe syscall_any { + starttime[name, tid()] = gettimeofday_ns() } -probe kernel.trace("sys_exit") { - name = syscall_name(_stp_syscall_nr()) +probe syscall_any.return { # Skip if we have not seen this before if (!([name, tid()] in starttime)) next diff --git a/testsuite/systemtap.examples/process/thread-business.stp b/testsuite/systemtap.examples/process/thread-business.stp index 71aa5b8b6..e25bb125e 100755 --- a/testsuite/systemtap.examples/process/thread-business.stp +++ b/testsuite/systemtap.examples/process/thread-business.stp @@ -6,10 +6,10 @@ global activity2 // [execname,tid]->syscall-name-string-history global syscall_history_length = 50 // override with stap -Gsyscall_history_length=NNN global top_threads = 20 -probe kernel.trace("sys_enter") # use syscall tracepoint; we don't need context data +probe syscall_any # use tracepoint based syscall_any; we don't need context data { activity[execname(),tid()]<<<1 - history = syscall_name($id)." ".activity2[execname(),tid()] + history = name." ".activity2[execname(),tid()] activity2[execname(),tid()] = substr(history,0,syscall_history_length) } diff --git a/testsuite/systemtap.examples/profiling/container_check.stp b/testsuite/systemtap.examples/profiling/container_check.stp index 882b6582c..1c34f689d 100755 --- a/testsuite/systemtap.examples/profiling/container_check.stp +++ b/testsuite/systemtap.examples/profiling/container_check.stp @@ -146,8 +146,7 @@ probe ns_capable !, capable cap_use[tid()] |= cap } -probe kernel.trace("sys_exit") { - name = syscall_name(_stp_syscall_nr()) +probe syscall_any.return { # note any problem capabilities use during syscall cap = cap_use[tid()] if (cap && child_of_target(task_current())) { @@ -162,8 +161,8 @@ probe kernel.trace("sys_exit") { } # note any syscalls returning errors - if ($ret < 0 && child_of_target(task_current())) { - syscall_errno[execname(), name, $ret] <<< 1 + if (retval < 0 && child_of_target(task_current())) { + syscall_errno[execname(), name, retval] <<< 1 } } diff --git a/testsuite/systemtap.examples/profiling/errno.stp b/testsuite/systemtap.examples/profiling/errno.stp index 9137e31f6..991d5104c 100755 --- a/testsuite/systemtap.examples/profiling/errno.stp +++ b/testsuite/systemtap.examples/profiling/errno.stp @@ -11,9 +11,8 @@ global execname, errors -probe kernel.trace("sys_exit") { - name = syscall_name(_stp_syscall_nr()) - errno = $ret +probe syscall_any.return { + errno = retval if ( errno < 0 ) { p = pid() execname[p]=execname(); diff --git a/testsuite/systemtap.examples/profiling/syscallerrorsbypid.stp b/testsuite/systemtap.examples/profiling/syscallerrorsbypid.stp index db97175f9..fafe3e6d0 100755 --- a/testsuite/systemtap.examples/profiling/syscallerrorsbypid.stp +++ b/testsuite/systemtap.examples/profiling/syscallerrorsbypid.stp @@ -13,12 +13,12 @@ global arr%[20000], sys%[20000] global procname% -probe kernel.trace("sys_enter") { - sys[tid()] = $id +probe syscall_any { + sys[tid()] = syscall_nr } -probe kernel.trace("sys_exit") { - if (tid() in sys && $ret < 0 ) { - arr[pid(), sys[tid()], $ret]++ +probe syscall_any.return { + if (tid() in sys && retval < 0 ) { + arr[pid(), sys[tid()], retval]++ procname[pid()] = execname() } delete sys[tid()] diff --git a/testsuite/systemtap.examples/profiling/syscalllatency.stp b/testsuite/systemtap.examples/profiling/syscalllatency.stp index f0cf2fddb..cda03270d 100755 --- a/testsuite/systemtap.examples/profiling/syscalllatency.stp +++ b/testsuite/systemtap.examples/profiling/syscalllatency.stp @@ -12,11 +12,11 @@ global arr%[20000], sys%[20000], entry_time%[20000] -probe kernel.trace("sys_enter") { +probe syscall_any { entry_time[tid()] = gettimeofday_ns(); - sys[tid()] = $id + sys[tid()] = syscall_nr } -probe kernel.trace("sys_exit") { +probe syscall_any.return { et = entry_time[tid()] id = sys[tid()] delete entry_time[tid()] diff --git a/testsuite/systemtap.examples/profiling/syscallsbypid.stp b/testsuite/systemtap.examples/profiling/syscallsbypid.stp index 9b1af01a1..b59491e88 100755 --- a/testsuite/systemtap.examples/profiling/syscallsbypid.stp +++ b/testsuite/systemtap.examples/profiling/syscallsbypid.stp @@ -13,8 +13,8 @@ global arr%[20000] global procname% -probe kernel.trace("sys_enter") { - arr[pid(), $id]++ +probe syscall_any { + arr[pid(), syscall_nr]++ procname[pid()] = execname() } diff --git a/testsuite/systemtap.examples/profiling/topsys.stp b/testsuite/systemtap.examples/profiling/topsys.stp index 08bcf0366..cf0b122aa 100755 --- a/testsuite/systemtap.examples/profiling/topsys.stp +++ b/testsuite/systemtap.examples/profiling/topsys.stp @@ -6,8 +6,7 @@ global syscalls_count -probe kernel.trace("sys_enter") { - name = syscall_name($id) +probe syscall_any { syscalls_count[name] <<< 1 } -- 2.17.1