Lines Matching +full:profile +full:- +full:traces

2 # @lint-avoid-python-3-compatibility-imports
4 # profile Profile CPU usage by sampling stack traces at a timed interval.
7 # This is an efficient profiler, as stack traces are frequency counted in
10 # at the end of the profile, greatly reducing the kernel<->user transfer.
15 # a version of this tool that may work on Linux 4.6 - 4.8.
25 # 15-Jul-2016 Brendan Gregg Created this.
26 # 20-Oct-2016 " " Switched to use the new 4.9 support.
27 # 26-Jan-2019 " " Changed to exclude CPU idle by default.
28 # 11-Apr-2023 Rocky Xing Added option to increase hash storage size.
69 # -EFAULT in get_stackid normally means the stack-trace is not available,
71 return (stack_id < 0) and (stack_id != -errno.EFAULT)
75 ./profile # profile stack traces at 49 Hertz until Ctrl-C
76 ./profile -F 99 # profile stack traces at 99 Hertz
77 ./profile -c 1000000 # profile stack traces every 1 in a million events
78 ./profile 5 # profile at 49 Hertz for 5 seconds only
79 ./profile -f 5 # output in folded format for flame graphs
80 ./profile -p 185 # only profile process with PID 185
81 ./profile -L 185 # only profile thread with TID 185
82 ./profile -U # only show user space stacks (no kernel)
83 ./profile -K # only show kernel space stacks (no user)
84 ./profile --cgroupmap mappath # only trace cgroups in this BPF map
85 ./profile --mntnsmap mappath # only trace mount namespaces in the map
88 description="Profile CPU stack traces at a timed interval",
92 thread_group.add_argument("-p", "--pid", type=positive_int_list,
93 help="profile process with one or more comma separated PIDs only")
94 thread_group.add_argument("-L", "--tid", type=positive_int_list,
95 help="profile thread with one or more comma separated TIDs only")
98 stack_group.add_argument("-U", "--user-stacks-only", action="store_true",
100 stack_group.add_argument("-K", "--kernel-stacks-only", action="store_true",
103 sample_group.add_argument("-F", "--frequency", type=positive_int,
105 sample_group.add_argument("-c", "--count", type=positive_int,
107 parser.add_argument("-d", "--delimited", action="store_true",
109 parser.add_argument("-a", "--annotations", action="store_true",
111 parser.add_argument("-I", "--include-idle", action="store_true",
113 parser.add_argument("-f", "--folded", action="store_true",
115 parser.add_argument("--hash-storage-size", default=40960,
118 parser.add_argument("--stack-storage-size", default=16384,
120 help="the number of unique stack traces that can be stored and "
125 parser.add_argument("-C", "--cpu", type=int, default=-1,
126 help="cpu number to run profile on")
127 parser.add_argument("--ebpf", action="store_true",
129 parser.add_argument("--cgroupmap",
131 parser.add_argument("--mntnsmap",
198 u64 ip = PT_REGS_IP(&ctx->regs);
228 # pid-namespace translation
264 kernel_stack_get = "stack_traces.get_stackid(&ctx->regs, 0)"
265 user_stack_get = "stack_traces.get_stackid(&ctx->regs, BPF_F_USER_STACK)"
269 kernel_stack_get = "-1"
272 user_stack_get = "-1"
300 print("... Hit Ctrl-C to end.")
325 # as cleanup can take some time, trap Ctrl-C:
347 # hash collision (-EEXIST) suggests that the map size may be too small
348 has_collision = has_collision or k.kernel_stack_id == -errno.EEXIST
351 has_collision = has_collision or k.user_stack_id == -errno.EEXIST
371 line = [k.name.decode('utf-8', 'replace')]
372 # if we failed to get the stack is, such as due to no space (-ENOMEM) or
373 # hash collision (-EEXIST), we still print a placeholder for consistency
378 … line.extend([b.sym(addr, k.pid).decode('utf-8', 'replace') for addr in reversed(user_stack)])
380 … line.extend(["-"] if (need_delimiter and k.kernel_stack_id >= 0 and k.user_stack_id >= 0) else [])
384 … line.extend([aksym(addr).decode('utf-8', 'replace') for addr in reversed(kernel_stack)])
387 # print default multi-line stack output
393 print(" %s" % aksym(addr).decode('utf-8', 'replace'))
396 print(" --")
401 print(" %s" % b.sym(addr, k.pid).decode('utf-8', 'replace'))
402 print(" %-16s %s (%d)" % ("-", k.name.decode('utf-8', 'replace'), k.pid))
408 " Consider increasing --stack-storage-size."
409 print("WARNING: %d stack traces could not be displayed.%s" %
415 print("WARNING: hash table full. Consider increasing --hash-storage-size.",