public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: William Cohen <wcohen@redhat.com>
To: systemtap@sourceware.org
Cc: William Cohen <wcohen@redhat.com>
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	[thread overview]
Message-ID: <20180921145607.5484-2-wcohen@redhat.com> (raw)
In-Reply-To: <20180921145607.5484-1-wcohen@redhat.com>

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

  parent reply	other threads:[~2018-09-21 14:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-21 14:56 [PATCH 0/4] syscall_any tapset to improve performance William Cohen
2018-09-21 14:56 ` [PATCH 3/4] Add the syscall_any and syscall_any.return probe points William Cohen
2018-09-21 14:56 ` William Cohen [this message]
2018-09-21 14:56 ` [PATCH 2/4] Adjust comment in tapset/errno.stp so the documentation can be built William Cohen
2018-09-21 14:56 ` [PATCH 4/4] Convert the various systemtap examples to use the syscall any tapset William Cohen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180921145607.5484-2-wcohen@redhat.com \
    --to=wcohen@redhat.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).