Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/biolatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

if args.flags and args.disks:
print("ERROR: can only use -D or -F. Exiting.")
exit()
exit(1)

# define BPF program
bpf_text = """
Expand Down Expand Up @@ -294,7 +294,7 @@
# Some flags are accessible in the rwbs field (RAHEAD, SYNC and META)
# but other aren't. Disable the -F option for tracepoint for now.
print("ERROR: blk_account_io_start/done probes not available. Can't use -F.")
exit()
exit(1)

if tp_start:
bpf_text += tp_start_text.replace("START_TP", tp_start)
Expand Down
4 changes: 2 additions & 2 deletions tools/biosnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
else:
print("ERROR: No found any block io start probe/tp.")
exit()
exit(1)

if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
Expand All @@ -357,7 +357,7 @@
b.attach_kprobe(event="blk_account_io_done", fn_name="trace_req_completion")
else:
print("ERROR: No found any block io done probe/tp.")
exit()
exit(1)


# header
Expand Down
4 changes: 2 additions & 2 deletions tools/biotop.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
else:
print("ERROR: No found any block io start probe/tp.")
exit()
exit(1)

if BPF.get_kprobe_functions(b'blk_start_request'):
b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
Expand All @@ -298,7 +298,7 @@
b.attach_kprobe(event="blk_account_io_done", fn_name="trace_req_completion")
else:
print("ERROR: No found any block io done probe/tp.")
exit()
exit(1)

# check whether hash table batch ops is supported
htab_batch_ops = True if BPF.kernel_struct_has_field(b'bpf_map_ops',
Expand Down
4 changes: 2 additions & 2 deletions tools/btrfsdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
label = "usecs"
if args.interval and int(args.interval) == 0:
print("ERROR: interval 0. Exiting.")
exit()
exit(1)
debug = 0

# define BPF program
Expand Down Expand Up @@ -188,7 +188,7 @@
if ops == '':
print("ERROR: no btrfs_file_operations in /proc/kallsyms. Exiting.")
print("HINT: the kernel should be built with CONFIG_KALLSYMS_ALL.")
exit()
exit(1)
bpf_text = bpf_text.replace('BTRFS_FILE_OPERATIONS', ops)
bpf_text = bpf_text.replace('FACTOR', str(factor))
if args.pid:
Expand Down
2 changes: 1 addition & 1 deletion tools/btrfsslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
if ops == '':
print("ERROR: no btrfs_file_operations in /proc/kallsyms. Exiting.")
print("HINT: the kernel should be built with CONFIG_KALLSYMS_ALL.")
exit()
exit(1)
bpf_text = bpf_text.replace('BTRFS_FILE_OPERATIONS', ops)
if min_ms == 0:
bpf_text = bpf_text.replace('FILTER_US', '0')
Expand Down
2 changes: 1 addition & 1 deletion tools/cpuunclaimed.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def check_runnable_weight_field():
interval = 0.2
if args.interval != -1 and (args.fullcsv or args.csv):
print("ERROR: cannot use interval with either -j or -J. Exiting.")
exit()
exit(1)
if args.interval == -1:
args.interval = "1"
interval = float(args.interval)
Expand Down
2 changes: 1 addition & 1 deletion tools/criticalstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

if debugfs_path == "":
print("ERROR: Unable to find debugfs mount point");
sys.exit(0);
sys.exit(1);

trace_path = debugfs_path + b"/tracing/events/preemptirq/";

Expand Down
2 changes: 1 addition & 1 deletion tools/drsnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
if vm_stat_addr == '':
print("ERROR: no vm_stat or vm_zone_stat in /proc/kallsyms. Exiting.")
print("HINT: the kernel should be built with CONFIG_KALLSYMS_ALL.")
exit()
exit(1)

NR_FREE_PAGES = 0

Expand Down
4 changes: 2 additions & 2 deletions tools/ext4dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
label = "usecs"
if args.interval and int(args.interval) == 0:
print("ERROR: interval 0. Exiting.")
exit()
exit(1)
debug = 0

# define BPF program
Expand Down Expand Up @@ -165,7 +165,7 @@
if ext4_file_ops_addr == '':
print("ERROR: no ext4_file_operations in /proc/kallsyms. Exiting.")
print("HINT: the kernel should be built with CONFIG_KALLSYMS_ALL.")
exit()
exit(1)
ext4_trace_read_code = """
int trace_read_entry(struct pt_regs *ctx, struct kiocb *iocb)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/ext4slower.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
if ops == '':
print("ERROR: no ext4_file_operations in /proc/kallsyms. Exiting.")
print("HINT: the kernel should be built with CONFIG_KALLSYMS_ALL.")
exit()
exit(1)
bpf_text = bpf_text.replace('EXT4_FILE_OPERATIONS', ops)
if min_ms == 0:
bpf_text = bpf_text.replace('FILTER_US', '0')
Expand Down
2 changes: 1 addition & 1 deletion tools/f2fsslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
if ops == '':
print("ERROR: no f2fs_file_operations in /proc/kallsyms. Exiting.")
print("HINT: the kernel should be built with CONFIG_KALLSYMS_ALL.")
exit()
exit(1)
bpf_text = bpf_text.replace('F2FS_FILE_OPERATIONS', ops)
if min_ms == 0:
bpf_text = bpf_text.replace('FILTER_US', '0')
Expand Down
2 changes: 1 addition & 1 deletion tools/funclatency.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def signal_ignore(signal, frame):

