Skip to content

Commit 517b75e

Browse files
olsajiriAlexei Starovoitov
authored andcommitted
bpf: Add dispatchers to kallsyms
Adding dispatchers to kallsyms. It's displayed as bpf_dispatcher_<NAME> where NAME is the name of dispatcher. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200312195610.346362-12-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent a108f7d commit 517b75e

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎include/linux/bpf.h‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ struct bpf_dispatcher {
531531
int num_progs;
532532
void *image;
533533
u32 image_off;
534+
struct bpf_ksym ksym;
534535
};
535536

536537
static __always_inline unsigned int bpf_dispatcher_nop_func(
@@ -546,13 +547,17 @@ struct bpf_trampoline *bpf_trampoline_lookup(u64 key);
546547
int bpf_trampoline_link_prog(struct bpf_prog *prog);
547548
int bpf_trampoline_unlink_prog(struct bpf_prog *prog);
548549
void bpf_trampoline_put(struct bpf_trampoline *tr);
549-
#define BPF_DISPATCHER_INIT(name) { \
550-
.mutex = __MUTEX_INITIALIZER(name.mutex), \
551-
.func = &name##_func, \
552-
.progs = {}, \
553-
.num_progs = 0, \
554-
.image = NULL, \
555-
.image_off = 0 \
550+
#define BPF_DISPATCHER_INIT(_name) { \
551+
.mutex = __MUTEX_INITIALIZER(_name.mutex), \
552+
.func = &_name##_func, \
553+
.progs = {}, \
554+
.num_progs = 0, \
555+
.image = NULL, \
556+
.image_off = 0, \
557+
.ksym = { \
558+
.name = #_name, \
559+
.lnode = LIST_HEAD_INIT(_name.ksym.lnode), \
560+
}, \
556561
}
557562

558563
#define DEFINE_BPF_DISPATCHER(name) \

‎kernel/bpf/dispatcher.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void bpf_dispatcher_change_prog(struct bpf_dispatcher *d, struct bpf_prog *from,
143143
d->image = bpf_image_alloc();
144144
if (!d->image)
145145
goto out;
146+
bpf_image_ksym_add(d->image, &d->ksym);
146147
}
147148

148149
prev_num_progs = d->num_progs;

0 commit comments

Comments
 (0)