Skip to content

Commit

Permalink
Modify tools/ext4dist.py for 4.10+ (iovisor#1855)
Browse files Browse the repository at this point in the history
based on kernel version, different kernel functions are kprobed.
  • Loading branch information
kernel-z authored and yonghong-song committed Jun 27, 2018
1 parent 293938d commit c325d6d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/ext4dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,16 @@
b = BPF(text=bpf_text)

# Common file functions. See earlier comment about generic_file_read_iter().
b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
# Comment by Joe Yin
# From Linux 4.10, the function .read_iter at the ext4_file_operations has
# changed to ext4_file_read_iter.
# So, I add get_kprobe_functions('ext4_file_read_iter'),it will first to attach ext4_file_read_iter,
# if fails and will attach the generic_file_read_iter which used to pre-4.10.

if BPF.get_kprobe_functions('ext4_file_read_iter'):
b.attach_kprobe(event="ext4_file_read_iter", fn_name="trace_entry")
else:
b.attach_kprobe(event="generic_file_read_iter", fn_name="trace_read_entry")
b.attach_kprobe(event="ext4_file_write_iter", fn_name="trace_entry")
b.attach_kprobe(event="ext4_file_open", fn_name="trace_entry")
b.attach_kprobe(event="ext4_sync_file", fn_name="trace_entry")
Expand Down

0 comments on commit c325d6d

Please sign in to comment.