if matched == 0:
print("0 functions matched by \"%s\". Exiting." % args.pattern)
exit()
exit(1)

# header
print("Tracing %d functions for \"%s\"... Hit Ctrl-C to end." %
Expand Down
2 changes: 1 addition & 1 deletion tools/nfsdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
label = "usecs"
if args.interval and int(args.interval) == 0:
print("ERROR: interval 0. Exiting.")
exit()
exit(1)
debug = 0

# define BPF program
Expand Down
2 changes: 1 addition & 1 deletion tools/offcputime.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def stack_id_err(stack_id):

if args.folded and args.offset:
print("ERROR: can only use -f or -s. Exiting.")
exit()
exit(1)

# signal handler
def signal_ignore(signal, frame):
Expand Down
2 changes: 1 addition & 1 deletion tools/offwaketime.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def signal_ignore(signal, frame):
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions traced. Exiting.")
exit()
exit(1)

# header
if not folded:
Expand Down
4 changes: 2 additions & 2 deletions tools/old/offcputime.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
maxdepth = 20 # and MAXDEPTH
if args.pid and args.useronly:
print("ERROR: use either -p or -u.")
exit()
exit(1)

# signal handler
def signal_ignore(signal, frame):
Expand Down Expand Up @@ -163,7 +163,7 @@ def signal_ignore(signal, frame):
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions traced. Exiting.")
exit()
exit(1)

# header
if not folded:
Expand Down
4 changes: 2 additions & 2 deletions tools/old/offwaketime.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
maxtdepth = 20 # and MAXTDEPTH
if args.pid and args.useronly:
print("ERROR: use either -p or -u.")
exit()
exit(1)

# signal handler
def signal_ignore(signal, frame):
Expand Down Expand Up @@ -212,7 +212,7 @@ def signal_ignore(signal, frame):
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions traced. Exiting.")
exit()
exit(1)

# header
if not folded:
Expand Down
2 changes: 1 addition & 1 deletion tools/old/stackcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def signal_ignore(signal, frame):
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions matched by \"%s\". Exiting." % args.pattern)
exit()
exit(1)

