Blame SOURCES/rhbz1657857.patch

132810
commit 75640f70daa0e8bab73e398113ea755e23eab887
132810
Author: William Cohen <wcohen@redhat.com>
132810
Date:   Mon Nov 12 17:24:44 2018 -0500
132810
132810
    Adjust the periodic.stp example to work with newer Linux kernels
132810
    
132810
    The data field in the timer_list struct was removed in newer kernels.
132810
    The various functions executed when a timer expires now use
132810
    container_of macros to find the struct that the timer_list was
132810
    embedded in.  The periodic.stp script has been modified to use
132810
    container_of when the data field is not available.
132810
132810
diff --git a/testsuite/systemtap.examples/profiling/periodic.stp b/testsuite/systemtap.examples/profiling/periodic.stp
132810
index 3b41981c0..f18f18399 100755
132810
--- a/testsuite/systemtap.examples/profiling/periodic.stp
132810
+++ b/testsuite/systemtap.examples/profiling/periodic.stp
132810
@@ -7,7 +7,7 @@
132810
 #
132810
 # stap --all-modules periodic.stp
132810
 
132810
-global last_expire, period, funct, data
132810
+global last_expire, period, funct, data, proc_info, delayed_work_info
132810
 
132810
 probe kernel.trace("timer_expire_entry")
132810
 {
132810
@@ -17,7 +17,9 @@ probe kernel.trace("timer_expire_entry")
132810
     elapsed = new_expire - old_expire
132810
     period[$timer] <<< elapsed
132810
     funct[$timer] = $timer->function
132810
-    data[$timer] = $timer->data
132810
+    data[$timer] = @defined($timer->data) ? $timer->data : 0
132810
+    proc_info[$timer] = @defined($timer->data) ? 0 : @container_of($timer, "struct process_timer", timer)->task
132810
+    delayed_work_info[$timer] = @defined($timer->data) ? 0 : & @container_of($timer, "struct delayed_work", timer)
132810
   }
132810
   last_expire[$timer] = new_expire
132810
 }
132810
@@ -29,14 +31,16 @@ function output()
132810
   foreach([timer] in period-) {
132810
     fname = symname(funct[timer])
132810
     if (fname == "process_timeout") {
132810
+      ptr = (data[timer] ? data[timer] : proc_info[timer])
132810
       fname = sprintf("%s(%d)",
132810
-                      kernel_string_n(@cast(data[timer], "struct task_struct", "kernel<linux/sched.h>")->comm, 16),
132810
-                      @cast(data[timer], "struct task_struct", "kernel<linux/sched.h>")->pid)
132810
+                      kernel_string_n(@cast(ptr, "struct task_struct", "kernel<linux/sched.h>")->comm, 16),
132810
+                      @cast(ptr, "struct task_struct", "kernel<linux/sched.h>")->pid)
132810
       type="process"
132810
     } else if (fname == "delayed_work_timer_fn") {
132810
-      faddr = @defined(@cast(data[timer], "struct delayed_work", "kernel<linux/workqueue.h>")->work->func)
132810
-      ? @cast(data[timer], "struct delayed_work", "kernel<linux/workqueue.h>")->work->func
132810
-      : @cast(data[timer], "struct work_struct", "kernel<linux/workqueue.h>")->func
132810
+      ptr = (data[timer] ? data[timer] : delayed_work_info[timer])
132810
+      faddr = @defined(@cast(ptr, "struct delayed_work", "kernel<linux/workqueue.h>")->work->func)
132810
+      ? @cast(ptr, "struct delayed_work", "kernel<linux/workqueue.h>")->work->func
132810
+      : @cast(ptr, "struct work_struct", "kernel<linux/workqueue.h>")->func
132810
       fname = sprintf("%s", symname(faddr))
132810
       type="work_q"
132810
     } else {
132810
@@ -68,5 +72,7 @@ probe timer.s($1)
132810
   delete period
132810
   delete funct
132810
   delete data
132810
+  delete proc_info
132810
+  delete delayed_work_info
132810
 }
132810
 %)