This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] (Naive) approach to make schedtimes follow the children of the traced process


On fre, 2014-01-31 at 08:19 -0800, Josh Stone wrote:
> On 01/31/2014 02:46 AM, David Juran wrote:

> 
> It's a reasonable modification, but you might like the target_set.stp
> tapset to simplify it.  Call function target_set_pid(some_pid) to find
> out if it's part of the target() and its children.

Thanks, that does make it simpler (-:


-- 
David Juran
Sr. Consultant
Red Hat
+46-725-345801
>From c4f0acb0ff598cfcafa8efeef94db9af4b475e53 Mon Sep 17 00:00:00 2001
From: David Juran <djuran@redhat.com>
Date: Mon, 3 Feb 2014 12:57:55 +0100
Subject: [PATCH 2/2] simplified using target_set tapset

---
 testsuite/systemtap.examples/process/schedtimes.stp | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/testsuite/systemtap.examples/process/schedtimes.stp b/testsuite/systemtap.examples/process/schedtimes.stp
index 2731bc7..ba8282b 100755
--- a/testsuite/systemtap.examples/process/schedtimes.stp
+++ b/testsuite/systemtap.examples/process/schedtimes.stp
@@ -19,8 +19,8 @@
 //constants
 global RUNNING=0, QUEUED=1, SLEEPING=2
 
-global traced_pid, my_pids
-global run_time, queued_time,  sleep_time, io_wait_time
+global traced_pid
+global run_time, queued_time, sleep_time, io_wait_time
 global pid_state, pid_names
 global previous_timestamp
 global io_wait_count
@@ -31,24 +31,16 @@ function get_iowait:long(queue:long)
   return @cast(queue,"rq","kernel")->nr_iowait->counter;
 }
 
-probe kprocess.create {
-
-  if ( pid() in my_pids) {
-    my_pids[new_pid]++;
-  }
-
-}
-
 probe kernel.trace("sched_switch") {
   previous_pid = $prev->pid;
   next_pid = $next->pid;
   
   #is either the interrupted or the interrupting pid in our set?
   #Then we set traced pid to this one in order to do accounting
-  if (previous_pid in my_pids) {
+  if (target_set_pid(previous_pid)) {
     traced_pid = previous_pid;
   }
-  if (next_pid in my_pids) {
+  if (target_set_pid(next_pid)) {
     traced_pid = next_pid;
   }
 
@@ -122,7 +114,7 @@ probe kernel.trace("sched_switch") {
 
 probe kernel.trace("sched_wakeup") {
   wakeup_pid = $p->pid;
-  if (wakeup_pid in my_pids) {
+  if (target_set_pid(wakeup_pid)) {
     traced_pid = wakeup_pid;
   }
 
@@ -159,7 +151,6 @@ probe begin {
   } else {
     printf("target mode\n");
     printf("traced pid: %d\n", traced_pid);
-    my_pids[traced_pid]++;
   }
 }
 
-- 
1.8.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]