# header
print("Tracing %d functions for \"%s\"... Hit Ctrl-C to end." %
Expand Down
4 changes: 2 additions & 2 deletions tools/old/wakeuptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
maxdepth = 20 # and MAXDEPTH
if args.pid and args.useronly:
print("ERROR: use either -p or -u.")
exit()
exit(1)

# signal handler
def signal_ignore(signal, frame):
Expand Down Expand Up @@ -177,7 +177,7 @@ def signal_ignore(signal, frame):
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions traced. Exiting.")
exit()
exit(1)

# header
if not folded:
Expand Down
4 changes: 2 additions & 2 deletions tools/opensnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@

if args.pid and args.exec:
print("ERROR: can only use -p or --exec. Exiting.")
exit()
exit(1)

if args.exec is not None and len(args.exec) == 0:
print("ERROR: --exec without command. Exiting.")
exit()
exit(1)

if args.duration:
args.duration = timedelta(seconds=int(args.duration))
Expand Down
12 changes: 6 additions & 6 deletions tools/readahead.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
ra_func = "page_cache_ra_order"
else:
print("Not found any kfunc for page cache readahead.")
exit()
exit(1)
bpf_text += bpf_text_kfunc_cache_readahead.replace("RA_FUNC", ra_func)
if BPF.get_kprobe_functions(b"__page_cache_alloc"):
bpf_text += bpf_text_kfunc_cache_alloc_ret_page
Expand All @@ -196,7 +196,7 @@
bpf_text += bpf_text_kfunc_cache_alloc_ret_folio_noprof
else:
print("ERROR: No cache alloc function found. Exiting.")
exit()
exit(1)
bpf_text += bpf_text_kfunc_cache_alloc_ret_folio_func_body
if BPF.get_kprobe_functions(b"folio_mark_accessed"):
ma_func_name = "folio_mark_accessed"
Expand All @@ -216,7 +216,7 @@
.replace("GET_PAGE_PTR_FROM_ARG0", get_page_ptr_code)
else:
print("Not found any kfunc for page cache mark accessed.")
exit()
exit(1)
bpf_text += bpf_text_kfunc_mark_accessed
b = BPF(text=bpf_text)
else:
Expand All @@ -229,7 +229,7 @@
ra_event = "page_cache_ra_order"
else:
print("Not found any kprobe for page cache readahead.")
exit()
exit(1)
if BPF.get_kprobe_functions(b"__page_cache_alloc"):
cache_func = "__page_cache_alloc"
bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'PT_REGS_RC(ctx)')
Expand All @@ -240,7 +240,7 @@
cache_func = "filemap_alloc_folio_noprof"
else:
print("ERROR: No cache alloc function found. Exiting.")
exit()
exit(1)
bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'folio_page((struct folio *)PT_REGS_RC(ctx), 0)')
if BPF.get_kprobe_functions(b"folio_mark_accessed"):
ma_event = "folio_mark_accessed"
Expand All @@ -250,7 +250,7 @@
bpf_text = bpf_text.replace('GET_ARG1_PAGE', '(struct page *)PT_REGS_PARM1(ctx)')
else:
print("Not found any kprobe for page cache mark accessed.")
exit()
exit(1)

b = BPF(text=bpf_text)
b.attach_kprobe(event=ra_event, fn_name="entry__do_page_cache_readahead")
Expand Down
2 changes: 1 addition & 1 deletion tools/stackcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def __init__(self):
if self.args.kernel_stacks_only and self.args.user_stacks_only:
print("ERROR: -K and -U are mutually exclusive. If you want " +
"both stacks, that is the default.")
exit()
exit(1)
if not self.args.kernel_stacks_only and not self.args.user_stacks_only:
self.kernel_stack = True
self.user_stack = True
Expand Down
2 changes: 1 addition & 1 deletion tools/swapin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
print("ERROR: swap_readpage() and swap_read_folio() kernel function"
" not found or traceable. "
"The kernel might be too old or the the function has been inlined.")
exit()
exit(1)

print("Counting swap ins. Ctrl-C to end.");

Expand Down
4 changes: 2 additions & 2 deletions tools/syscount.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def handle_errno(errstr):

if args.pid and args.exec:
print("ERROR: can only use -p or --exec. Exiting.")
exit()
exit(1)

if args.exec is not None and len(args.exec) == 0:
print("ERROR: --exec without command. Exiting.")
exit()
exit(1)

syscall_nr = -1
if args.syscall is not None:
Expand Down
4 changes: 2 additions & 2 deletions tools/tcpdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
if args.pid_netns != 0:
if args.netns_id != 0:
print("ERROR: --pid_netns and --netns-id not allowed together")
exit()
exit(1)
args.netns_id = os.stat('/proc/{}/ns/net'.format(args.pid_netns)).st_ino

if args.netns_id != 0:
Expand Down Expand Up @@ -386,7 +386,7 @@ def print_ipv6_event(cpu, data, size):
print("ERROR: tcp_drop() kernel function and tracepoint:skb:kfree_skb"
" not found or traceable. "
"The kernel might be too old or the the function has been inlined.")
exit()
exit(1)
stack_traces = b.get_table("stack_traces")

# header
Expand Down
2 changes: 1 addition & 1 deletion tools/wakeuptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def signal_ignore(signal, frame):
matched = b.num_open_kprobes()
if matched == 0:
print("0 functions traced. Exiting.")
exit()
exit(1)

# check whether hash table batch ops is supported
htab_batch_ops = True if BPF.kernel_struct_has_field(b'bpf_map_ops',
Expand Down
2 changes: 1 addition & 1 deletion tools/xfsdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
label = "usecs"
if args.interval and int(args.interval) == 0:
print("ERROR: interval 0. Exiting.")
exit()
exit(1)
debug = 0

# define BPF program
Expand Down
2 changes: 1 addition & 1 deletion tools/zfsdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
label = "usecs"
if args.interval and int(args.interval) == 0:
print("ERROR: interval 0. Exiting.")
exit()
exit(1)
debug = 0

# define BPF program
Expand Down
Loading