diff --git a/bpf/estat/nfs.c b/bpf/estat/nfs.c index 618611b..cfdabea 100644 --- a/bpf/estat/nfs.c +++ b/bpf/estat/nfs.c @@ -4,10 +4,6 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -struct bpf_wq { - __u64 __opaque[2]; -} __attribute__((aligned(8))); - #include #include #include diff --git a/bpf/estat/zvol.c b/bpf/estat/zvol.c index 14ff2ab..8eeac81 100644 --- a/bpf/estat/zvol.c +++ b/bpf/estat/zvol.c @@ -40,12 +40,6 @@ typedef struct { zvol_state_t *zv; } zvol_data_t; -typedef struct zv_request { - zvol_state_t *zv; - struct bio *bio; -} zv_request_t; - - BPF_HASH(zvol_base_data, u32, zvol_data_t); static inline bool equal_to_pool(char *str) diff --git a/bpf/standalone/arc_prefetch.py b/bpf/standalone/arc_prefetch.py index c7ef659..6e5ba78 100755 --- a/bpf/standalone/arc_prefetch.py +++ b/bpf/standalone/arc_prefetch.py @@ -270,6 +270,8 @@ class ArcLatencyIndex(BCCMapIndex): "-I/usr/src/zfs-" + KVER + "/include/", "-I/usr/src/zfs-" + KVER + "/include/spl/", "-I/usr/src/zfs-" + KVER + "/include/linux", + "-D__KERNEL__", + "-D_KERNEL", "-DNCOUNT_INDEX=" + str(len(ArcCountIndex)), "-DNAVERAGE_INDEX=" + str(len(ArcLatencyIndex))] \ + ArcCountIndex.getCDefinitions() \ diff --git a/bpf/standalone/txg.py b/bpf/standalone/txg.py index 583ee91..012f380 100755 --- a/bpf/standalone/txg.py +++ b/bpf/standalone/txg.py @@ -288,7 +288,6 @@ def read_zfs_dirty_max_data(): """ Use the drgn program object to read the zfs_dirty_data_max kernel variable. """ - global proj variable = prog['zfs_dirty_data_max'] return int(variable.value_()) @@ -349,7 +348,8 @@ def print_event(cpu, data, size): "-I/usr/src/zfs-" + KVER + "/include/", "-I/usr/src/zfs-" + KVER + "/include/spl", "-I/usr/src/zfs-" + KVER + "/include/", - "-I/usr/src/zfs-" + KVER + "/include/linux"]) + "-I/usr/src/zfs-" + KVER + "/include/linux", + "-D__KERNEL__", "-D_KERNEL"]) b.attach_kprobe(event="spa_sync", fn_name="spa_sync_entry") b.attach_kretprobe(event="spa_sync", fn_name="spa_sync_return") diff --git a/bpf/standalone/zil.py b/bpf/standalone/zil.py index c02994e..d00ea90 100755 --- a/bpf/standalone/zil.py +++ b/bpf/standalone/zil.py @@ -48,7 +48,7 @@ description='Collect zil latency statistics.', usage='estat zil [options]') parser.add_argument('-c', '--coll', type=int, action='store', - dest='collection_sec', + dest='collection_sec', default=60, help='The collection interval in seconds') parser.add_argument('-p', '--pool', type=str, action='store', dest='pool', @@ -286,18 +286,6 @@ return 0; } -int zil_commit_waiter_skip_entry(struct pt_regs *cts) -{ - u32 tid = bpf_get_current_pid_tgid(); - zil_tid_info_t *info = zil_info_map.lookup(&tid); - if (info == NULL) { - return 0; - } - - count_call("waiter skip"); - return 0; -} - int zil_commit_writer_stall_entry(struct pt_regs *cts) { u32 tid = bpf_get_current_pid_tgid(); @@ -319,7 +307,8 @@ "-include", "/usr/src/zfs-" + KVER + "/include/spl/sys/types.h", "-I/usr/src/zfs-" + KVER + "/include/", - "-I/usr/src/zfs-" + KVER + "/include/spl"]) + "-I/usr/src/zfs-" + KVER + "/include/spl", + "-D__KERNEL__", "-D_KERNEL"]) b.attach_kprobe(event="zfs_write", fn_name="zfs_write_entry") b.attach_kretprobe(event="zfs_write", fn_name="zfs_write_return") @@ -337,8 +326,6 @@ fn_name="zil_commit_waiter_return") b.attach_kretprobe(event="zio_alloc_zil", fn_name="zio_alloc_zil_return") -b.attach_kprobe(event="zil_commit_waiter_skip", - fn_name="zil_commit_waiter_skip_entry") b.attach_kprobe(event="zil_commit_writer_stall", fn_name="zil_commit_writer_stall_entry") @@ -354,25 +341,13 @@ BCCHelper.COUNT_AGGREGATION, "count") call_count_helper.add_key_type("name") -if (not args.collection_sec): - print(" Tracing enabled... Hit Ctrl-C to end.") - -# Collect data for a collection interval if specified -if (args.collection_sec): - sleep(args.collection_sec) - try: - print("%-16s\n" % strftime("%D - %H:%M:%S %Z")) - latency_helper.printall() - call_count_helper.printall() - exit(0) - except Exception as e: - print(str(e)) - exit(0) - -# Collect data until keyborad interrupt with output for each second +# +# Collect data until keyboard interrupt +# +print(" Tracing enabled... Hit Ctrl-C to end.") while True: try: - sleep(60) + sleep(args.collection_sec) except KeyboardInterrupt: print("%-16s\n" % strftime("%D - %H:%M:%S %Z")) latency_helper.printall() diff --git a/bpf/stbtrace/iscsi.st b/bpf/stbtrace/iscsi.st index 0b2c1de..9567eb7 100755 --- a/bpf/stbtrace/iscsi.st +++ b/bpf/stbtrace/iscsi.st @@ -27,6 +27,7 @@ bpf_text += """ #include #include +struct iscsi_conn; #include "target/iscsi/iscsi_target_core.h" diff --git a/bpf/stbtrace/nfs.st b/bpf/stbtrace/nfs.st index e7c5f70..9d2df71 100755 --- a/bpf/stbtrace/nfs.st +++ b/bpf/stbtrace/nfs.st @@ -24,10 +24,6 @@ from bcchelper import BCCHelper # noqa: E402 bpf_text = '#include "' + base_dir + 'lib/bcc_helper.h' + '"\n' bpf_text += """ -struct bpf_wq { - __u64 __opaque[2]; -} __attribute__((aligned(8))); - #include #include #include @@ -41,42 +37,42 @@ struct bpf_wq { #define bool int typedef struct { - u32 cl_boot; - u32 cl_id; + u32 cl_boot; + u32 cl_id; } clientid_t; typedef struct { - clientid_t so_clid; - u32 so_id; + clientid_t so_clid; + u32 so_id; } stateid_opaque_t; typedef struct { - u32 si_generation; - stateid_opaque_t si_opaque; + u32 si_generation; + stateid_opaque_t si_opaque; } stateid_t; struct nfsd4_read { - stateid_t rd_stateid; /* request */ - u64 rd_offset; /* request */ - u32 rd_length; /* request */ - int rd_vlen; - struct nfsd_file *rd_nf; - - struct svc_rqst *rd_rqstp; /* response */ - struct svc_fh *rd_fhp; /* response */ - u32 rd_eof; /* response */ + stateid_t rd_stateid; /* request */ + u64 rd_offset; /* request */ + u32 rd_length; /* request */ + int rd_vlen; + struct nfsd_file *rd_nf; + + struct svc_rqst *rd_rqstp; /* response */ + struct svc_fh *rd_fhp; /* response */ + u32 rd_eof; /* response */ }; struct nfsd4_write { - stateid_t wr_stateid; /* request */ - u64 wr_offset; /* request */ - u32 wr_stable_how; /* request */ - u32 wr_buflen; /* request */ - struct xdr_buf wr_payload; /* request */ - - u32 wr_bytes_written; /* response */ - u32 wr_how_written; /* response */ - nfs4_verifier wr_verifier; /* response */ + stateid_t wr_stateid; /* request */ + u64 wr_offset; /* request */ + u32 wr_stable_how; /* request */ + u32 wr_buflen; /* request */ + struct xdr_buf wr_payload; /* request */ + + u32 wr_bytes_written; /* response */ + u32 wr_how_written; /* response */ + nfs4_verifier wr_verifier; /* response */ }; // Definitions for this script diff --git a/cmd/estat.py b/cmd/estat.py index 18b8c9e..97436be 100755 --- a/cmd/estat.py +++ b/cmd/estat.py @@ -110,8 +110,10 @@ def die(*args, **kwargs): estat zil [POOL] Provides a breakdown of time spent doing ZIL-related activities, in particular the time spent allocating a block and time spent waiting for - the write I/O to complete. If POOL is not specified, defaults to tracing - the pool 'domain0'. + the write I/O to complete. + -h show txg help message and exit + -c INTERVAL set the collection interval in seconds + -p POOL set the pool to monitor (default: domain0) """ @@ -406,7 +408,9 @@ class Args: "-include", "/usr/src/zfs-" + KVER + "/include/spl/sys/types.h", "-I/usr/src/zfs-" + KVER + "/include/", - "-I/usr/src/zfs-" + KVER + "/include/spl"] + "-I/usr/src/zfs-" + KVER + "/include/spl", + "-D__KERNEL__", + "-D_KERNEL"] if script_arg: cflags.append("-DOPTARG=\"" + script_arg + "\"")