Skip to content

Commit 9691c56

Browse files
xixiliguoekyooo
authored andcommitted
Add support for fuse to fsdist and fsslower tools
1 parent fb8910a commit 9691c56

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

libbpf-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
/fsdist
2929
/fsslower
3030
/funclatency
31+
/fusedist
32+
/fuseslower
3133
/futexctn
3234
/gethostlatency
3335
/hardirqs

libbpf-tools/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ APPS = \
100100
# export variables that are used in Makefile.btfgen as well.
101101
export OUTPUT BPFTOOL ARCH BTFHUB_ARCHIVE APPS
102102

103-
FSDIST_ALIASES = btrfsdist ext4dist nfsdist xfsdist f2fsdist bcachefsdist zfsdist
104-
FSSLOWER_ALIASES = btrfsslower ext4slower nfsslower xfsslower f2fsslower bcachefsslower zfsslower
103+
FSDIST_ALIASES = btrfsdist ext4dist fusedist nfsdist xfsdist f2fsdist bcachefsdist zfsdist
104+
FSSLOWER_ALIASES = btrfsslower ext4slower fuseslower nfsslower xfsslower f2fsslower bcachefsslower zfsslower
105105
SIGSNOOP_ALIAS = killsnoop
106106
APP_ALIASES = $(FSDIST_ALIASES) $(FSSLOWER_ALIASES) ${SIGSNOOP_ALIAS}
107107

libbpf-tools/fsdist.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum fs_type {
3434
NONE,
3535
BTRFS,
3636
EXT4,
37+
FUSE,
3738
NFS,
3839
XFS,
3940
F2FS,
@@ -59,6 +60,13 @@ static struct fs_config {
5960
[F_FSYNC] = "ext4_sync_file",
6061
[F_GETATTR] = "ext4_file_getattr",
6162
}},
63+
[FUSE] = { "fuse", {
64+
[F_READ] = "fuse_file_read_iter",
65+
[F_WRITE] = "fuse_file_write_iter",
66+
[F_OPEN] = "fuse_open",
67+
[F_FSYNC] = "fuse_fsync",
68+
[F_GETATTR] = "fuse_getattr",
69+
}},
6270
[NFS] = { "nfs", {
6371
[F_READ] = "nfs_file_read",
6472
[F_WRITE] = "nfs_file_write",
@@ -134,7 +142,7 @@ static const struct argp_option opts[] = {
134142
{ "timestamp", 'T', NULL, 0, "Print timestamp", 0 },
135143
{ "milliseconds", 'm', NULL, 0, "Millisecond histogram", 0 },
136144
{ "pid", 'p', "PID", 0, "Process ID to trace", 0 },
137-
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
145+
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/fuse/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
138146
{ "verbose", 'v', NULL, 0, "Verbose debug output", 0 },
139147
{ NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help", 0 },
140148
{},
@@ -159,6 +167,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
159167
fs_type = BTRFS;
160168
} else if (!strcmp(arg, "ext4")) {
161169
fs_type = EXT4;
170+
} else if (!strcmp(arg, "fuse")) {
171+
fs_type = FUSE;
162172
} else if (!strcmp(arg, "nfs")) {
163173
fs_type = NFS;
164174
} else if (!strcmp(arg, "xfs")) {
@@ -219,6 +229,8 @@ static void alias_parse(char *prog)
219229
fs_type = BTRFS;
220230
} else if (strstr(name, "ext4dist")) {
221231
fs_type = EXT4;
232+
} else if (strstr(name, "fusedist")) {
233+
fs_type = FUSE;
222234
} else if (strstr(name, "nfsdist")) {
223235
fs_type = NFS;
224236
} else if (strstr(name, "xfsdist")) {

libbpf-tools/fsslower.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum fs_type {
3737
NONE,
3838
BTRFS,
3939
EXT4,
40+
FUSE,
4041
NFS,
4142
XFS,
4243
F2FS,
@@ -60,6 +61,12 @@ static struct fs_config {
6061
[F_OPEN] = "ext4_file_open",
6162
[F_FSYNC] = "ext4_sync_file",
6263
}},
64+
[FUSE] = { "fuse", {
65+
[F_READ] = "fuse_file_read_iter",
66+
[F_WRITE] = "fuse_file_write_iter",
67+
[F_OPEN] = "fuse_open",
68+
[F_FSYNC] = "fuse_fsync",
69+
}},
6370
[NFS] = { "nfs", {
6471
[F_READ] = "nfs_file_read",
6572
[F_WRITE] = "nfs_file_write",
@@ -127,7 +134,7 @@ static const struct argp_option opts[] = {
127134
{ "duration", 'd', "DURATION", 0, "Total duration of trace in seconds", 0 },
128135
{ "pid", 'p', "PID", 0, "Process ID to trace", 0 },
129136
{ "min", 'm', "MIN", 0, "Min latency to trace, in ms (default 10)", 0 },
130-
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
137+
{ "type", 't', "Filesystem", 0, "Which filesystem to trace, [btrfs/ext4/fuse/nfs/xfs/f2fs/bcachefs/zfs]", 0 },
131138
{ "verbose", 'v', NULL, 0, "Verbose debug output", 0 },
132139
{ NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help", 0 },
133140
{},
@@ -162,6 +169,8 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
162169
fs_type = BTRFS;
163170
} else if (!strcmp(arg, "ext4")) {
164171
fs_type = EXT4;
172+
} else if (!strcmp(arg, "fuse")) {
173+
fs_type = FUSE;
165174
} else if (!strcmp(arg, "nfs")) {
166175
fs_type = NFS;
167176
} else if (!strcmp(arg, "xfs")) {
@@ -202,6 +211,8 @@ static void alias_parse(char *prog)
202211
fs_type = BTRFS;
203212
} else if (strstr(name, "ext4slower")) {
204213
fs_type = EXT4;
214+
} else if (strstr(name, "fuseslower")) {
215+
fs_type = FUSE;
205216
} else if (strstr(name, "nfsslower")) {
206217
fs_type = NFS;
207218
} else if (strstr(name, "xfsslower")) {

0 commit comments

Comments
 (0)