-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlat.stp
73 lines (61 loc) · 1.77 KB
/
lat.stp
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
%{
#include <linux/stacktrace.h>
#include <linux/latencytop.h>
#ifndef LT_BACKTRACEDEPTH
#define LT_BACKTRACEDEPTH 12
#endif
%}
%( $# != 3 %? **ERROR** %)
global min_delay = $1
global max_interruptible_delay = $2
global pid_filter = $3
function task_stack_trace:string(tsk:long) %{
struct stack_trace trace;
unsigned long backtrace[LT_BACKTRACEDEPTH];
char *p = STAP_RETVALUE;
int i;
bool first = true;
BUILD_BUG_ON(MAXSTRINGLEN < LT_BACKTRACEDEPTH * (2 + 8*2 + 1));
memset(&trace, 0, sizeof(trace));
trace.max_entries = LT_BACKTRACEDEPTH;
trace.entries = backtrace;
save_stack_trace_tsk((struct task_struct*)STAP_ARG_tsk, &trace);
for (i = 0; i < LT_BACKTRACEDEPTH; i++) {
unsigned long record = backtrace[i];
if (record == 0 || record == ULONG_MAX)
goto finish;
if (!first)
*p++ = ' ';
sprintf(p, "0x%08lx", record);
p += 2 + 8*2;
first = false;
}
finish:
*p = '\0';
%}
probe kernel.trace("sched_stat_sleep") {
/* Long interruptible waits are generally user-requested */
/* Negative sleeps are time going backwards */
/* Zero-time sleeps are non-interesting */
pid = task_pid($tsk);
if ((pid_filter == 0 || pid_filter == pid) &&
$delay > min_delay && $delay <= max_interruptible_delay) {
printf("S %lu %lu %lu %s\n%s\n",
$delay, pid, task_tid($tsk), task_execname($tsk),
task_stack_trace($tsk));
}
}
probe kernel.trace("sched_stat_blocked") {
/* Negative sleeps are time going backwards */
/* Zero-time sleeps are non-interesting */
pid = task_pid($tsk);
if ((pid_filter == 0 || pid_filter == pid) &&
$delay > min_delay) {
printf("B %lu %lu %lu %s\n%s\n",
$delay, pid, task_tid($tsk), task_execname($tsk),
task_stack_trace($tsk));
}
}
probe begin {
printf("lat begin\n");
}