public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 4/4] Convert the various systemtap examples to use the syscall any tapset
  2018-09-21 14:56 [PATCH 0/4] syscall_any tapset to improve performance William Cohen
                   ` (2 preceding siblings ...)
  2018-09-21 14:56 ` [PATCH 1/4] Use sys_enter and sys_exit tracepoints in place of syscall.*{.return} William Cohen
@ 2018-09-21 14:56 ` William Cohen
  3 siblings, 0 replies; 5+ messages in thread
From: William Cohen @ 2018-09-21 14:56 UTC (permalink / raw)
  To: systemtap; +Cc: William Cohen

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] Use sys_enter and sys_exit tracepoints in place of syscall.*{.return}
  2018-09-21 14:56 [PATCH 0/4] syscall_any tapset to improve performance William Cohen
  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 3/4] Add the syscall_any and syscall_any.return probe points William Cohen
@ 2018-09-21 14:56 ` William Cohen
  2018-09-21 14:56 ` [PATCH 4/4] Convert the various systemtap examples to use the syscall any tapset William Cohen
  3 siblings, 0 replies; 5+ messages in thread
From: William Cohen @ 2018-09-21 14:56 UTC (permalink / raw)
  To: systemtap; +Cc: William Cohen

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] Add the syscall_any and syscall_any.return probe points
  2018-09-21 14:56 [PATCH 0/4] syscall_any tapset to improve performance William Cohen
  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 ` William Cohen
  2018-09-21 14:56 ` [PATCH 1/4] Use sys_enter and sys_exit tracepoints in place of syscall.*{.return} William Cohen
  2018-09-21 14:56 ` [PATCH 4/4] Convert the various systemtap examples to use the syscall any tapset William Cohen
  3 siblings, 0 replies; 5+ messages in thread
From: William Cohen @ 2018-09-21 14:56 UTC (permalink / raw)
  To: systemtap; +Cc: William Cohen

The syscall.*{.return} and np_syscall.*.{.return} end up expanding to
large amount of code that takes a signficant amount of time to
compile.  The resulting kernel module also takes a fair amount of time
to install and remove the instrumentation when it starts and shuts
down.  For instrumentation don't really care about the details of the
syscall arguments it would be preferable to use the sys_enter and sys_exit
tracepoints to more efficiently probe the one or two places.

Using tp_syscall.*{.return} end up generating a lot of code to
determine which of the hundreds of syscall is being used and then runs
the same handler.  The syscall_any and syscall_any.return eliminate
that undesired overhead by just looking up the syscall name in a
table.
---
 doc/SystemTap_Tapset_Reference/tapsets.tmpl | 12 +++++
 tapset/linux/sysc_any.stp                   | 50 +++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 tapset/linux/sysc_any.stp

diff --git a/doc/SystemTap_Tapset_Reference/tapsets.tmpl b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
index c92e91b68..74e7f7762 100644
--- a/doc/SystemTap_Tapset_Reference/tapsets.tmpl
+++ b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
@@ -463,6 +463,18 @@
 !Itapset/switchfile.stp
   </chapter>
 
+  <chapter id="syscall_any.stp">
+    <title>Syscall Any Tapset</title>
+    <para>
+      This family of probe points is designed to provide low cost
+      instrumentation for cases where only the syscall name (or number)
+      and return value are required and there is no need for the detailed
+      syscall argument values. They are restricted versions of
+      syscall.* and syscall.*.return.
+    </para>
+!Itapset/linux/sysc_any.stp
+  </chapter>
+
 !Syscalls
 
 </book>
diff --git a/tapset/linux/sysc_any.stp b/tapset/linux/sysc_any.stp
new file mode 100644
index 000000000..5ef1f794e
--- /dev/null
+++ b/tapset/linux/sysc_any.stp
@@ -0,0 +1,50 @@
+/**
+ * probe syscall_any - Record entry into a syscall
+ *
+ * @syscall_nr: number of the syscall
+ * @name: name of the syscall
+ *
+ * Context: The process performing the syscall
+ *
+ * The syscall_any probe point is designed to be a low overhead
+ * that monitors all the syscalls entered via a kernel tracepoint.
+ * Because of the breadth of syscalls it monitors it provides
+ * no information about the syscall arguments or argstr string
+ * representation of those arguments.
+ *
+ * This requires kernel 3.5+ and newer which have the
+ * kernel.trace("sys_enter") probe point.
+ */
+probe syscall_any = kernel.trace("sys_enter")
+{
+	__set_syscall_pt_regs($regs)
+	syscall_nr = $id
+	name = syscall_name($id)
+}
+
+/**
+ * probe syscall_any.return - Record exit from a syscall
+ *
+ * @syscall_nr: number of the syscall
+ * @name: name of the syscall
+ * @retval: return value of the syscall
+ *
+ * Context: The process performing the syscall
+ *
+ * The syscall_any.return probe point is designed to be a low overhead
+ * that monitors all the syscalls returns via a kernel tracepoint.
+ * Because of the breadth of syscalls it monitors it provides
+ * no information about the syscall arguments, argstr string
+ * representation of those arguments, or a string interpretation
+ * of the return value (retval).
+ *
+ * This requires kernel 3.5+ and newer which have the
+ * kernel.trace("sys_exit") probe point.
+ */
+probe syscall_any.return = kernel.trace("sys_exit")
+{
+	__set_syscall_pt_regs($regs)
+	syscall_nr = _stp_syscall_nr()
+	name = syscall_name(_stp_syscall_nr())
+	retval = $ret
+}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] Adjust comment in tapset/errno.stp so the documentation can be built.
  2018-09-21 14:56 [PATCH 0/4] syscall_any tapset to improve performance William Cohen
