Skip to content

Commit a45c6a8

Browse files
authored
DLPX-96701 estat commands are failing with redefinition and forward declaration errors
PR URL: https://www.github.com/delphix/performance-diagnostics/pull/115
2 parents 5e7a27b + 6191c9f commit a45c6a8

8 files changed

Lines changed: 44 additions & 76 deletions

File tree

bpf/estat/nfs.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
* SPDX-License-Identifier: GPL-2.0-or-later
55
*/
66

7-
struct bpf_wq {
8-
__u64 __opaque[2];
9-
} __attribute__((aligned(8)));
10-
117
#include <uapi/linux/ptrace.h>
128
#include <linux/bpf_common.h>
139
#include <uapi/linux/bpf.h>

bpf/estat/zvol.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ typedef struct {
4040
zvol_state_t *zv;
4141
} zvol_data_t;
4242

43-
typedef struct zv_request {
44-
zvol_state_t *zv;
45-
struct bio *bio;
46-
} zv_request_t;
47-
48-
4943
BPF_HASH(zvol_base_data, u32, zvol_data_t);
5044

5145
static inline bool equal_to_pool(char *str)

bpf/standalone/arc_prefetch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ class ArcLatencyIndex(BCCMapIndex):
270270
"-I/usr/src/zfs-" + KVER + "/include/",
271271
"-I/usr/src/zfs-" + KVER + "/include/spl/",
272272
"-I/usr/src/zfs-" + KVER + "/include/linux",
273+
"-D__KERNEL__",
274+
"-D_KERNEL",
273275
"-DNCOUNT_INDEX=" + str(len(ArcCountIndex)),
274276
"-DNAVERAGE_INDEX=" + str(len(ArcLatencyIndex))] \
275277
+ ArcCountIndex.getCDefinitions() \

bpf/standalone/txg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ def read_zfs_dirty_max_data():
288288
""" Use the drgn program object to read the
289289
zfs_dirty_data_max kernel variable.
290290
"""
291-
global proj
292291
variable = prog['zfs_dirty_data_max']
293292
return int(variable.value_())
294293

@@ -349,7 +348,8 @@ def print_event(cpu, data, size):
349348
"-I/usr/src/zfs-" + KVER + "/include/",
350349
"-I/usr/src/zfs-" + KVER + "/include/spl",
351350
"-I/usr/src/zfs-" + KVER + "/include/",
352-
"-I/usr/src/zfs-" + KVER + "/include/linux"])
351+
"-I/usr/src/zfs-" + KVER + "/include/linux",
352+
"-D__KERNEL__", "-D_KERNEL"])
353353

354354
b.attach_kprobe(event="spa_sync", fn_name="spa_sync_entry")
355355
b.attach_kretprobe(event="spa_sync", fn_name="spa_sync_return")

bpf/standalone/zil.py

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
description='Collect zil latency statistics.',
4949
usage='estat zil [options]')
5050
parser.add_argument('-c', '--coll', type=int, action='store',
51-
dest='collection_sec',
51+
dest='collection_sec', default=60,
5252
help='The collection interval in seconds')
5353
parser.add_argument('-p', '--pool', type=str, action='store',
5454
dest='pool',
@@ -286,18 +286,6 @@
286286
return 0;
287287
}
288288
289-
int zil_commit_waiter_skip_entry(struct pt_regs *cts)
290-
{
291-
u32 tid = bpf_get_current_pid_tgid();
292-
zil_tid_info_t *info = zil_info_map.lookup(&tid);
293-
if (info == NULL) {
294-
return 0;
295-
}
296-
297-
count_call("waiter skip");
298-
return 0;
299-
}
300-
301289
int zil_commit_writer_stall_entry(struct pt_regs *cts)
302290
{
303291
u32 tid = bpf_get_current_pid_tgid();
@@ -319,7 +307,8 @@
319307
"-include",
320308
"/usr/src/zfs-" + KVER + "/include/spl/sys/types.h",
321309
"-I/usr/src/zfs-" + KVER + "/include/",
322-
"-I/usr/src/zfs-" + KVER + "/include/spl"])
310+
"-I/usr/src/zfs-" + KVER + "/include/spl",
311+
"-D__KERNEL__", "-D_KERNEL"])
323312

324313
b.attach_kprobe(event="zfs_write", fn_name="zfs_write_entry")
325314
b.attach_kretprobe(event="zfs_write", fn_name="zfs_write_return")
@@ -337,8 +326,6 @@
337326
fn_name="zil_commit_waiter_return")
338327
b.attach_kretprobe(event="zio_alloc_zil",
339328
fn_name="zio_alloc_zil_return")
340-
b.attach_kprobe(event="zil_commit_waiter_skip",
341-
fn_name="zil_commit_waiter_skip_entry")
342329
b.attach_kprobe(event="zil_commit_writer_stall",
343330
fn_name="zil_commit_writer_stall_entry")
344331

@@ -354,25 +341,13 @@
354341
BCCHelper.COUNT_AGGREGATION, "count")
355342
call_count_helper.add_key_type("name")
356343

