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

libbpf-tools: improve fentry_exists check #3917

Merged
merged 1 commit into from Mar 28, 2022

Conversation

cobrien7
Copy link
Contributor

On architectures that lack support for fentry programs, tools should
fall back to using kprobes even if the kernel version is new enough to
include BPF_TRACE_FENTRY, but fentry_exists() cannot currently detect
this case.

Add an additional check verifying that attaching a BPF_TRACE_FENTRY
program can actually succeed.

Signed-off-by: Connor O'Brien connoro@google.com

@cobrien7
Copy link
Contributor Author

Are these failed checks a regression caused by this change? It looks like the failing tests involve the python tools, so I'm not sure I see how this would affect them.

@davemarchevsky davemarchevsky self-assigned this Mar 23, 2022
@davemarchevsky
Copy link
Collaborator

Are these failed checks a regression caused by this change? It looks like the failing tests involve the python tools, so I'm not sure I see how this would affect them.

Agreed, test failures look unrelated. Will look into them separately.

libbpf-tools/trace_helpers.c Outdated Show resolved Hide resolved
@@ -1042,7 +1065,7 @@ bool fentry_exists(const char *name, const char *mod)
err_out:
btf__free(btf);
btf__free(base);
return id > 0;
return id > 0 ? fentry_can_attach(id) : false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit will also close #3781 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should help, but I don't think all of the tools listed there use fentry_exists to fall back to kprobes

@davemarchevsky
Copy link
Collaborator

Looks like these are the tools which are affected by this change:

cachestat.c
fsdist.c
fsslower.c
klockstat.c
solisten.c
tcprtt.c
tcpsynbl.c
vfsstat.c

Just listing for posterity

libbpf-tools/trace_helpers.c Outdated Show resolved Hide resolved
libbpf-tools/trace_helpers.c Outdated Show resolved Hide resolved
On architectures that lack support for fentry programs, tools should
fall back to using kprobes even if the kernel version is new enough to
include BPF_TRACE_FENTRY, but fentry_exists() cannot currently detect
this case.

Instead of searching for BPF_TRACE_FENTRY, verify that attaching a
BPF_TRACE_FENTRY program can actually succeed. Rename fentry_exists to
fentry_can_attach to reflect this change.

Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I5ad0341cb060c7a4a2ee17245337170963dfefad
Copy link
Collaborator

@davemarchevsky davemarchevsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will merge after test run

@davemarchevsky davemarchevsky merged commit c65446b into iovisor:master Mar 28, 2022
@cobrien7 cobrien7 deleted the fix-fentry-check branch March 28, 2022 20:30
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