summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/systemtap/systemtap/scheduler-stp.patch
blob: 9897e481a34ae25db790bf96ab4a1b56e201db9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
scheduler.stp: Handle missing symbols.

Compiler output code optimization leads to missing debug data for some
target variables, in particular some inline functions parameters, e.g.
context_switch.

Handle this by testing for variable name resolvability and provide default
variable values in case no suitable target data is available through variable
name. Affected functions: ctxswitch,wakeup.

This fix does not affect the intended context switch tracing.


Upstream-Status: Pending

Signed-off-by: George Nita <george.nita@enea.com>


diff --git a/tapset/linux/scheduler.stp b/tapset/linux/scheduler.stp
index 7596a46..539a0f1 100644
--- a/tapset/linux/scheduler.stp
+++ b/tapset/linux/scheduler.stp
@@ -120,7 +120,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
 %( arch != "x86_64" && arch != "ia64" && arch != "arm" %?
 	kernel.function("__switch_to")
 %:
-	kernel.function("context_switch")
+	kernel.function("prepare_task_switch")
 %)
 {
 	name = "ctxswitch"
@@ -140,7 +140,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
 		prev_task_name = task_execname($prev_p)
 		prevtsk_state = $prev_p->state
 	}
-	else {
+	else if (@defined($prev)) {
 		prev_priority = $prev->prio
 		prev_pid = $prev->tgid
 		prev_tid = $prev->pid
@@ -148,6 +148,15 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
 		prev_task_name = task_execname($prev)
 		prevtsk_state = $prev->state
 	}
+	else {
+		prev_priority = 0
+		prev_pid = 0
+		prev_tid = 0
+		/* No prev_task, dummy */
+		prev_task = task_current()
+		prev_task_name = "UNAVAILABLE"
+		prevtsk_state = 0
+	}
 
 	if (@defined($next)) {
 		next_priority = $next->prio
@@ -165,7 +174,7 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
 		next_task_name = task_execname($next_p)
 		nexttsk_state = $next_p->state
 	}
-	else {
+	else if (@defined($new)) {
 		next_priority = $new->prio
 		next_pid = $new->tgid
 		next_tid = $new->pid
@@ -173,6 +182,14 @@ probe scheduler.ctxswitch = kernel.trace("sched_switch") !,
 		next_task_name = task_execname($new)
 		nexttsk_state = $new->state
 	}
+	else {
+		next_task = task_current()
+		next_priority = task_prio(next_task)
+		next_pid = task_pid(next_task)
+		next_tid = task_tid(next_task)
+		next_task_name = task_execname(next_task)
+		nexttsk_state = task_state(next_task)
+	}
 }
 
 
@@ -254,12 +271,22 @@ probe scheduler.wakeup =
 	kernel.function("try_to_wake_up")
 {
 	name = "wakeup"
-	task = $p
-	task_pid = $p->tgid
-	task_tid = $p->pid
-	task_priority = $p->prio
-	task_cpu = task_cpu($p)
-	task_state = task_state($p)
+	if (@defined($p)) {
+		task = $p
+		task_pid = $p->tgid
+		task_tid = $p->pid
+		task_priority = $p->prio
+		task_cpu = task_cpu($p)
+		task_state = task_state($p)
+	}
+	else {
+		task = task_current()
+		task_pid = task_pid(task)
+		task_tid = task_tid(task)
+		task_priority = task_prio(task)
+		task_cpu = task_cpu(task)
+		task_state = task_state(task)
+	}
 }
 
 /**