Lines Matching +full:- +full:- +full:pid
2 # @lint-avoid-python-3-compatibility-imports
4 # cpudist Summarize on- and off-CPU time per task as a histogram.
6 # USAGE: cpudist [-h] [-O] [-T] [-m] [-P] [-L] [-p PID] [-I] [interval] [count]
9 # as a histogram, optionally per-process.
11 # By default CPU idle time are excluded by simply excluding PID 0.
16 # 27-Mar-2022 Rocky Xing Changed to exclude CPU idle time by default.
24 cpudist # summarize on-CPU time as a histogram
25 cpudist -O # summarize off-CPU time as a histogram
27 cpudist -mT 1 # 1s summaries, milliseconds, and timestamps
28 cpudist -P # show each PID separately
29 cpudist -p 185 # trace PID 185 only
30 cpudist -I # include CPU idle time
33 description="Summarize on-CPU time per task as a histogram.",
36 parser.add_argument("-O", "--offcpu", action="store_true",
37 help="measure off-CPU time")
38 parser.add_argument("-T", "--timestamp", action="store_true",
40 parser.add_argument("-m", "--milliseconds", action="store_true",
42 parser.add_argument("-P", "--pids", action="store_true",
44 parser.add_argument("-L", "--tids", action="store_true",
46 parser.add_argument("-p", "--pid",
47 help="trace this PID only")
48 parser.add_argument("-I", "--include-idle", action="store_true",
54 parser.add_argument("--ebpf", action="store_true",
69 u32 pid;
82 static inline void store_start(u32 tgid, u32 pid, u32 cpu, u64 ts)
90 entry_key_t entry_key = { .pid = pid, .cpu = cpu };
94 static inline void update_hist(u32 tgid, u32 pid, u32 cpu, u64 ts)
102 entry_key_t entry_key = { .pid = pid, .cpu = cpu };
108 // Probably a clock issue where the recorded on-CPU event had a
109 // timestamp later than the recorded off-CPU event, or vice versa.
112 u64 delta = ts - *tsp;
121 u32 tgid = pid_tgid >> 32, pid = pid_tgid;
124 u32 prev_pid = prev->pid;
125 u32 prev_tgid = prev->tgid;
134 store_start(tgid, pid, cpu, ts);
136 update_hist(tgid, pid, cpu, ts);
143 if args.pid:
144 bpf_text = bpf_text.replace('PID_FILTER', 'tgid != %s' % args.pid)
149 idle_filter = 'pid == 0'
161 section = "pid"
162 pid = "tgid" variable
164 pid = "pid" variable
169 'pid_key_t key = {.id = ' + pid + ', .slot = bpf_log2l(delta)}; ' +
183 b = BPF(text=bpf_text, cflags=["-DMAX_PID=%d" % max_pid])
187 print("Tracing %s-CPU time... Hit Ctrl-C to end." %
200 print("%-8s\n" % strftime("%H:%M:%S"), end="")
202 def pid_to_comm(pid): argument
204 comm = open("/proc/%d/comm" % pid, "r").read()
205 return "%d %s" % (pid, comm)
207 return str(pid)
212 countdown -= 1