From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:06
hi,
this patchset adds trampoline and dispatcher objects
to be visible in /proc/kallsyms. The last patch also
adds sorting for all bpf objects in /proc/kallsyms.
$ sudo cat /proc/kallsyms | tail -20
...
ffffffffa050f000 t bpf_prog_5a2b06eab81b8f51 [bpf]
ffffffffa0511000 t bpf_prog_6deef7357e7b4530 [bpf]
ffffffffa0542000 t bpf_trampoline_13832 [bpf]
ffffffffa0548000 t bpf_prog_96f1b5bf4e4cc6dc_mutex_lock [bpf]
ffffffffa0572000 t bpf_prog_d1c63e29ad82c4ab_bpf_prog1 [bpf]
ffffffffa0585000 t bpf_prog_e314084d332a5338__dissect [bpf]
ffffffffa0587000 t bpf_prog_59785a79eac7e5d2_mutex_unlock [bpf]
ffffffffa0589000 t bpf_prog_d0db6e0cac050163_mutex_lock [bpf]
ffffffffa058d000 t bpf_prog_d8f047721e4d8321_bpf_prog2 [bpf]
ffffffffa05df000 t bpf_trampoline_25637 [bpf]
ffffffffa05e3000 t bpf_prog_d8f047721e4d8321_bpf_prog2 [bpf]
ffffffffa05e5000 t bpf_prog_3b185187f1855c4c [bpf]
ffffffffa05e7000 t bpf_prog_d8f047721e4d8321_bpf_prog2 [bpf]
ffffffffa05eb000 t bpf_prog_93cebb259dd5c4b2_do_sys_open [bpf]
ffffffffa0677000 t bpf_dispatcher_xdp [bpf]
v4 changes:
- add trampoline and dispatcher to kallsyms once the it's allocated [Alexei]
- omit the symbols sorting for kallsyms [Alexei]
- small title change in one patch [Song]
- some function renames:
bpf_get_prog_name to bpf_prog_ksym_set_name
bpf_get_prog_addr_region to bpf_prog_ksym_set_addr
- added acks to changelogs
- I checked and there'll be conflict on perftool side with
upcoming changes from Adrian Hunter (text poke events),
so I think it's better if Arnaldo takes the perf changes
via perf tree and we will solve all conflicts there
v3 changes:
- use container_of directly in bpf_get_ksym_start [Daniel]
- add more changelog explanations for ksym addresses [Daniel]
v2 changes:
- omit extra condition in __bpf_ksym_add for sorting code (Andrii)
- rename bpf_kallsyms_tree_ops to bpf_ksym_tree (Andrii)
- expose only executable code in kallsyms (Andrii)
- use full trampoline key as its kallsyms id (Andrii)
- explained the BPF_TRAMP_REPLACE case (Andrii)
- small format changes in bpf_trampoline_link_prog/bpf_trampoline_unlink_prog (Andrii)
- propagate error value in bpf_dispatcher_update and update kallsym if it's successful (Andrii)
- get rid of __always_inline for bpf_ksym_tree callbacks (Andrii)
- added KSYMBOL notification for bpf_image add/removal
- added perf tools changes to properly display trampoline/dispatcher
For perf tool to properly display trampoline/dispatcher you need
also Arnaldo's perf/urgent branch changes. I merged everything
into following branch:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git bpf/kallsyms
thanks,
jirka
---
Björn Töpel (1):
bpf: Add bpf_trampoline_ name prefix for DECLARE_BPF_DISPATCHER
Jiri Olsa (14):
x86/mm: Rename is_kernel_text to __is_kernel_text
bpf: Add struct bpf_ksym
bpf: Add name to struct bpf_ksym
bpf: Move lnode list node to struct bpf_ksym
bpf: Add bpf_ksym_tree tree
bpf: Move bpf_tree add/del from bpf_prog_ksym_node_add/del
bpf: Separate kallsyms add/del functions
bpf: Add bpf_ksym_add/del functions
bpf: Rename bpf_tree to bpf_progs_tree
bpf: Add trampolines to kallsyms
bpf: Add dispatchers to kallsyms
perf tools: Synthesize bpf_trampoline/dispatcher ksymbol event
perf tools: Set ksymbol dso as loaded on arrival
perf annotate: Add base support for bpf_image
arch/x86/mm/init_32.c | 14 ++++++++----
include/linux/bpf.h | 55 ++++++++++++++++++++++++++++++--------------
include/linux/filter.h | 13 +++--------
kernel/bpf/core.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
kernel/bpf/dispatcher.c | 1 +
kernel/bpf/trampoline.c | 28 +++++++++++++++++++++++
kernel/events/core.c | 9 ++++----
net/core/filter.c | 5 ++--
tools/perf/util/annotate.c | 20 ++++++++++++++++
tools/perf/util/bpf-event.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/dso.c | 1 +
tools/perf/util/dso.h | 1 +
tools/perf/util/machine.c | 12 ++++++++++
tools/perf/util/symbol.c | 1 +
14 files changed, 325 insertions(+), 86 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:10
The kbuild test robot reported compile issue on x86 in one of
the following patches that adds <linux/kallsyms.h> include into
<linux/bpf.h>, which is picked up by init_32.c object.
The problem is that <linux/kallsyms.h> defines global function
is_kernel_text which colides with the static function of the
same name defined in init_32.c:
$ make ARCH=i386
...
>> arch/x86/mm/init_32.c:241:19: error: redefinition of 'is_kernel_text'
static inline int is_kernel_text(unsigned long addr)
^~~~~~~~~~~~~~
In file included from include/linux/bpf.h:21:0,
from include/linux/bpf-cgroup.h:5,
from include/linux/cgroup-defs.h:22,
from include/linux/cgroup.h:28,
from include/linux/hugetlb.h:9,
from arch/x86/mm/init_32.c:18:
include/linux/kallsyms.h:31:19: note: previous definition of 'is_kernel_text' was here
static inline int is_kernel_text(unsigned long addr)
Renaming the init_32.c is_kernel_text function to __is_kernel_text.
Acked-by: Song Liu <redacted>
Reported-by: kbuild test robot <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
arch/x86/mm/init_32.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:17
From: Björn Töpel <redacted>
Adding bpf_trampoline_ name prefix for DECLARE_BPF_DISPATCHER,
so all the dispatchers have the common name prefix.
And also a small '_' cleanup for bpf_dispatcher_nopfunc function
name.
Acked-by: Song Liu <redacted>
Signed-off-by: Björn Töpel <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 21 +++++++++++----------
include/linux/filter.h | 7 +++----
net/core/filter.c | 5 ++---
3 files changed, 16 insertions(+), 17 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:19
Adding 'struct bpf_ksym' object that will carry the
kallsym information for bpf symbol. Adding the start
and end address to begin with. It will be used by
bpf_prog, bpf_trampoline, bpf_dispatcher.
The symbol_start/symbol_end values were originally used
to sort bpf_prog objects. For the address displayed in
/proc/kallsyms we are using prog->bpf_func.
I'm using the bpf_func for program symbol start instead
of the symbol_start, because it makes no difference for
sorting bpf_prog objects and we can use it directly as
an address for display it in /proc/kallsyms.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 6 ++++++
kernel/bpf/core.c | 28 ++++++++++++----------------
2 files changed, 18 insertions(+), 16 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:23
Adding name to 'struct bpf_ksym' object to carry the name
of the symbol for bpf_prog, bpf_trampoline, bpf_dispatcher.
The current benefit is that name is now generated only when
the symbol is added to the list, so we don't need to generate
it every time it's accessed.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 2 ++
include/linux/filter.h | 6 ------
kernel/bpf/core.c | 9 ++++++---
kernel/events/core.c | 9 ++++-----
4 files changed, 12 insertions(+), 14 deletions(-)
@@ -681,7 +684,7 @@ const char *__bpf_address_lookup(unsigned long addr, unsigned long *size,unsignedlongsymbol_start=prog->aux->ksym.start;unsignedlongsymbol_end=prog->aux->ksym.end;-bpf_get_prog_name(prog,sym);+strncpy(sym,prog->aux->ksym.name,KSYM_NAME_LEN);ret=sym;if(size)
@@ -738,7 +741,7 @@ int bpf_get_kallsym(unsigned int symnum, unsigned long *value, char *type,if(it++!=symnum)continue;-bpf_get_prog_name(aux->prog,sym);+strncpy(sym,aux->ksym.name,KSYM_NAME_LEN);*value=(unsignedlong)aux->prog->bpf_func;*type=BPF_SYM_ELF_TYPE;
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:32
Adding lnode list node to 'struct bpf_ksym' object,
so the symbol itself can be chained and used in other
objects like bpf_trampoline and bpf_dispatcher.
Changing iterator to bpf_ksym in bpf_get_kallsym.
The ksym->start is holding the prog->bpf_func value,
so it's ok to use it in bpf_get_kallsym.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 2 +-
kernel/bpf/core.c | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 12 deletions(-)
@@ -729,7 +729,7 @@ const struct exception_table_entry *search_bpf_extables(unsigned long addr)intbpf_get_kallsym(unsignedintsymnum,unsignedlong*value,char*type,char*sym){-structbpf_prog_aux*aux;+structbpf_ksym*ksym;unsignedintit=0;intret=-ERANGE;
@@ -737,13 +737,13 @@ int bpf_get_kallsym(unsigned int symnum, unsigned long *value, char *type,returnret;rcu_read_lock();-list_for_each_entry_rcu(aux,&bpf_kallsyms,ksym_lnode){+list_for_each_entry_rcu(ksym,&bpf_kallsyms,lnode){if(it++!=symnum)continue;-strncpy(sym,aux->ksym.name,KSYM_NAME_LEN);+strncpy(sym,ksym->name,KSYM_NAME_LEN);-*value=(unsignedlong)aux->prog->bpf_func;+*value=ksym->start;*type=BPF_SYM_ELF_TYPE;ret=0;
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:35
The bpf_tree is used both for kallsyms iterations and searching
for exception tables of bpf programs, which is needed only for
bpf programs.
Adding bpf_ksym_tree that will hold symbols for all bpf_prog
bpf_trampoline and bpf_dispatcher objects and keeping bpf_tree
only for bpf_prog objects to keep it fast.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 1 +
kernel/bpf/core.c | 56 ++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 51 insertions(+), 6 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:36
Moving bpf_tree add/del from bpf_prog_ksym_node_add/del,
because it will be used (and renamed) in following patches
for bpf_ksym objects. The bpf_tree is specific for bpf_prog
objects.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
kernel/bpf/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:49
Moving bpf_prog_ksym_node_add/del to __bpf_ksym_add/del
and changing the argument to 'struct bpf_ksym' object.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
kernel/bpf/core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:32:49
Adding bpf_ksym_add/del functions as locked version
for __bpf_ksym_add/del. It will be used in following
patches for bpf_trampoline and bpf_dispatcher.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 3 +++
kernel/bpf/core.c | 14 ++++++++++++++
2 files changed, 17 insertions(+)
@@ -573,6 +573,9 @@ struct bpf_image {#define BPF_IMAGE_SIZE (PAGE_SIZE - sizeof(struct bpf_image))boolis_bpf_image_address(unsignedlongaddress);void*bpf_image_alloc(void);+/* Called only from code, so there's no need for stubs. */+voidbpf_ksym_add(structbpf_ksym*ksym);+voidbpf_ksym_del(structbpf_ksym*ksym);#elsestaticinlinestructbpf_trampoline*bpf_trampoline_lookup(u64key){
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:33:00
Renaming bpf_tree to bpf_progs_tree and bpf_tree_ops
to bpf_progs_tree_ops to better capture the usage of
the tree which is for the bpf_prog objects only.
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
kernel/bpf/core.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:33:03
Adding trampolines to kallsyms. It's displayed as
bpf_trampoline_<ID> [bpf]
where ID is the BTF id of the trampoline function.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/bpf.h | 3 +++
kernel/bpf/trampoline.c | 28 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
@@ -502,6 +502,7 @@ struct bpf_trampoline {/* Executable image of trampoline */void*image;u64selector;+structbpf_ksymksym;};#define BPF_DISPATCHER_MAX 48 /* Fits in 2048B */
@@ -573,6 +574,8 @@ struct bpf_image {#define BPF_IMAGE_SIZE (PAGE_SIZE - sizeof(struct bpf_image))boolis_bpf_image_address(unsignedlongaddress);void*bpf_image_alloc(void);+voidbpf_image_ksym_add(void*data,structbpf_ksym*ksym);+voidbpf_image_ksym_del(structbpf_ksym*ksym);/* Called only from code, so there's no need for stubs. */voidbpf_ksym_add(structbpf_ksym*ksym);voidbpf_ksym_del(structbpf_ksym*ksym);
@@ -5,6 +5,7 @@#include<linux/filter.h>#include<linux/ftrace.h>#include<linux/rbtree_latch.h>+#include<linux/perf_event.h>/* dummy _ops. The verifier will operate on target program's ops. */conststructbpf_verifier_opsbpf_extension_verifier_ops={
@@ -96,6 +97,30 @@ bool is_bpf_image_address(unsigned long addr)returnret;}+voidbpf_image_ksym_add(void*data,structbpf_ksym*ksym)+{+ksym->start=(unsignedlong)data;+ksym->end=ksym->start+BPF_IMAGE_SIZE;+bpf_ksym_add(ksym);+perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF,ksym->start,+BPF_IMAGE_SIZE,false,ksym->name);+}++voidbpf_image_ksym_del(structbpf_ksym*ksym)+{+bpf_ksym_del(ksym);+perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF,ksym->start,+BPF_IMAGE_SIZE,true,ksym->name);+}++staticvoidbpf_trampoline_ksym_add(structbpf_trampoline*tr)+{+structbpf_ksym*ksym=&tr->ksym;++snprintf(ksym->name,KSYM_NAME_LEN,"bpf_trampoline_%llu",tr->key);+bpf_image_ksym_add(tr->image,ksym);+}+structbpf_trampoline*bpf_trampoline_lookup(u64key){structbpf_trampoline*tr;
@@ -356,6 +383,7 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)gotoout;if(WARN_ON_ONCE(!hlist_empty(&tr->progs_hlist[BPF_TRAMP_FEXIT])))gotoout;+bpf_image_ksym_del(&tr->ksym);image=container_of(tr->image,structbpf_image,data);latch_tree_erase(&image->tnode,&image_tree,&image_tree_ops);/* wait for tasks to get out of trampoline before freeing it */
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:33:07
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>
---
include/linux/bpf.h | 19 ++++++++++++-------
kernel/bpf/dispatcher.c | 1 +
2 files changed, 13 insertions(+), 7 deletions(-)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:33:15
Synthesize bpf images (trampolines/dispatchers) on start,
as ksymbol events from /proc/kallsyms. Having this perf
can recognize samples from those images and perf report
and top shows them correctly.
The rest of the ksymbol handling is already in place from
for the bpf programs monitoring, so only the initial state
was needed.
perf report output:
# Overhead Command Shared Object Symbol
12.37% test_progs [kernel.vmlinux] [k] entry_SYSCALL_64
11.80% test_progs [kernel.vmlinux] [k] syscall_return_via_sysret
9.63% test_progs bpf_prog_bcf7977d3b93787c_prog2 [k] bpf_prog_bcf7977d3b93787c_prog2
6.90% test_progs bpf_trampoline_24456 [k] bpf_trampoline_24456
6.36% test_progs [kernel.vmlinux] [k] memcpy_erms
Acked-by: Arnaldo Carvalho de Melo <redacted>
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/bpf-event.c | 98 +++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
@@ -290,11 +293,87 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session,returnerr?-1:0;}+structkallsyms_parse{+unionperf_event*event;+perf_event__handler_tprocess;+structmachine*machine;+structperf_tool*tool;+};++staticint+process_bpf_image(char*name,u64addr,structkallsyms_parse*data)+{+structmachine*machine=data->machine;+unionperf_event*event=data->event;+structperf_record_ksymbol*ksymbol;+u32size;++ksymbol=&event->ksymbol;++/*+*Thebpfimage(trampoline/dispatcher)sizeisalignedto+*page,whileitstartslittlebitafterthepageboundary.+*/+size=page_size-(addr-PERF_ALIGN(addr,page_size));++*ksymbol=(structperf_record_ksymbol){+.header={+.type=PERF_RECORD_KSYMBOL,+.size=offsetof(structperf_record_ksymbol,name),+},+.addr=addr,+.len=size,+.ksym_type=PERF_RECORD_KSYMBOL_TYPE_BPF,+.flags=0,+};++strncpy(ksymbol->name,name,KSYM_NAME_LEN);+ksymbol->header.size+=PERF_ALIGN(strlen(name)+1,sizeof(u64));+memset((void*)event+event->header.size,0,machine->id_hdr_size);+event->header.size+=machine->id_hdr_size;++returnperf_tool__process_synth_event(data->tool,event,machine,+data->process);+}++staticint+kallsyms_process_symbol(void*data,constchar*_name,+chartype__maybe_unused,u64start)+{+char*module,*name;+unsignedlongid;+interr=0;++module=strchr(_name,'\t');+if(!module)+return0;++/* We are going after [bpf] module ... */+if(strcmp(module+1,"[bpf]"))+return0;++name=memdup(_name,(module-_name)+1);+if(!name)+return-ENOMEM;++name[module-_name]=0;++/* .. and only for trampolines and dispatchers */+if((sscanf(name,"bpf_trampoline_%lu",&id)==1)||+(sscanf(name,"bpf_dispatcher_%lu",&id)==1))+err=process_bpf_image(name,start,data);++free(name);+returnerr;+}+intperf_event__synthesize_bpf_events(structperf_session*session,perf_event__handler_tprocess,structmachine*machine,structrecord_opts*opts){+constchar*kallsyms_filename="/proc/kallsyms";+structkallsyms_parsearg;unionperf_event*event;__u32id=0;interr;
@@ -303,6 +382,8 @@ int perf_event__synthesize_bpf_events(struct perf_session *session,event=malloc(sizeof(event->bpf)+KSYM_NAME_LEN+machine->id_hdr_size);if(!event)return-1;++/* Synthesize all the bpf programs in system. */while(true){err=bpf_prog_get_next_id(id,&id);if(err){
@@ -335,6 +416,23 @@ int perf_event__synthesize_bpf_events(struct perf_session *session,break;}}++/* Synthesize all the bpf images - trampolines/dispatchers. */+if(symbol_conf.kallsyms_name!=NULL)+kallsyms_filename=symbol_conf.kallsyms_name;++arg=(structkallsyms_parse){+.event=event,+.process=process,+.machine=machine,+.tool=session->tool,+};++if(kallsyms__parse(kallsyms_filename,&arg,kallsyms_process_symbol)){+pr_err("%s: failed to synthesize bpf images: %s\n",+__func__,strerror(errno));+}+free(event);returnerr;}
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:33:19
There's no special load action for ksymbol data on
map__load/dso__load action, where the kernel is getting
loaded. It only gets confused with kernel kallsyms/vmlinux
load for bpf object, which fails and could mess up with
the map.
Disabling any further load of the map for ksymbol related dso/map.
Acked-by: Arnaldo Carvalho de Melo <redacted>
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/machine.c | 1 +
1 file changed, 1 insertion(+)
From: Jiri Olsa <jolsa@kernel.org> Date: 2020-03-02 14:33:26
Adding the DSO_BINARY_TYPE__BPF_IMAGE dso binary type
to recognize bpf images that carry trampoline or dispatcher.
Upcoming patches will add support to read the image data,
store it within the BPF feature in perf.data and display
it for annotation purposes.
Currently we only display following message:
# ./perf annotate bpf_trampoline_24456 --stdio
Percent | Source code & Disassembly of . for cycles (504 ...
--------------------------------------------------------------- ...
: to be implemented
Acked-by: Arnaldo Carvalho de Melo <redacted>
Acked-by: Song Liu <redacted>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/annotate.c | 20 ++++++++++++++++++++
tools/perf/util/dso.c | 1 +
tools/perf/util/dso.h | 1 +
tools/perf/util/machine.c | 11 +++++++++++
tools/perf/util/symbol.c | 1 +
5 files changed, 34 insertions(+)
On Mon, Mar 02, 2020 at 03:31:45PM +0100, Jiri Olsa wrote:
The bpf_tree is used both for kallsyms iterations and searching
for exception tables of bpf programs, which is needed only for
bpf programs.
Adding bpf_ksym_tree that will hold symbols for all bpf_prog
bpf_trampoline and bpf_dispatcher objects and keeping bpf_tree
only for bpf_prog objects to keep it fast.
I have to agree with Daniel here.
Having bpf prog in two latch trees is unnecessary.
Especially looking at the patch 7 that moves update to the other tree.
The whole thing becomes assymetrical and harder to follow.
Consider that walking extable is slow anyway. It's a page fault.
Having trampoline and dispatch in the same tree will not be measurable
on the speed of search_bpf_extables->bpf_prog_kallsyms_find.
So please consolidate.
Also I don't see a hunk that deletes tnode from 'struct bpf_image'.
These patches suppose to generalize it too, no?
And at the end kernel_text_address() suppose to call
is_bpf_text_address() only, right?
Instead of is_bpf_text_address() || is_bpf_image_address() ?
That _will_ actually speed up backtrace collection.
From: Jiri Olsa <hidden> Date: 2020-03-03 20:12:47
On Tue, Mar 03, 2020 at 10:03:19AM -0800, Alexei Starovoitov wrote:
On Mon, Mar 02, 2020 at 03:31:45PM +0100, Jiri Olsa wrote:
quoted
The bpf_tree is used both for kallsyms iterations and searching
for exception tables of bpf programs, which is needed only for
bpf programs.
Adding bpf_ksym_tree that will hold symbols for all bpf_prog
bpf_trampoline and bpf_dispatcher objects and keeping bpf_tree
only for bpf_prog objects to keep it fast.
I have to agree with Daniel here.
Having bpf prog in two latch trees is unnecessary.
Especially looking at the patch 7 that moves update to the other tree.
The whole thing becomes assymetrical and harder to follow.
Consider that walking extable is slow anyway. It's a page fault.
Having trampoline and dispatch in the same tree will not be measurable
on the speed of search_bpf_extables->bpf_prog_kallsyms_find.
So please consolidate.
ok
Also I don't see a hunk that deletes tnode from 'struct bpf_image'.
These patches suppose to generalize it too, no?
__bpf_ksym_del function added in patch:
bpf: Separate kallsyms add/del functions
And at the end kernel_text_address() suppose to call
is_bpf_text_address() only, right?
Instead of is_bpf_text_address() || is_bpf_image_address() ?
That _will_ actually speed up backtrace collection.
right, this one could have already used just the ksym tree
will send new version.. meanwhile I was checking struct_ops,
so will include kallsyms support them as well
thanks,
jirka