Message ID | 20200304180710.2677695-1-songliubraving@fb.com |
---|---|
Headers | show |
Series | bpftool: introduce prog profile | expand |
On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: > This set introduces bpftool prog profile command, which uses hardware > counters to profile BPF programs. > > This command attaches fentry/fexit programs to a target program. These two > programs read hardware counters before and after the target program and > calculate the difference. > > Changes v3 => v4: > 1. Simplify err handling in profile_open_perf_events() (Quentin); > 2. Remove redundant p_err() (Quentin); > 3. Replace tab with space in bash-completion; (Quentin); > 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). hum, I'm getting: [jolsa@dell-r440-01 bpftool]$ pwd /home/jolsa/linux-perf/tools/bpf/bpftool [jolsa@dell-r440-01 bpftool]$ make ... make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' LINK _bpftool make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. jirka > > Changes v2 => v3: > 1. Change order of arguments (Quentin), as: > bpftool prog profile PROG [duration DURATION] METRICs > 2. Add bash-completion for bpftool prog profile (Quentin); > 3. Fix build of selftests (Yonghong); > 4. Better handling of bpf_map_lookup_elem() returns (Yonghong); > 5. Improve clean up logic of do_profile() (Yonghong); > 6. Other smaller fixes/cleanups. > > Changes RFC => v2: > 1. Use new bpf_program__set_attach_target() API; > 2. Update output format to be perf-stat like (Alexei); > 3. Incorporate skeleton generation into Makefile; > 4. Make DURATION optional and Allow Ctrl-C (Alexei); > 5. Add calcated values "insn per cycle" and "LLC misses per million isns". > > Song Liu (4): > bpftool: introduce "prog profile" command > bpftool: Documentation for bpftool prog profile > bpftool: bash completion for "bpftool prog profile" > bpftool: fix typo in bash-completion > > .../bpftool/Documentation/bpftool-prog.rst | 19 + > tools/bpf/bpftool/Makefile | 18 + > tools/bpf/bpftool/bash-completion/bpftool | 47 +- > tools/bpf/bpftool/prog.c | 425 +++++++++++++++++- > tools/bpf/bpftool/skeleton/profiler.bpf.c | 171 +++++++ > tools/bpf/bpftool/skeleton/profiler.h | 47 ++ > tools/scripts/Makefile.include | 1 + > 7 files changed, 725 insertions(+), 3 deletions(-) > create mode 100644 tools/bpf/bpftool/skeleton/profiler.bpf.c > create mode 100644 tools/bpf/bpftool/skeleton/profiler.h > > -- > 2.17.1 >
2020-03-04 10:07 UTC-0800 ~ Song Liu <songliubraving@fb.com> > This set introduces bpftool prog profile command, which uses hardware > counters to profile BPF programs. > > This command attaches fentry/fexit programs to a target program. These two > programs read hardware counters before and after the target program and > calculate the difference. > > Changes v3 => v4: > 1. Simplify err handling in profile_open_perf_events() (Quentin); > 2. Remove redundant p_err() (Quentin); > 3. Replace tab with space in bash-completion; (Quentin); > 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). > > Changes v2 => v3: > 1. Change order of arguments (Quentin), as: > bpftool prog profile PROG [duration DURATION] METRICs > 2. Add bash-completion for bpftool prog profile (Quentin); > 3. Fix build of selftests (Yonghong); > 4. Better handling of bpf_map_lookup_elem() returns (Yonghong); > 5. Improve clean up logic of do_profile() (Yonghong); > 6. Other smaller fixes/cleanups. > > Changes RFC => v2: > 1. Use new bpf_program__set_attach_target() API; > 2. Update output format to be perf-stat like (Alexei); > 3. Incorporate skeleton generation into Makefile; > 4. Make DURATION optional and Allow Ctrl-C (Alexei); > 5. Add calcated values "insn per cycle" and "LLC misses per million isns". > > Song Liu (4): > bpftool: introduce "prog profile" command > bpftool: Documentation for bpftool prog profile > bpftool: bash completion for "bpftool prog profile" > bpftool: fix typo in bash-completion > > .../bpftool/Documentation/bpftool-prog.rst | 19 + > tools/bpf/bpftool/Makefile | 18 + > tools/bpf/bpftool/bash-completion/bpftool | 47 +- > tools/bpf/bpftool/prog.c | 425 +++++++++++++++++- > tools/bpf/bpftool/skeleton/profiler.bpf.c | 171 +++++++ > tools/bpf/bpftool/skeleton/profiler.h | 47 ++ > tools/scripts/Makefile.include | 1 + > 7 files changed, 725 insertions(+), 3 deletions(-) > create mode 100644 tools/bpf/bpftool/skeleton/profiler.bpf.c > create mode 100644 tools/bpf/bpftool/skeleton/profiler.h > > -- Thanks again! This version looks good to me, although I've not tested the patchset, so there's still the error met by Jiri to figure out. For the rest of the series: Reviewed-by: Quentin Monnet <quentin@isovalent.com>
On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: > On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: > > This set introduces bpftool prog profile command, which uses hardware > > counters to profile BPF programs. > > > > This command attaches fentry/fexit programs to a target program. These two > > programs read hardware counters before and after the target program and > > calculate the difference. > > > > Changes v3 => v4: > > 1. Simplify err handling in profile_open_perf_events() (Quentin); > > 2. Remove redundant p_err() (Quentin); > > 3. Replace tab with space in bash-completion; (Quentin); > > 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). > > hum, I'm getting: > > [jolsa@dell-r440-01 bpftool]$ pwd > /home/jolsa/linux-perf/tools/bpf/bpftool > [jolsa@dell-r440-01 bpftool]$ make > ... > make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' > LINK _bpftool > make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. ok, I had to apply your patches by hand, because 'git am' refused to due to fuzz.. so some of you new files did not make it to my tree ;-) anyway I hit another error now: CC prog.o In file included from prog.c:1553: profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 136 | s->maps[4].mmaped = (void **)&obj->rodata; | ^~ prog.c: In function ‘profile_read_values’: prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; I'll try to figure it out.. might be error on my end do you have git repo with these changes? thanks, jirka
> On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: > > On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: >> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: >>> This set introduces bpftool prog profile command, which uses hardware >>> counters to profile BPF programs. >>> >>> This command attaches fentry/fexit programs to a target program. These two >>> programs read hardware counters before and after the target program and >>> calculate the difference. >>> >>> Changes v3 => v4: >>> 1. Simplify err handling in profile_open_perf_events() (Quentin); >>> 2. Remove redundant p_err() (Quentin); >>> 3. Replace tab with space in bash-completion; (Quentin); >>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). >> >> hum, I'm getting: >> >> [jolsa@dell-r440-01 bpftool]$ pwd >> /home/jolsa/linux-perf/tools/bpf/bpftool >> [jolsa@dell-r440-01 bpftool]$ make >> ... >> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >> LINK _bpftool >> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. > > ok, I had to apply your patches by hand, because 'git am' refused to > due to fuzz.. so some of you new files did not make it to my tree ;-) > > anyway I hit another error now: > > CC prog.o > In file included from prog.c:1553: > profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: > profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 136 | s->maps[4].mmaped = (void **)&obj->rodata; > | ^~ > prog.c: In function ‘profile_read_values’: > prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; > > I'll try to figure it out.. might be error on my end > > do you have git repo with these changes? I pushed it to https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats Thanks, Song
On Wed, Mar 04, 2020 at 09:16:29PM +0000, Song Liu wrote: > > > > On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: > > > > On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: > >> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: > >>> This set introduces bpftool prog profile command, which uses hardware > >>> counters to profile BPF programs. > >>> > >>> This command attaches fentry/fexit programs to a target program. These two > >>> programs read hardware counters before and after the target program and > >>> calculate the difference. > >>> > >>> Changes v3 => v4: > >>> 1. Simplify err handling in profile_open_perf_events() (Quentin); > >>> 2. Remove redundant p_err() (Quentin); > >>> 3. Replace tab with space in bash-completion; (Quentin); > >>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). > >> > >> hum, I'm getting: > >> > >> [jolsa@dell-r440-01 bpftool]$ pwd > >> /home/jolsa/linux-perf/tools/bpf/bpftool > >> [jolsa@dell-r440-01 bpftool]$ make > >> ... > >> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' > >> LINK _bpftool > >> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. > > > > ok, I had to apply your patches by hand, because 'git am' refused to > > due to fuzz.. so some of you new files did not make it to my tree ;-) > > > > anyway I hit another error now: > > > > CC prog.o > > In file included from prog.c:1553: > > profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: > > profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > > 136 | s->maps[4].mmaped = (void **)&obj->rodata; > > | ^~ > > prog.c: In function ‘profile_read_values’: > > prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > > 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; > > > > I'll try to figure it out.. might be error on my end > > > > do you have git repo with these changes? > > I pushed it to > > https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats still the same: [jolsa@dell-r440-01 bpftool]$ git show --oneline HEAD | head -1 7bbda5cca00a bpftool: fix typo in bash-completion [jolsa@dell-r440-01 bpftool]$ make make[1]: Entering directory '/home/jolsa/linux-perf/tools/lib/bpf' make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' CC prog.o In file included from prog.c:1553: profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 136 | s->maps[4].mmaped = (void **)&obj->rodata; | ^~ prog.c: In function ‘profile_read_values’: prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; | ^~ prog.c: In function ‘profile_open_perf_events’: prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); | ^~ prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); | ^~ prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { | ^~ prog.c: In function ‘do_profile’: prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1904 | profile_obj->rodata->num_cpu = num_cpu; | ^~ prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ 1905 | profile_obj->rodata->num_metric = num_metric; | ^~ make: *** [Makefile:129: prog.o] Error 1 jirka
> On Mar 4, 2020, at 1:29 PM, Jiri Olsa <jolsa@redhat.com> wrote: > > On Wed, Mar 04, 2020 at 09:16:29PM +0000, Song Liu wrote: >> >> >>> On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: >>> >>> On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: >>>> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: >>>>> This set introduces bpftool prog profile command, which uses hardware >>>>> counters to profile BPF programs. >>>>> >>>>> This command attaches fentry/fexit programs to a target program. These two >>>>> programs read hardware counters before and after the target program and >>>>> calculate the difference. >>>>> >>>>> Changes v3 => v4: >>>>> 1. Simplify err handling in profile_open_perf_events() (Quentin); >>>>> 2. Remove redundant p_err() (Quentin); >>>>> 3. Replace tab with space in bash-completion; (Quentin); >>>>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). >>>> >>>> hum, I'm getting: >>>> >>>> [jolsa@dell-r440-01 bpftool]$ pwd >>>> /home/jolsa/linux-perf/tools/bpf/bpftool >>>> [jolsa@dell-r440-01 bpftool]$ make >>>> ... >>>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >>>> LINK _bpftool >>>> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. >>> >>> ok, I had to apply your patches by hand, because 'git am' refused to >>> due to fuzz.. so some of you new files did not make it to my tree ;-) >>> >>> anyway I hit another error now: >>> >>> CC prog.o >>> In file included from prog.c:1553: >>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >>> | ^~ >>> prog.c: In function ‘profile_read_values’: >>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >>> >>> I'll try to figure it out.. might be error on my end >>> >>> do you have git repo with these changes? >> >> I pushed it to >> >> https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats > > still the same: > > [jolsa@dell-r440-01 bpftool]$ git show --oneline HEAD | head -1 > 7bbda5cca00a bpftool: fix typo in bash-completion > [jolsa@dell-r440-01 bpftool]$ make > make[1]: Entering directory '/home/jolsa/linux-perf/tools/lib/bpf' > make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' > CC prog.o > In file included from prog.c:1553: > profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: > profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 136 | s->maps[4].mmaped = (void **)&obj->rodata; > | ^~ > prog.c: In function ‘profile_read_values’: > prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; > | ^~ > prog.c: In function ‘profile_open_perf_events’: > prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > | ^~ > prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > | ^~ > prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { > | ^~ > prog.c: In function ‘do_profile’: > prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1904 | profile_obj->rodata->num_cpu = num_cpu; > | ^~ > prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > 1905 | profile_obj->rodata->num_metric = num_metric; > | ^~ > make: *** [Makefile:129: prog.o] Error 1 I guess you need a newer version of clang that supports global data in BPF programs. Thanks, Song
> On Mar 4, 2020, at 1:39 PM, Song Liu <songliubraving@fb.com> wrote: > > > >> On Mar 4, 2020, at 1:29 PM, Jiri Olsa <jolsa@redhat.com> wrote: >> >> On Wed, Mar 04, 2020 at 09:16:29PM +0000, Song Liu wrote: >>> >>> >>>> On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: >>>> >>>> On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: >>>>> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: >>>>>> This set introduces bpftool prog profile command, which uses hardware >>>>>> counters to profile BPF programs. >>>>>> >>>>>> This command attaches fentry/fexit programs to a target program. These two >>>>>> programs read hardware counters before and after the target program and >>>>>> calculate the difference. >>>>>> >>>>>> Changes v3 => v4: >>>>>> 1. Simplify err handling in profile_open_perf_events() (Quentin); >>>>>> 2. Remove redundant p_err() (Quentin); >>>>>> 3. Replace tab with space in bash-completion; (Quentin); >>>>>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). >>>>> >>>>> hum, I'm getting: >>>>> >>>>> [jolsa@dell-r440-01 bpftool]$ pwd >>>>> /home/jolsa/linux-perf/tools/bpf/bpftool >>>>> [jolsa@dell-r440-01 bpftool]$ make >>>>> ... >>>>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >>>>> LINK _bpftool >>>>> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. >>>> >>>> ok, I had to apply your patches by hand, because 'git am' refused to >>>> due to fuzz.. so some of you new files did not make it to my tree ;-) >>>> >>>> anyway I hit another error now: >>>> >>>> CC prog.o >>>> In file included from prog.c:1553: >>>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >>>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >>>> | ^~ >>>> prog.c: In function ‘profile_read_values’: >>>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >>>> >>>> I'll try to figure it out.. might be error on my end >>>> >>>> do you have git repo with these changes? >>> >>> I pushed it to >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats >> >> still the same: >> >> [jolsa@dell-r440-01 bpftool]$ git show --oneline HEAD | head -1 >> 7bbda5cca00a bpftool: fix typo in bash-completion >> [jolsa@dell-r440-01 bpftool]$ make >> make[1]: Entering directory '/home/jolsa/linux-perf/tools/lib/bpf' >> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >> CC prog.o >> In file included from prog.c:1553: >> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >> | ^~ >> prog.c: In function ‘profile_read_values’: >> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >> | ^~ >> prog.c: In function ‘profile_open_perf_events’: >> prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); >> | ^~ >> prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); >> | ^~ >> prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { >> | ^~ >> prog.c: In function ‘do_profile’: >> prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1904 | profile_obj->rodata->num_cpu = num_cpu; >> | ^~ >> prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1905 | profile_obj->rodata->num_metric = num_metric; >> | ^~ >> make: *** [Makefile:129: prog.o] Error 1 > > I guess you need a newer version of clang that supports global data in BPF programs. Hi Jiri, Have you got chance to test this with latest clang? Thanks, Song
On Thu, Mar 05, 2020 at 08:03:53PM +0000, Song Liu wrote: SNIP > >> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; > >> | ^~ > >> prog.c: In function ‘profile_open_perf_events’: > >> prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > >> | ^~ > >> prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > >> | ^~ > >> prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >> 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { > >> | ^~ > >> prog.c: In function ‘do_profile’: > >> prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >> 1904 | profile_obj->rodata->num_cpu = num_cpu; > >> | ^~ > >> prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >> 1905 | profile_obj->rodata->num_metric = num_metric; > >> | ^~ > >> make: *** [Makefile:129: prog.o] Error 1 > > > > I guess you need a newer version of clang that supports global data in BPF programs. > > Hi Jiri, > > Have you got chance to test this with latest clang? yep, got it compiled with new clang I was testing in on bpftrace programs and couldn't made it work, because it relies on BTF info.. so I got stuck ;-) # bpftool prog profile id 241 duration 3 cycles instructions llc_misses Error: prog FD 3 doesn't have valid btf nit.. ^^^ you could display ID instead of FD in here I need to check if we can provide BTF info for bpftrace programs jirka
2020-03-04 21:39 UTC+0000 ~ Song Liu <songliubraving@fb.com> > > >> On Mar 4, 2020, at 1:29 PM, Jiri Olsa <jolsa@redhat.com> wrote: >> >> On Wed, Mar 04, 2020 at 09:16:29PM +0000, Song Liu wrote: >>> >>> >>>> On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: >>>> >>>> On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: >>>>> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: >>>>>> This set introduces bpftool prog profile command, which uses hardware >>>>>> counters to profile BPF programs. >>>>>> >>>>>> This command attaches fentry/fexit programs to a target program. These two >>>>>> programs read hardware counters before and after the target program and >>>>>> calculate the difference. >>>>>> >>>>>> Changes v3 => v4: >>>>>> 1. Simplify err handling in profile_open_perf_events() (Quentin); >>>>>> 2. Remove redundant p_err() (Quentin); >>>>>> 3. Replace tab with space in bash-completion; (Quentin); >>>>>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). >>>>> >>>>> hum, I'm getting: >>>>> >>>>> [jolsa@dell-r440-01 bpftool]$ pwd >>>>> /home/jolsa/linux-perf/tools/bpf/bpftool >>>>> [jolsa@dell-r440-01 bpftool]$ make >>>>> ... >>>>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >>>>> LINK _bpftool >>>>> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. >>>> >>>> ok, I had to apply your patches by hand, because 'git am' refused to >>>> due to fuzz.. so some of you new files did not make it to my tree ;-) >>>> >>>> anyway I hit another error now: >>>> >>>> CC prog.o >>>> In file included from prog.c:1553: >>>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >>>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >>>> | ^~ >>>> prog.c: In function ‘profile_read_values’: >>>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >>>> >>>> I'll try to figure it out.. might be error on my end >>>> >>>> do you have git repo with these changes? >>> >>> I pushed it to >>> >>> https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats >> >> still the same: >> >> [jolsa@dell-r440-01 bpftool]$ git show --oneline HEAD | head -1 >> 7bbda5cca00a bpftool: fix typo in bash-completion >> [jolsa@dell-r440-01 bpftool]$ make >> make[1]: Entering directory '/home/jolsa/linux-perf/tools/lib/bpf' >> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >> CC prog.o >> In file included from prog.c:1553: >> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >> | ^~ >> prog.c: In function ‘profile_read_values’: >> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >> | ^~ >> prog.c: In function ‘profile_open_perf_events’: >> prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); >> | ^~ >> prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); >> | ^~ >> prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { >> | ^~ >> prog.c: In function ‘do_profile’: >> prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1904 | profile_obj->rodata->num_cpu = num_cpu; >> | ^~ >> prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >> 1905 | profile_obj->rodata->num_metric = num_metric; >> | ^~ >> make: *** [Makefile:129: prog.o] Error 1 > > I guess you need a newer version of clang that supports global data in BPF programs. > > Thanks, > Song > Thinking about this requirement again... Do you think it would be worth adding (as a follow-up) a feature check on the availability of clang with global data support to bpftool's Makefile? So that we could compile out program profiling if clang is not present or does not support it. Just like libbfd support is optional already. I'm asking mostly because a number of distributions now package bpftool, and e.g. Ubuntu builds it from kernel source when creating its linux-images and linux-tools-* packages. And I am pretty sure the build environment does not have latest clang/LLVM, but it would be great to remain able to build bpftool. Best regards, Quentin
> On Mar 9, 2020, at 11:04 AM, Quentin Monnet <quentin@isovalent.com> wrote: > > 2020-03-04 21:39 UTC+0000 ~ Song Liu <songliubraving@fb.com> >> >> >>> On Mar 4, 2020, at 1:29 PM, Jiri Olsa <jolsa@redhat.com> wrote: >>> >>> On Wed, Mar 04, 2020 at 09:16:29PM +0000, Song Liu wrote: >>>> >>>> >>>>> On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: >>>>> >>>>> On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: >>>>>> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: >>>>>>> This set introduces bpftool prog profile command, which uses hardware >>>>>>> counters to profile BPF programs. >>>>>>> >>>>>>> This command attaches fentry/fexit programs to a target program. These two >>>>>>> programs read hardware counters before and after the target program and >>>>>>> calculate the difference. >>>>>>> >>>>>>> Changes v3 => v4: >>>>>>> 1. Simplify err handling in profile_open_perf_events() (Quentin); >>>>>>> 2. Remove redundant p_err() (Quentin); >>>>>>> 3. Replace tab with space in bash-completion; (Quentin); >>>>>>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). >>>>>> >>>>>> hum, I'm getting: >>>>>> >>>>>> [jolsa@dell-r440-01 bpftool]$ pwd >>>>>> /home/jolsa/linux-perf/tools/bpf/bpftool >>>>>> [jolsa@dell-r440-01 bpftool]$ make >>>>>> ... >>>>>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >>>>>> LINK _bpftool >>>>>> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. >>>>> >>>>> ok, I had to apply your patches by hand, because 'git am' refused to >>>>> due to fuzz.. so some of you new files did not make it to my tree ;-) >>>>> >>>>> anyway I hit another error now: >>>>> >>>>> CC prog.o >>>>> In file included from prog.c:1553: >>>>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >>>>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>>>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >>>>> | ^~ >>>>> prog.c: In function ‘profile_read_values’: >>>>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>>>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >>>>> >>>>> I'll try to figure it out.. might be error on my end >>>>> >>>>> do you have git repo with these changes? >>>> >>>> I pushed it to >>>> >>>> https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats >>> >>> still the same: >>> >>> [jolsa@dell-r440-01 bpftool]$ git show --oneline HEAD | head -1 >>> 7bbda5cca00a bpftool: fix typo in bash-completion >>> [jolsa@dell-r440-01 bpftool]$ make >>> make[1]: Entering directory '/home/jolsa/linux-perf/tools/lib/bpf' >>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' >>> CC prog.o >>> In file included from prog.c:1553: >>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: >>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; >>> | ^~ >>> prog.c: In function ‘profile_read_values’: >>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; >>> | ^~ >>> prog.c: In function ‘profile_open_perf_events’: >>> prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); >>> | ^~ >>> prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); >>> | ^~ >>> prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { >>> | ^~ >>> prog.c: In function ‘do_profile’: >>> prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1904 | profile_obj->rodata->num_cpu = num_cpu; >>> | ^~ >>> prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ >>> 1905 | profile_obj->rodata->num_metric = num_metric; >>> | ^~ >>> make: *** [Makefile:129: prog.o] Error 1 >> >> I guess you need a newer version of clang that supports global data in BPF programs. >> >> Thanks, >> Song >> > > Thinking about this requirement again... Do you think it would be worth > adding (as a follow-up) a feature check on the availability of clang > with global data support to bpftool's Makefile? So that we could compile > out program profiling if clang is not present or does not support it. > Just like libbfd support is optional already. > > I'm asking mostly because a number of distributions now package bpftool, > and e.g. Ubuntu builds it from kernel source when creating its > linux-images and linux-tools-* packages. And I am pretty sure the build > environment does not have latest clang/LLVM, but it would be great to > remain able to build bpftool. Yeah, I think it is a good idea. Some more Makefile fun. ;) Thanks, Song
On Mon, Mar 09, 2020 at 06:24:22PM +0000, Song Liu wrote: > > > > On Mar 9, 2020, at 11:04 AM, Quentin Monnet <quentin@isovalent.com> wrote: > > > > 2020-03-04 21:39 UTC+0000 ~ Song Liu <songliubraving@fb.com> > >> > >> > >>> On Mar 4, 2020, at 1:29 PM, Jiri Olsa <jolsa@redhat.com> wrote: > >>> > >>> On Wed, Mar 04, 2020 at 09:16:29PM +0000, Song Liu wrote: > >>>> > >>>> > >>>>> On Mar 4, 2020, at 12:41 PM, Jiri Olsa <jolsa@redhat.com> wrote: > >>>>> > >>>>> On Wed, Mar 04, 2020 at 08:08:07PM +0100, Jiri Olsa wrote: > >>>>>> On Wed, Mar 04, 2020 at 10:07:06AM -0800, Song Liu wrote: > >>>>>>> This set introduces bpftool prog profile command, which uses hardware > >>>>>>> counters to profile BPF programs. > >>>>>>> > >>>>>>> This command attaches fentry/fexit programs to a target program. These two > >>>>>>> programs read hardware counters before and after the target program and > >>>>>>> calculate the difference. > >>>>>>> > >>>>>>> Changes v3 => v4: > >>>>>>> 1. Simplify err handling in profile_open_perf_events() (Quentin); > >>>>>>> 2. Remove redundant p_err() (Quentin); > >>>>>>> 3. Replace tab with space in bash-completion; (Quentin); > >>>>>>> 4. Fix typo _bpftool_get_map_names => _bpftool_get_prog_names (Quentin). > >>>>>> > >>>>>> hum, I'm getting: > >>>>>> > >>>>>> [jolsa@dell-r440-01 bpftool]$ pwd > >>>>>> /home/jolsa/linux-perf/tools/bpf/bpftool > >>>>>> [jolsa@dell-r440-01 bpftool]$ make > >>>>>> ... > >>>>>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' > >>>>>> LINK _bpftool > >>>>>> make: *** No rule to make target 'skeleton/profiler.bpf.c', needed by 'skeleton/profiler.bpf.o'. Stop. > >>>>> > >>>>> ok, I had to apply your patches by hand, because 'git am' refused to > >>>>> due to fuzz.. so some of you new files did not make it to my tree ;-) > >>>>> > >>>>> anyway I hit another error now: > >>>>> > >>>>> CC prog.o > >>>>> In file included from prog.c:1553: > >>>>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: > >>>>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>>>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; > >>>>> | ^~ > >>>>> prog.c: In function ‘profile_read_values’: > >>>>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>>>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; > >>>>> > >>>>> I'll try to figure it out.. might be error on my end > >>>>> > >>>>> do you have git repo with these changes? > >>>> > >>>> I pushed it to > >>>> > >>>> https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/tree/?h=bpf-per-prog-stats > >>> > >>> still the same: > >>> > >>> [jolsa@dell-r440-01 bpftool]$ git show --oneline HEAD | head -1 > >>> 7bbda5cca00a bpftool: fix typo in bash-completion > >>> [jolsa@dell-r440-01 bpftool]$ make > >>> make[1]: Entering directory '/home/jolsa/linux-perf/tools/lib/bpf' > >>> make[1]: Leaving directory '/home/jolsa/linux-perf/tools/lib/bpf' > >>> CC prog.o > >>> In file included from prog.c:1553: > >>> profiler.skel.h: In function ‘profiler_bpf__create_skeleton’: > >>> profiler.skel.h:136:35: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 136 | s->maps[4].mmaped = (void **)&obj->rodata; > >>> | ^~ > >>> prog.c: In function ‘profile_read_values’: > >>> prog.c:1650:29: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 1650 | __u32 m, cpu, num_cpu = obj->rodata->num_cpu; > >>> | ^~ > >>> prog.c: In function ‘profile_open_perf_events’: > >>> prog.c:1810:19: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > >>> | ^~ > >>> prog.c:1810:42: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 1810 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > >>> | ^~ > >>> prog.c:1825:26: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 1825 | for (cpu = 0; cpu < obj->rodata->num_cpu; cpu++) { > >>> | ^~ > >>> prog.c: In function ‘do_profile’: > >>> prog.c:1904:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 1904 | profile_obj->rodata->num_cpu = num_cpu; > >>> | ^~ > >>> prog.c:1905:13: error: ‘struct profiler_bpf’ has no member named ‘rodata’ > >>> 1905 | profile_obj->rodata->num_metric = num_metric; > >>> | ^~ > >>> make: *** [Makefile:129: prog.o] Error 1 > >> > >> I guess you need a newer version of clang that supports global data in BPF programs. > >> > >> Thanks, > >> Song > >> > > > > Thinking about this requirement again... Do you think it would be worth > > adding (as a follow-up) a feature check on the availability of clang > > with global data support to bpftool's Makefile? So that we could compile > > out program profiling if clang is not present or does not support it. > > Just like libbfd support is optional already. > > > > I'm asking mostly because a number of distributions now package bpftool, > > and e.g. Ubuntu builds it from kernel source when creating its > > linux-images and linux-tools-* packages. And I am pretty sure the build > > environment does not have latest clang/LLVM, but it would be great to > > remain able to build bpftool. > > Yeah, I think it is a good idea. Some more Makefile fun. ;) I think it's good idea, also bpftool is already using feature detection from tools/build/features.. you can check commits like: fb982666e380 tools/bpftool: fix bpftool build with bintutils >= 2.9 for adding new feature detection jirka