Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify trace function from generic_file_read_iter() to ext4_file_read_iter() #1818

Merged
merged 3 commits into from
Jun 14, 2018
Merged

Conversation

kernel-z
Copy link
Contributor

The new Linux version (since form 4.10) uses ext4_file_read_iter(), And if the 'CONFIG_FS_DAX'
is not set ,then ext4_file_read_iter() will call generic_file_read_iter(), else it will call
ext4_dax_read_iter(), and trace generic_file_read_iter() will fail.

@pchaigno
Copy link
Contributor

Instead of a new command line flag, couldn't we try attaching to ext4_file_read_iter, and if it fails, fall-back to the old behavior? Or even, simply check that ext4_file_read_iter exists instead of trying to attach...

@kernel-z
Copy link
Contributor Author

kernel-z commented Jun 13, 2018

There are too many scripts, and will be more.
I think one script for one function is better.
If two scripts for one function, when the kernel evolving ,it may be need another one. At last it will be a lots of scripts for the same function.

@yonghong-song
Copy link
Collaborator

agree with @pchaigno A new option is unnecessary. bcc tools have numerous example for such detecting-and-attach. For example, in tcplife.py, we have

if (BPF.tracepoint_exists("sock", "inet_sock_set_state")):
    bpf_text += bpf_text_tracepoint
else:
    bpf_text += bpf_text_kprobe

In zfsdist.py, we have

if BPF.get_kprobe_functions(b'zpl_iter'):
    b.attach_kprobe(event="zpl_iter_read", fn_name="trace_entry")
    b.attach_kprobe(event="zpl_iter_write", fn_name="trace_entry")
elif BPF.get_kprobe_functions(b'zpl_aio'):
    b.attach_kprobe(event="zpl_aio_read", fn_name="trace_entry")
    b.attach_kprobe(event="zpl_aio_write", fn_name="trace_entry")
else:
    b.attach_kprobe(event="zpl_read", fn_name="trace_entry")
    b.attach_kprobe(event="zpl_write", fn_name="trace_entry")
b.attach_kprobe(event="zpl_open", fn_name="trace_entry")
b.attach_kprobe(event="zpl_fsync", fn_name="trace_entry")
if BPF.get_kprobe_functions(b'zpl_iter'):
    b.attach_kretprobe(event="zpl_iter_read", fn_name="trace_read_return")
    b.attach_kretprobe(event="zpl_iter_write", fn_name="trace_write_return")
elif BPF.get_kprobe_functions(b'zpl_aio'):
    b.attach_kretprobe(event="zpl_aio_read", fn_name="trace_read_return")
    b.attach_kretprobe(event="zpl_aio_write", fn_name="trace_write_return")
else:
    b.attach_kretprobe(event="zpl_read", fn_name="trace_read_return")
    b.attach_kretprobe(event="zpl_write", fn_name="trace_write_return")
b.attach_kretprobe(event="zpl_open", fn_name="trace_open_return")

Similar mechanism can be applied here.

@yonghong-song
Copy link
Collaborator

[buildbot, ok to test]

@kernel-z
Copy link
Contributor Author

Thank you ,@yonghong-song,@pchaigno, I have changed the code as zfsdist.py type.

@yonghong-song
Copy link
Collaborator

LGTM. Thanks!

@yonghong-song yonghong-song merged commit e07f2ed into iovisor:master Jun 14, 2018
banh-gao pushed a commit to banh-gao/bcc that referenced this pull request Jun 21, 2018
…_iter() (iovisor#1818)

* modify ext4slower.py for 4.10+ version

* modify ext4slower.py for 4.10+ version

* iovisor#1818
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
…_iter() (iovisor#1818)

* modify ext4slower.py for 4.10+ version

* modify ext4slower.py for 4.10+ version

* iovisor#1818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants