• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:pid

2 # @lint-avoid-python-3-compatibility-imports
7 # USAGE: runqlat [-h] [-T] [-m] [-P] [-L] [-p PID] [interval] [count]
10 # on-CPU, and shows this time as a histogram. This time should be small, but a
15 # and execution. This traces ttwu_do_wakeup(), wake_up_new_task() ->
25 # 07-Feb-2016 Brendan Gregg Created this.
36 ./runqlat -mT 1 # 1s summaries, milliseconds, and timestamps
37 ./runqlat -P # show each PID separately
38 ./runqlat -p 185 # trace PID 185 only
44 parser.add_argument("-T", "--timestamp", action="store_true",
46 parser.add_argument("-m", "--milliseconds", action="store_true",
48 parser.add_argument("-P", "--pids", action="store_true",
50 # PID options are --pid and --pids, so namespaces should be --pidns (not done
51 # yet) and --pidnss:
52 parser.add_argument("--pidnss", action="store_true",
53 help="print a histogram per PID namespace")
54 parser.add_argument("-L", "--tids", action="store_true",
56 parser.add_argument("-p", "--pid",
57 help="trace this PID only")
62 parser.add_argument("--ebpf", action="store_true",
92 static int trace_enqueue(u32 tgid, u32 pid)
94 if (FILTER || pid == 0)
97 start.update(&pid, &ts);
113 /* get the pid namespace by following task_active_pid_ns(),
114 * pid->numbers[pid->level].ns
116 bpf_probe_read_kernel(&pids, sizeof(pids), &task->pids[PIDTYPE_PID]);
117 bpf_probe_read_kernel(&level, sizeof(level), &pids.pid->level);
118 bpf_probe_read_kernel(&upid, sizeof(upid), &pids.pid->numbers[level]);
119 bpf_probe_read_kernel(&ns, sizeof(ns), &upid.ns->ns);
123 struct pid *pid;
128 /* get the pid namespace by following task_active_pid_ns(),
129 * pid->numbers[pid->level].ns
131 bpf_probe_read_kernel(&pid, sizeof(pid), &task->thread_pid);
132 bpf_probe_read_kernel(&level, sizeof(level), &pid->level);
133 bpf_probe_read_kernel(&upid, sizeof(upid), &pid->numbers[level]);
134 bpf_probe_read_kernel(&ns, sizeof(ns), &upid.ns->ns);
144 return trace_enqueue(p->tgid, p->pid);
150 return trace_enqueue(p->tgid, p->pid);
156 u32 pid, tgid;
159 if (prev->STATE_FIELD == TASK_RUNNING) {
160 tgid = prev->tgid;
161 pid = prev->pid;
162 if (!(FILTER || pid == 0)) {
164 start.update(&pid, &ts);
169 pid = bpf_get_current_pid_tgid();
170 if (FILTER || pid == 0)
175 tsp = start.lookup(&pid);
179 delta = bpf_ktime_get_ns() - *tsp;
185 start.delete(&pid);
194 struct task_struct *p = (struct task_struct *)ctx->args[0];
195 return trace_enqueue(p->tgid, p->pid);
201 struct task_struct *p = (struct task_struct *)ctx->args[0];
202 return trace_enqueue(p->tgid, p->pid);
208 struct task_struct *prev = (struct task_struct *)ctx->args[1];
209 struct task_struct *next = (struct task_struct *)ctx->args[2];
210 u32 pid, tgid;
213 if (prev->STATE_FIELD == TASK_RUNNING) {
214 tgid = prev->tgid;
215 pid = prev->pid;
216 if (!(FILTER || pid == 0)) {
218 start.update(&pid, &ts);
222 tgid = next->tgid;
223 pid = next->pid;
224 if (FILTER || pid == 0)
229 tsp = start.lookup(&pid);
233 delta = bpf_ktime_get_ns() - *tsp;
239 start.delete(&pid);
255 if args.pid:
256 # pid from userspace point of view is thread group from kernel pov
257 bpf_text = bpf_text.replace('FILTER', 'tgid != %s' % args.pid)
267 section = "pid"
268 pid = "tgid" variable
270 pid = "pid" variable
275 'pid_key_t key = {.id = ' + pid + ', .slot = bpf_log2l(delta)}; ' +
302 print("Tracing run queue latency... Hit Ctrl-C to end.")
315 print("%-8s\n" % strftime("%H:%M:%S"), end="")
320 countdown -= 1