Subject: Re: [PATCH v4 bpf-next 0/4] bpftool: introduce prog profile

From: Jiri Olsa <[email-masked]>
Date: Fri, 6 Mar 2020 09:51:58 +0100

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