@ 2018-09-21 14:56 ` William Cohen
  2018-09-21 14:56 ` [PATCH 3/4] Add the syscall_any and syscall_any.return probe points William Cohen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: William Cohen @ 2018-09-21 14:56 UTC (permalink / raw)
  To: systemtap; +Cc: William Cohen

---
 tapset/errno.stp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tapset/errno.stp b/tapset/errno.stp
index affa33c4f..a75e3bac2 100644
--- a/tapset/errno.stp
+++ b/tapset/errno.stp
@@ -415,6 +415,8 @@ function set_returnval(val:long) %{
 %) /* compatible <= 4.0 */
 
 
+/* NB: The following function is not STABLE because it depends on varying
+   state in the context. */
 /**
  * sfunction returnval - Possible return value of probed function
  *
@@ -423,8 +425,6 @@ function set_returnval(val:long) %{
  * available. This is only a guess of the actual return value and can be
  * totally wrong. Normally only used in dwarfless probes.
  */
-/* NB: this function is not STABLE because it depends on varying
-   state in the context. */
 function returnval:long () %{ /* pure */
 	struct pt_regs *regs;
   #if STAP_COMPAT_VERSION <= STAP_VERSION(4,0)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 0/4] syscall_any tapset to improve performance
@ 2018-09-21 14:56 William Cohen
  2018-09-21 14:56 ` [PATCH 2/4] Adjust comment in tapset/errno.stp so the documentation can be built William Cohen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: William Cohen @ 2018-09-21 14:56 UTC (permalink / raw)
  To: systemtap; +Cc: William Cohen

When running on Fedora with a 4.17 kernel a number of the systemtap
example scripts using the syscall.* and syscall.*.return fail because
the syscall tapset update is not yet complete.  These scripts were
just noting the syscall name and the return values.  The new
syscall_any and syscall_any.return makes the instrumentation more
resiliant to the details and mechanics of how the kernel handles
syscalls.

While investigating the failures of scripts using syscall.* and
syscall.*.return found that a significant amount of time is spent to
create the instrumentation because of the number of probes.  The use
of the syscall_any probes greatly reduces that overhead producing a
smaller kernel module and also yields a faster starup and shutdown
because there are fewer instrumentation probes to install and remove.
Below are pass times and sizes of syscalls_by_proc.stp running on a
RHEL7.5 x86_64 system.  Also compared the tracepoint variant of the
syscalls tapset, tp_syscall.*.

           syscall.*   syscall_any	tp_syscall.*
pass2        10.8s          1.1s              8.9s
pass4         9.9s          1.4s              7.5s
*src.c     1070154 bytes  32582 bytes     41501 bytes
*src.o      491400 bytes  90016 bytes     96768 bytes
*src.ko     505480 bytes  97584 bytes    102976 bytes


William Cohen (4):
  Use sys_enter and sys_exit tracepoints in place of syscall.*{.return}
  Adjust comment in tapset/errno.stp so the documentation can be built.
  Add the syscall_any and syscall_any.return probe points
  Convert the various systemtap examples to use the syscall any tapset

 doc/SystemTap_Tapset_Reference/tapsets.tmpl   | 12 +++++
 tapset/errno.stp                              |  4 +-
 tapset/linux/sysc_any.stp                     | 50 +++++++++++++++++++
 .../general/eventcount.meta                   |  2 +-
 .../general/stopwatches.stp                   |  4 +-
 .../lwtools/syscallbypid-nd.stp               |  2 +-
 .../process/syscalls_by_pid.stp               |  2 +-
 .../process/syscalls_by_proc.stp              |  3 +-
 .../systemtap.examples/process/syscalltimes   |  6 +--
 .../process/thread-business.stp               |  4 +-
 .../profiling/container_check.stp             |  2 +-
 .../systemtap.examples/profiling/errno.stp    |  4 +-
 .../profiling/syscallerrorsbypid.stp          | 10 ++--
 .../profiling/syscalllatency.stp              |  6 +--
 .../profiling/syscallsbypid.stp               |  4 +-
 .../systemtap.examples/profiling/topsys.stp   |  2 +-
 16 files changed, 90 insertions(+), 27 deletions(-)
 create mode 100644 tapset/linux/sysc_any.stp

-- 
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-21 14:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21 14:56 [PATCH 0/4] syscall_any tapset to improve performance William Cohen
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 3/4] Add the syscall_any and syscall_any.return probe points William Cohen
2018-09-21 14:56 ` [PATCH 1/4] Use sys_enter and sys_exit tracepoints in place of syscall.*{.return} William Cohen
2018-09-21 14:56 ` [PATCH 4/4] Convert the various systemtap examples to use the syscall any tapset William Cohen

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).