Bpf/tracing multi ci#11005
Draft
olsajiri wants to merge 17 commits intokernel-patches:bpf-next_basefrom
Draft
Conversation
2294d0a to
254af9f
Compare
4483170 to
f0c9e60
Compare
254af9f to
25c770c
Compare
f0c9e60 to
04b0321
Compare
a4a9811 to
2650068
Compare
04b0321 to
cb52425
Compare
Adding external ftrace_hash_count function that replaces hash_count function, so we can get hash count outside of ftrace object. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
d00fa97 to
e1dd74a
Compare
Removing the mutex_is_locked in bpf_trampoline_put, because we removed the mutex from bpf_trampoline. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
In following changes we will need to change ftrace direct attachment logic. In order to do that adding struct bpf_trampoline_ops object that defines 3 callbacks that follow ftrace attachment functions: register_fentry unregister_fentry modify_fentry The new struct bpf_trampoline_ops object is passed as an argument to __bpf_trampoline_link_prog function. At the moment the default trampoline_ops is set to the current ftrace direct attachment functions, so there's no change for current code. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Add struct bpf_struct_ops_tramp_link for struct_ops link, to follow the code of all the other users of bpf_tramp_link object. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding struct bpf_tramp_node to decouple the link out of the trampoline
attachment info.
At the moment the object for attaching bpf program to the trampoline is
'struct bpf_tramp_link':
struct bpf_tramp_link {
struct bpf_link link;
struct hlist_node tramp_hlist;
u64 cookie;
}
The link holds the bpf_prog pointer and forces one link - one program
binding logic. In following changes we want to attach program to multiple
trampolines but have just one bpf_link object.
Splitting struct bpf_tramp_link into:
struct bpf_tramp_link {
struct bpf_link link;
struct bpf_tramp_node node;
};
struct bpf_tramp_node {
struct bpf_link *link;
struct hlist_node tramp_hlist;
u64 cookie;
};
where 'struct bpf_tramp_link' defines standard single trampoline link,
and 'struct bpf_tramp_node' is the attachment trampoline object. This
will allow us to define link for multiple trampolines, like:
struct bpf_tracing_multi_link {
struct bpf_link link;
...
int nodes_cnt;
struct bpf_tracing_multi_node nodes[] __counted_by(nodes_cnt);
};
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding new attach type to identify multi tracing attachment: BPF_TRACE_FENTRY_MULTI BPF_TRACE_FEXIT_MULTI Programs with such attach type will use specific link attachment interface coming in following changes. This was suggested by Andrii some (long) time ago and turned out to be easier than having special program flag for that. Bpf programs with such types have 'bpf_multi_func' function set as their attach_btf_id. Suggested-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
dd9ff24 to
8d3fa89
Compare
Adding bpf_trampoline_multi_attach/detach functions that allows to attach/detach multi tracing trampoline. The attachment is defined with bpf_program and array of BTF ids of functions to attach the bpf program to. The attachment will allocate or use currently existing trampoline for function to attach and link it with the bpf program. The attach works as follows: - we get all the needed trampolines - lock them and add the bpf program to each (__bpf_trampoline_link_prog) - the trampoline_multi_ops passed in __bpf_trampoline_link_prog gather needed ftrace_hash ip->trampoline data - we call update_ftrace_direct_add/mod to update needed locations - we unlock all the trampolines The detach works as follows: - we lock all the needed trampolines - remove the program from each (__bpf_trampoline_unlink_prog) - the trampoline_multi_ops passed in __bpf_trampoline_link_prog gather needed ftrace_hash ip->trampoline data - we call update_ftrace_direct_del/mod to update needed locations - we unlock and put all the trampolines Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding new link to allow to attach program to multiple function
BTF IDs. The link is represented by struct bpf_tracing_multi_link.
To configure the link, new fields are added to bpf_attr::link_create
to pass array of BTF IDs;
struct {
__aligned_u64 btf_ids; /* addresses to attach */
__u32 btf_ids_cnt; /* addresses count */
} tracing_multi;
Each BTF ID represents function (BTF_KIND_FUNC) that the link will
attach bpf program to.
We use previously added bpf_trampoline_multi_attach/detach functions
to attach/detach the link.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding new interface function to attach programs with tracing
multi link:
bpf_program__attach_tracing_multi(const struct bpf_program *prog,
const char *pattern,
const struct bpf_tracing_multi_opts *opts);
The program is attach to functions specified by pattern or by
btf IDs specified in bpf_tracing_multi_opts object.
Adding support for new sections to attach programs with above
functions:
fentry.multi/pattern
fexit.multi/pattern
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
8d3fa89 to
6ab54fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.