From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22657 invoked by alias); 21 Sep 2018 14:56:17 -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 22574 invoked by uid 89); 21 Sep 2018 14:56:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=batch, corp, Corp, 1214 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:14 +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 3B42D88E61 for ; Fri, 21 Sep 2018 14:56:13 +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 DC7EA308BDA4; Fri, 21 Sep 2018 14:56:12 +0000 (UTC) From: William Cohen To: systemtap@sourceware.org Cc: William Cohen Subject: [PATCH 1/4] Use sys_enter and sys_exit tracepoints in place of syscall.*{.return} Date: Fri, 21 Sep 2018 14:56:00 -0000 Message-Id: <20180921145607.5484-2-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/msg00193.txt.bz2 The common probe point idiom of syscall.* and syscall.*.return can be replaced with equivalent sys_enter and sys_exit tracepoints for a number of the example scripts. The advantages are: -Quicker compilation of the script into instrumenation -Smaller kernels modules for the instrumentation -Lower overhead for probe points This changes are not applicable to all uses use syscall.* and syscall.*.return. The predefined variable such as argstr are not available for the sys_enter and sys_exit trace points. Some of the revised examples are using the internal _stp_syscall_nr()) function. A user visible version of this function should be available. --- testsuite/systemtap.examples/general/eventcount.meta | 2 +- testsuite/systemtap.examples/general/stopwatches.stp | 4 ++-- testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp | 3 ++- testsuite/systemtap.examples/process/syscalls_by_pid.stp | 2 +- .../systemtap.examples/process/syscalls_by_proc.stp | 3 ++- testsuite/systemtap.examples/process/syscalltimes | 9 +++++---- testsuite/systemtap.examples/process/thread-business.stp | 6 +++--- .../systemtap.examples/profiling/container_check.stp | 7 ++++--- testsuite/systemtap.examples/profiling/errno.stp | 7 ++++--- testsuite/systemtap.examples/profiling/topsys.stp | 3 ++- 10 files changed, 26 insertions(+), 20 deletions(-) diff --git a/testsuite/systemtap.examples/general/eventcount.meta b/testsuite/systemtap.examples/general/eventcount.meta index 200ac5645..6567a3ea5 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 'syscall.*' -c 'sleep 3' +test_installcheck: stap eventcount.stp 'kernel.trace("sys_enter")' -c 'sleep 3' diff --git a/testsuite/systemtap.examples/general/stopwatches.stp b/testsuite/systemtap.examples/general/stopwatches.stp index 60275b974..8c28f3a5f 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 syscall.* +probe kernel.trace("sys_enter") { if (pid() != target()) next stop_stopwatch("user") start_stopwatch("system") } -probe syscall.*.return +probe kernel.trace("sys_exit") { 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 edd70cddb..4ed64908c 100755 --- a/testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp +++ b/testsuite/systemtap.examples/lwtools/syscallbypid-nd.stp @@ -27,8 +27,9 @@ probe begin printf("Tracing syscall completions... Hit Ctrl-C to end.\n"); } -probe nd_syscall.*.return +probe kernel.trace("sys_exit") { + 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 06ed7b727..5cf64be12 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 nd_syscall.* { +probe kernel.trace("sys_enter") { syscalls[pid()]++ } diff --git a/testsuite/systemtap.examples/process/syscalls_by_proc.stp b/testsuite/systemtap.examples/process/syscalls_by_proc.stp index cf89424eb..dcf480611 100755 --- a/testsuite/systemtap.examples/process/syscalls_by_proc.stp +++ b/testsuite/systemtap.examples/process/syscalls_by_proc.stp @@ -1,6 +1,7 @@ #! /usr/bin/env stap # Copyright (C) 2006 IBM Corp. +# Copyright (C) 2018 Red Hat, Inc. # # This file is part of systemtap, and is free software. You can # redistribute it and/or modify it under the terms of the GNU General @@ -17,7 +18,7 @@ probe begin { print ("Collecting data... Type Ctrl-C to exit and display results\n") } -probe nd_syscall.* { +probe kernel.trace("sys_enter") { syscalls[execname()]++ } diff --git a/testsuite/systemtap.examples/process/syscalltimes b/testsuite/systemtap.examples/process/syscalltimes index 3aae186ec..08d11ea99 100755 --- a/testsuite/systemtap.examples/process/syscalltimes +++ b/testsuite/systemtap.examples/process/syscalltimes @@ -2,7 +2,7 @@ # Syscalltimes systemtap script # Copyright (C) 2007 IBM Corp. -# Copyright (C) 2011 Red Hat, Inc. +# Copyright (C) 2011,2018 Red Hat, Inc. # # This file is part of systemtap, and is free software. You can # redistribute it and/or modify it under the terms of the GNU General @@ -138,11 +138,12 @@ probe begin { } } -probe syscall.* { - starttime[name, tid()] = gettimeofday_ns() +probe kernel.trace("sys_enter") { + starttime[syscall_name($id), tid()] = gettimeofday_ns() } -probe syscall.*.return { +probe kernel.trace("sys_exit") { + name = syscall_name(_stp_syscall_nr()) # 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 5e258c017..71aa5b8b6 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 nd_syscall.* # use non-dwarf variant; we don't need context data +probe kernel.trace("sys_enter") # use syscall tracepoint; we don't need context data { activity[execname(),tid()]<<<1 - history = name." ".activity2[execname(),tid()] + history = syscall_name($id)." ".activity2[execname(),tid()] activity2[execname(),tid()] = substr(history,0,syscall_history_length) } @@ -25,4 +25,4 @@ probe timer.s(5) printf("\n") delete activity delete activity2 -} \ No newline at end of file +} diff --git a/testsuite/systemtap.examples/profiling/container_check.stp b/testsuite/systemtap.examples/profiling/container_check.stp index 51bca8bc4..882b6582c 100755 --- a/testsuite/systemtap.examples/profiling/container_check.stp +++ b/testsuite/systemtap.examples/profiling/container_check.stp @@ -146,7 +146,8 @@ probe ns_capable !, capable cap_use[tid()] |= cap } -probe nd_syscall.*.return { +probe kernel.trace("sys_exit") { + name = syscall_name(_stp_syscall_nr()) # note any problem capabilities use during syscall cap = cap_use[tid()] if (cap && child_of_target(task_current())) { @@ -161,8 +162,8 @@ probe nd_syscall.*.return { } # note any syscalls returning errors - if (retval < 0 && child_of_target(task_current())) { - syscall_errno[execname(), name, retval] <<< 1 + if ($ret < 0 && child_of_target(task_current())) { + syscall_errno[execname(), name, $ret] <<< 1 } } diff --git a/testsuite/systemtap.examples/profiling/errno.stp b/testsuite/systemtap.examples/profiling/errno.stp index 599f05d1a..9137e31f6 100755 --- a/testsuite/systemtap.examples/profiling/errno.stp +++ b/testsuite/systemtap.examples/profiling/errno.stp @@ -1,6 +1,6 @@ #! /usr/bin/env stap # -# Copyright (C) 2010 Red Hat, Inc. +# Copyright (C) 2010, 2018 Red Hat, Inc. # By Dominic Duval, Red Hat Inc. # dduval@redhat.com # @@ -11,8 +11,9 @@ global execname, errors -probe syscall.*.return { - errno = retval +probe kernel.trace("sys_exit") { + name = syscall_name(_stp_syscall_nr()) + errno = $ret if ( errno < 0 ) { p = pid() execname[p]=execname(); diff --git a/testsuite/systemtap.examples/profiling/topsys.stp b/testsuite/systemtap.examples/profiling/topsys.stp index 1263e52a2..08bcf0366 100755 --- a/testsuite/systemtap.examples/profiling/topsys.stp +++ b/testsuite/systemtap.examples/profiling/topsys.stp @@ -6,7 +6,8 @@ global syscalls_count -probe syscall.* { +probe kernel.trace("sys_enter") { + name = syscall_name($id) syscalls_count[name] <<< 1 } -- 2.17.1