-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Try use new API to create [k,u]probe with perf_event_open #1518
Conversation
[buildbot, ok to test] |
19eb0bf
to
96918c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good. Tested on a VM with the change (PeterD's queue git, perf/core branch).
src/cc/libbpf.c
Outdated
char buf[64]; | ||
|
||
snprintf(buf, sizeof(buf), PMU_TYPE_FILE, event_type); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to check the return value of snprintf
? Is it possible that it may fail in the future?
src/cc/libbpf.c
Outdated
int ret; | ||
char buf[64]; | ||
|
||
snprintf(buf, sizeof(buf), PMU_RETPROBE_FILE, event_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same here, check snprintf
return status?
src/cc/libbpf.c
Outdated
struct perf_reader *reader, int pid, | ||
int pfd) | ||
{ | ||
int efd, cpu = 0; | ||
ssize_t bytes; | ||
char buf[256]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to your patch, but for long file path, the buffer size may not be enough. Could you help change it to PATH_MAX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Teng just fixed it :)
goto error; | ||
} | ||
res = snprintf(event_alias, sizeof(event_alias), "%s_bcc_%d", ev_name, getpid()); | ||
if (res < 0 || res >= sizeof(event_alias)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what these solid green block is? Is this due to using TAB? In bcc non-kernel code, we use spaces instead of TABs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because we moved many lines into if (pfd < 0). Diff broke it into several sections, but it is just adding 2 more spaces for the whole chunk (
Please rebase on top of trunk as there is a conflict for ready-to-merge. |
The new [k,u]probe API allows creating [k,u]probe together with perf_event_open. This patch adds functions to use the new API. Note: these new functions are not used until next patch, so this patch doesn't change the behavior. The change is splitted into two patches for cleaner review. Signed-off-by: Song Liu <[email protected]>
New kernel API allows creating [k,u]probe with perf_event_open. This patch tries to use the new API. If the new API doesn't work, we fall back to old API. bpf_detach_probe() looks up the event being removed. If the event is not found, we skip the clean up procedure. Signed-off-by: Song Liu <[email protected]>
96918c2
to
0e9ed20
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
New kernel API allows creating [k,u]probe with perf_event_open.
This patch tries to use the new API. If the new API doesn't work,
we fall back to old API.
The kernel part of this work is available for test at:
git:https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git perf/core
Thanks,
Song