357-
if (not args.collection_sec):
358-
print(" Tracing enabled... Hit Ctrl-C to end.")
359-
360-
# Collect data for a collection interval if specified
361-
if (args.collection_sec):
362-
sleep(args.collection_sec)
363-
try:
364-
print("%-16s\n" % strftime("%D - %H:%M:%S %Z"))
365-
latency_helper.printall()
366-
call_count_helper.printall()
367-
exit(0)
368-
except Exception as e:
369-
print(str(e))
370-
exit(0)
371-
372-
# Collect data until keyborad interrupt with output for each second
344+
#
345+
# Collect data until keyboard interrupt
346+
#
347+
print(" Tracing enabled... Hit Ctrl-C to end.")
373348
while True:
374349
try:
375-
sleep(60)
350+
sleep(args.collection_sec)
376351
except KeyboardInterrupt:
377352
print("%-16s\n" % strftime("%D - %H:%M:%S %Z"))
378353
latency_helper.printall()

bpf/stbtrace/iscsi.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ bpf_text += """
2727
#include <linux/bpf_common.h>
2828
#include <uapi/linux/bpf.h>
2929

30+
struct iscsi_conn;
3031
#include "target/iscsi/iscsi_target_core.h"
3132

3233

bpf/stbtrace/nfs.st

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ from bcchelper import BCCHelper # noqa: E402
2424
bpf_text = '#include "' + base_dir + 'lib/bcc_helper.h' + '"\n'
2525
bpf_text += """
2626

27-
struct bpf_wq {
28-
__u64 __opaque[2];
29-
} __attribute__((aligned(8)));
30-
3127
#include <uapi/linux/ptrace.h>
3228
#include <linux/bpf_common.h>
3329
#include <uapi/linux/bpf.h>
@@ -41,42 +37,42 @@ struct bpf_wq {
4137
#define bool int
4238

4339
typedef struct {
44-
u32 cl_boot;
45-
u32 cl_id;
40+
u32 cl_boot;
41+
u32 cl_id;
4642
} clientid_t;
4743

4844
typedef struct {
49-
clientid_t so_clid;
50-
u32 so_id;
45+
clientid_t so_clid;
46+
u32 so_id;
5147
} stateid_opaque_t;
5248

5349
typedef struct {
54-
u32 si_generation;
55-
stateid_opaque_t si_opaque;
50+
u32 si_generation;
51+
stateid_opaque_t si_opaque;
5652
} stateid_t;
5753

5854
struct nfsd4_read {
59-
stateid_t rd_stateid; /* request */
60-
u64 rd_offset; /* request */
61-
u32 rd_length; /* request */
62-
int rd_vlen;
63-
struct nfsd_file *rd_nf;
64-
65-
struct svc_rqst *rd_rqstp; /* response */
66-
struct svc_fh *rd_fhp; /* response */
67-
u32 rd_eof; /* response */
55+
stateid_t rd_stateid; /* request */
56+
u64 rd_offset; /* request */
57+
u32 rd_length; /* request */
58+
int rd_vlen;
59+
struct nfsd_file *rd_nf;
60+
61+
struct svc_rqst *rd_rqstp; /* response */
62+
struct svc_fh *rd_fhp; /* response */
63+
u32 rd_eof; /* response */
6864
};
6965

7066
struct nfsd4_write {
71-
stateid_t wr_stateid; /* request */
72-
u64 wr_offset; /* request */
73-
u32 wr_stable_how; /* request */
74-
u32 wr_buflen; /* request */
75-
struct xdr_buf wr_payload; /* request */
76-
77-
u32 wr_bytes_written; /* response */
78-
u32 wr_how_written; /* response */
79-
nfs4_verifier wr_verifier; /* response */
67+
stateid_t wr_stateid; /* request */
68+
u64 wr_offset; /* request */
69+
u32 wr_stable_how; /* request */
70+
u32 wr_buflen; /* request */
71+
struct xdr_buf wr_payload; /* request */
72+
73+
u32 wr_bytes_written; /* response */
74+
u32 wr_how_written; /* response */
75+
nfs4_verifier wr_verifier; /* response */
8076
};
8177

8278
// Definitions for this script

cmd/estat.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ def die(*args, **kwargs):
110110
estat zil [POOL]
111111
Provides a breakdown of time spent doing ZIL-related activities, in
112112
particular the time spent allocating a block and time spent waiting for
113-
the write I/O to complete. If POOL is not specified, defaults to tracing
114-
the pool 'domain0'.
113+
the write I/O to complete.
114+
-h show txg help message and exit
115+
-c INTERVAL set the collection interval in seconds
116+
-p POOL set the pool to monitor (default: domain0)
115117
"""
116118

117119

@@ -406,7 +408,9 @@ class Args:
406408
"-include",
407409
"/usr/src/zfs-" + KVER + "/include/spl/sys/types.h",
408410
"-I/usr/src/zfs-" + KVER + "/include/",
409-
"-I/usr/src/zfs-" + KVER + "/include/spl"]
411+
"-I/usr/src/zfs-" + KVER + "/include/spl",
412+
"-D__KERNEL__",
413+
"-D_KERNEL"]
410414
if script_arg:
411415
cflags.append("-DOPTARG=\"" + script_arg + "\"")
412416

0 commit comments

Comments
 (0)