Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-20 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 05:48:31PM -0800, Joe Stringer escreveu:
> On 15 December 2016 at 14:00, Joe Stringer  wrote:
> > On 15 December 2016 at 10:34, Arnaldo Carvalho de Melo  
> > wrote:
> >> So, I'm stopping here so that I can push what I have to Ingo, then I'll get
> >> back to this, hopefully by then you beat me and I have just to retest 8-)

> > OK, thanks for the report. Looks like there was another difference
> > between the two libbpfs - one used total program size for its
> > load_program API; the actual kernel API uses instruction count. This
> > incremental should do the trick:

> > https://github.com/joestringer/linux/commit/6ff7726f20077bed66fb725f5189c13690154b6a
 
> The full branch with this change (fast-forward from your tmp branch)
> is available here:
> https://github.com/joestringer/linux/tree/submit/libbpf_samples_v5
 
> I tried running every selftest and BPF sample I could get my hands on;
> there's one or two that I couldn't run, but seemed more to do with my
> versions of TC/iproute and kernel config rather than libbpf changes.
> Let me know if you see any further trouble.

Finally getting back to this, now after I figured out how to get patches
out of github (wget commit + .patch) I applied this and at least the
samples/bpf/offwaketime seems to work as before, applying.

- Arnaldo


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-16 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 05:48:31PM -0800, Joe Stringer escreveu:
> On 15 December 2016 at 14:00, Joe Stringer  wrote:
> > On 15 December 2016 at 10:34, Arnaldo Carvalho de Melo  
> > wrote:
> >> Em Thu, Dec 15, 2016 at 03:29:18PM -0300, Arnaldo Carvalho de Melo 
> >> escreveu:
> >>> Em Thu, Dec 15, 2016 at 12:50:22PM -0300, Arnaldo Carvalho de Melo 
> >>> escreveu:
> >>> > Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
> >>> > > Now that libbpf under tools/lib/bpf/* is synced with the version from
> >>> > > samples/bpf, we can get rid most of the libbpf library here.
> >>> > >
> >>> > > Signed-off-by: Joe Stringer 
> >>> > > Cc: Alexei Starovoitov 
> >>> > > Cc: Daniel Borkmann 
> >>> > > Cc: Wang Nan 
> >>> > > Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
> >>> > > [ Use -I$(srctree)/tools/lib/ to support out of source code tree 
> >>> > > builds, as noticed by Wang Nan ]
> >>>
> >>> So, the above comment no longer applied to this adjusted patch from you,
> >>> as you removed one hunk too much, that, after applied, gets samples/bpf/
> >>> to build successfully:
> >>>
> >>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> >>> index add514e2984a..81b0ef2f7994 100644
> >>> --- a/samples/bpf/Makefile
> >>> +++ b/samples/bpf/Makefile
> >>> @@ -107,6 +107,7 @@ always += lwt_len_hist_kern.o
> >>>  always += xdp_tx_iptunnel_kern.o
> >>>
> >>>  HOSTCFLAGS += -I$(objtree)/usr/include
> >>> +HOSTCFLAGS += -I$(srctree)/tools/lib/
> >>>  HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
> >>>
> >>>  HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
> >>>
> >>> -
> >>>
> >>> I added it, continuing...
> >>
> >> But then, when I tried to run offwaketime with it, it fails:
> >>
> >> [root@jouet bpf]# ./offwaketime  ls
> >> bpf_load_program() err=22
> >> BPF_LDX uses reserved fields
> >> bpf_load_program() err=22
> >> BPF_LDX uses reserved fields
> >> [root@jouet bpf]#
> >>
> >> If I remove this patch and try again, it works:
> >>
> >> [root@jouet bpf]# ./offwaketime | head -4
> >> swapper/1;start_secondary;cpu_startup_entry;schedule_preempt_disabled;schedule;__schedule;-;---;;
> >>  46
> >> chrome;return_from_SYSCALL_64;do_syscall_64;exit_to_usermode_loop;schedule;__schedule;-;try_to_wake_up;do_futex;sys_futex;do_syscall_64;return_from_SYSCALL_64;;Chrome_ChildIOT
> >>  1
> >> firefox;entry_SYSCALL_64_fastpath;sys_poll;do_sys_poll;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;pollwake;__wake_up_common;__wake_up_sync_key;pipe_write;__vfs_write;vfs_write;sys_write;entry_SYSCALL_64_fastpath;;Timer
> >>  3
> >> dockerd-current;entry_SYSCALL_64_fastpath;sys_select;core_sys_select;do_select;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;futex_wake;do_futex;sys_futex;entry_SYSCALL_64_fastpath;;dockerd-current
> >>  2
> >> [root@jouet bpf]#
> >>
> >>
> >> So, I'm stopping here so that I can push what I have to Ingo, then I'll get
> >> back to this, hopefully by then you beat me and I have just to retest 8-)
> >
> > OK, thanks for the report. Looks like there was another difference
> > between the two libbpfs - one used total program size for its
> > load_program API; the actual kernel API uses instruction count. This
> > incremental should do the trick:
> >
> > https://github.com/joestringer/linux/commit/6ff7726f20077bed66fb725f5189c13690154b6a
> 
> The full branch with this change (fast-forward from your tmp branch)
> is available here:
> https://github.com/joestringer/linux/tree/submit/libbpf_samples_v5

Can you please repost the patches you changed, and just those, sometimes
I'm with limited net connectivity, so not having to go use the github
interface, figure out how to download the patches, etc, is a win.

- Arnaldo
 
> I tried running every selftest and BPF sample I could get my hands on;
> there's one or two that I couldn't run, but seemed more to do with my
> versions of TC/iproute and kernel config rather than libbpf changes.
> Let me know if you see any further trouble.


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-16 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 05:48:31PM -0800, Joe Stringer escreveu:
> On 15 December 2016 at 14:00, Joe Stringer  wrote:
> > On 15 December 2016 at 10:34, Arnaldo Carvalho de Melo  
> > wrote:
> >> So, I'm stopping here so that I can push what I have to Ingo, then I'll get
> >> back to this, hopefully by then you beat me and I have just to retest 8-)

> > OK, thanks for the report. Looks like there was another difference
> > between the two libbpfs - one used total program size for its
> > load_program API; the actual kernel API uses instruction count. This
> > incremental should do the trick:

> > https://github.com/joestringer/linux/commit/6ff7726f20077bed66fb725f5189c13690154b6a
 
> The full branch with this change (fast-forward from your tmp branch)
> is available here:
> https://github.com/joestringer/linux/tree/submit/libbpf_samples_v5
 
> I tried running every selftest and BPF sample I could get my hands on;
> there's one or two that I couldn't run, but seemed more to do with my
> versions of TC/iproute and kernel config rather than libbpf changes.
> Let me know if you see any further trouble.

Thanks for doing that! I'll try and reproduce your tests as soon as I'm
back to the office, it looks like it all will go together in my next
pull to Ingo.

- Arnaldo


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Joe Stringer
On 15 December 2016 at 14:00, Joe Stringer  wrote:
> On 15 December 2016 at 10:34, Arnaldo Carvalho de Melo  
> wrote:
>> Em Thu, Dec 15, 2016 at 03:29:18PM -0300, Arnaldo Carvalho de Melo escreveu:
>>> Em Thu, Dec 15, 2016 at 12:50:22PM -0300, Arnaldo Carvalho de Melo escreveu:
>>> > Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
>>> > > Now that libbpf under tools/lib/bpf/* is synced with the version from
>>> > > samples/bpf, we can get rid most of the libbpf library here.
>>> > >
>>> > > Signed-off-by: Joe Stringer 
>>> > > Cc: Alexei Starovoitov 
>>> > > Cc: Daniel Borkmann 
>>> > > Cc: Wang Nan 
>>> > > Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
>>> > > [ Use -I$(srctree)/tools/lib/ to support out of source code tree 
>>> > > builds, as noticed by Wang Nan ]
>>>
>>> So, the above comment no longer applied to this adjusted patch from you,
>>> as you removed one hunk too much, that, after applied, gets samples/bpf/
>>> to build successfully:
>>>
>>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
>>> index add514e2984a..81b0ef2f7994 100644
>>> --- a/samples/bpf/Makefile
>>> +++ b/samples/bpf/Makefile
>>> @@ -107,6 +107,7 @@ always += lwt_len_hist_kern.o
>>>  always += xdp_tx_iptunnel_kern.o
>>>
>>>  HOSTCFLAGS += -I$(objtree)/usr/include
>>> +HOSTCFLAGS += -I$(srctree)/tools/lib/
>>>  HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
>>>
>>>  HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
>>>
>>> -
>>>
>>> I added it, continuing...
>>
>> But then, when I tried to run offwaketime with it, it fails:
>>
>> [root@jouet bpf]# ./offwaketime  ls
>> bpf_load_program() err=22
>> BPF_LDX uses reserved fields
>> bpf_load_program() err=22
>> BPF_LDX uses reserved fields
>> [root@jouet bpf]#
>>
>> If I remove this patch and try again, it works:
>>
>> [root@jouet bpf]# ./offwaketime | head -4
>> swapper/1;start_secondary;cpu_startup_entry;schedule_preempt_disabled;schedule;__schedule;-;---;;
>>  46
>> chrome;return_from_SYSCALL_64;do_syscall_64;exit_to_usermode_loop;schedule;__schedule;-;try_to_wake_up;do_futex;sys_futex;do_syscall_64;return_from_SYSCALL_64;;Chrome_ChildIOT
>>  1
>> firefox;entry_SYSCALL_64_fastpath;sys_poll;do_sys_poll;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;pollwake;__wake_up_common;__wake_up_sync_key;pipe_write;__vfs_write;vfs_write;sys_write;entry_SYSCALL_64_fastpath;;Timer
>>  3
>> dockerd-current;entry_SYSCALL_64_fastpath;sys_select;core_sys_select;do_select;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;futex_wake;do_futex;sys_futex;entry_SYSCALL_64_fastpath;;dockerd-current
>>  2
>> [root@jouet bpf]#
>>
>>
>> So, I'm stopping here so that I can push what I have to Ingo, then I'll get
>> back to this, hopefully by then you beat me and I have just to retest 8-)
>
> OK, thanks for the report. Looks like there was another difference
> between the two libbpfs - one used total program size for its
> load_program API; the actual kernel API uses instruction count. This
> incremental should do the trick:
>
> https://github.com/joestringer/linux/commit/6ff7726f20077bed66fb725f5189c13690154b6a

The full branch with this change (fast-forward from your tmp branch)
is available here:
https://github.com/joestringer/linux/tree/submit/libbpf_samples_v5

I tried running every selftest and BPF sample I could get my hands on;
there's one or two that I couldn't run, but seemed more to do with my
versions of TC/iproute and kernel config rather than libbpf changes.
Let me know if you see any further trouble.


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Joe Stringer
On 15 December 2016 at 10:34, Arnaldo Carvalho de Melo  wrote:
> Em Thu, Dec 15, 2016 at 03:29:18PM -0300, Arnaldo Carvalho de Melo escreveu:
>> Em Thu, Dec 15, 2016 at 12:50:22PM -0300, Arnaldo Carvalho de Melo escreveu:
>> > Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
>> > > Now that libbpf under tools/lib/bpf/* is synced with the version from
>> > > samples/bpf, we can get rid most of the libbpf library here.
>> > >
>> > > Signed-off-by: Joe Stringer 
>> > > Cc: Alexei Starovoitov 
>> > > Cc: Daniel Borkmann 
>> > > Cc: Wang Nan 
>> > > Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
>> > > [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, 
>> > > as noticed by Wang Nan ]
>>
>> So, the above comment no longer applied to this adjusted patch from you,
>> as you removed one hunk too much, that, after applied, gets samples/bpf/
>> to build successfully:
>>
>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
>> index add514e2984a..81b0ef2f7994 100644
>> --- a/samples/bpf/Makefile
>> +++ b/samples/bpf/Makefile
>> @@ -107,6 +107,7 @@ always += lwt_len_hist_kern.o
>>  always += xdp_tx_iptunnel_kern.o
>>
>>  HOSTCFLAGS += -I$(objtree)/usr/include
>> +HOSTCFLAGS += -I$(srctree)/tools/lib/
>>  HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
>>
>>  HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
>>
>> -
>>
>> I added it, continuing...
>
> But then, when I tried to run offwaketime with it, it fails:
>
> [root@jouet bpf]# ./offwaketime  ls
> bpf_load_program() err=22
> BPF_LDX uses reserved fields
> bpf_load_program() err=22
> BPF_LDX uses reserved fields
> [root@jouet bpf]#
>
> If I remove this patch and try again, it works:
>
> [root@jouet bpf]# ./offwaketime | head -4
> swapper/1;start_secondary;cpu_startup_entry;schedule_preempt_disabled;schedule;__schedule;-;---;;
>  46
> chrome;return_from_SYSCALL_64;do_syscall_64;exit_to_usermode_loop;schedule;__schedule;-;try_to_wake_up;do_futex;sys_futex;do_syscall_64;return_from_SYSCALL_64;;Chrome_ChildIOT
>  1
> firefox;entry_SYSCALL_64_fastpath;sys_poll;do_sys_poll;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;pollwake;__wake_up_common;__wake_up_sync_key;pipe_write;__vfs_write;vfs_write;sys_write;entry_SYSCALL_64_fastpath;;Timer
>  3
> dockerd-current;entry_SYSCALL_64_fastpath;sys_select;core_sys_select;do_select;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;futex_wake;do_futex;sys_futex;entry_SYSCALL_64_fastpath;;dockerd-current
>  2
> [root@jouet bpf]#
>
>
> So, I'm stopping here so that I can push what I have to Ingo, then I'll get
> back to this, hopefully by then you beat me and I have just to retest 8-)

OK, thanks for the report. Looks like there was another difference
between the two libbpfs - one used total program size for its
load_program API; the actual kernel API uses instruction count. This
incremental should do the trick:

https://github.com/joestringer/linux/commit/6ff7726f20077bed66fb725f5189c13690154b6a


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 10:29:19AM -0800, Joe Stringer escreveu:
> On 15 December 2016 at 07:50, Arnaldo Carvalho de Melo  
> wrote:
> > Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
> >> Now that libbpf under tools/lib/bpf/* is synced with the version from
> >> samples/bpf, we can get rid most of the libbpf library here.
> >>
> >> Signed-off-by: Joe Stringer 
> >> Cc: Alexei Starovoitov 
> >> Cc: Daniel Borkmann 
> >> Cc: Wang Nan 
> >> Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
> >> [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, 
> >> as noticed by Wang Nan ]
> >> Signed-off-by: Arnaldo Carvalho de Melo 
> >
> > So, right before this patch building samples/bpf works, then, after, it 
> > fails,
> > investigating:
> >
> > [root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ headers_install
> > make[1]: Entering directory '/tmp/build/linux'
> >   CHK include/generated/uapi/linux/version.h
> > make[1]: Leaving directory '/tmp/build/linux'
> > [root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ samples/bpf/
> > make[1]: Entering directory '/tmp/build/linux'
> >   CHK include/config/kernel.release
> >   GEN ./Makefile
> >   CHK include/generated/uapi/linux/version.h
> >   Using /git/linux as source for kernel
> >   CHK include/generated/utsrelease.h
> >   CHK include/generated/timeconst.h
> >   CHK include/generated/bounds.h
> >   CHK include/generated/asm-offsets.h
> >   CALL/git/linux/scripts/checksyscalls.sh
> >   HOSTCC  samples/bpf/test_lru_dist.o
> >   HOSTCC  samples/bpf/libbpf.o
> >   HOSTCC  samples/bpf/sock_example.o
> >   HOSTCC  samples/bpf/bpf_load.o
> > In file included from /git/linux/samples/bpf/libbpf.c:12:0:
> > /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file 
> > or directory
> >  #include 
> >  ^
> > compilation terminated.
> > In file included from /git/linux/samples/bpf/test_lru_dist.c:24:0:
> > /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file 
> > or directory
> >  #include 
> >  ^
> > compilation terminated.
> > make[2]: *** [scripts/Makefile.host:124: samples/bpf/test_lru_dist.o] Error 
> > 1
> > make[2]: *** Waiting for unfinished jobs
> > make[2]: *** [scripts/Makefile.host:124: samples/bpf/libbpf.o] Error 1
> > In file included from /git/linux/samples/bpf/bpf_load.c:24:0:
> > /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file 
> > or directory
> >  #include 
> >  ^
> > compilation terminated.
> > make[2]: *** [scripts/Makefile.host:124: samples/bpf/bpf_load.o] Error 1
> > In file included from /git/linux/samples/bpf/sock_example.c:29:0:
> > /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file 
> > or directory
> >  #include 
> >  ^
> > compilation terminated.
> > make[2]: *** [scripts/Makefile.host:124: samples/bpf/sock_example.o] Error 1
> > make[1]: *** [/git/linux/Makefile:1659: samples/bpf/] Error 2
> > make[1]: Leaving directory '/tmp/build/linux'
> > make: *** [Makefile:150: sub-make] Error 2
> > [root@1e797fdfbf4f linux]#
> 
> Sorry about that.
> 
> It looks like this fragment which ended up in "samples/bpf: Remove
> perf_event_open() declaration" patch should be here instead:

I figured that out, but there is another problem, see my other messages,

- Arnaldo
 
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index add514e2984a..9718f664fedf 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -108,6 +108,8 @@ always += xdp_tx_iptunnel_kern.o
> 
> HOSTCFLAGS += -I$(objtree)/usr/include
> HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
> +HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
> +HOSTCFLAGS += -I$(srctree)/tools/perf
> 
> HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
> HOSTLOADLIBES_fds_example += -lelf


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 03:29:18PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Dec 15, 2016 at 12:50:22PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
> > > Now that libbpf under tools/lib/bpf/* is synced with the version from
> > > samples/bpf, we can get rid most of the libbpf library here.
> > > 
> > > Signed-off-by: Joe Stringer 
> > > Cc: Alexei Starovoitov 
> > > Cc: Daniel Borkmann 
> > > Cc: Wang Nan 
> > > Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
> > > [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, 
> > > as noticed by Wang Nan ]
> 
> So, the above comment no longer applied to this adjusted patch from you,
> as you removed one hunk too much, that, after applied, gets samples/bpf/
> to build successfully:
> 
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index add514e2984a..81b0ef2f7994 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -107,6 +107,7 @@ always += lwt_len_hist_kern.o
>  always += xdp_tx_iptunnel_kern.o
>  
>  HOSTCFLAGS += -I$(objtree)/usr/include
> +HOSTCFLAGS += -I$(srctree)/tools/lib/
>  HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
>  
>  HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
> 
> -
> 
> I added it, continuing...

But then, when I tried to run offwaketime with it, it fails:

[root@jouet bpf]# ./offwaketime  ls
bpf_load_program() err=22
BPF_LDX uses reserved fields
bpf_load_program() err=22
BPF_LDX uses reserved fields
[root@jouet bpf]# 

If I remove this patch and try again, it works:

[root@jouet bpf]# ./offwaketime | head -4
swapper/1;start_secondary;cpu_startup_entry;schedule_preempt_disabled;schedule;__schedule;-;---;;
 46
chrome;return_from_SYSCALL_64;do_syscall_64;exit_to_usermode_loop;schedule;__schedule;-;try_to_wake_up;do_futex;sys_futex;do_syscall_64;return_from_SYSCALL_64;;Chrome_ChildIOT
 1
firefox;entry_SYSCALL_64_fastpath;sys_poll;do_sys_poll;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;pollwake;__wake_up_common;__wake_up_sync_key;pipe_write;__vfs_write;vfs_write;sys_write;entry_SYSCALL_64_fastpath;;Timer
 3
dockerd-current;entry_SYSCALL_64_fastpath;sys_select;core_sys_select;do_select;poll_schedule_timeout;schedule_hrtimeout_range;schedule_hrtimeout_range_clock;schedule;__schedule;-;try_to_wake_up;futex_wake;do_futex;sys_futex;entry_SYSCALL_64_fastpath;;dockerd-current
 2
[root@jouet bpf]# 


So, I'm stopping here so that I can push what I have to Ingo, then I'll get
back to this, hopefully by then you beat me and I have just to retest 8-)

- Arnaldo



Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 03:34:40PM -0300, Arnaldo Carvalho de Melo escreveu:
> 
> So, I'm stopping here so that I can push what I have to Ingo, then I'll get
> back to this, hopefully by then you beat me and I have just to retest 8-)

Ah, I left what I have in the tmp.perf/samples-libbpf branch in my tree
at git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git.

I'll remove just the HEAD one and push the rest to Ingo.

- Arnaldo


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Joe Stringer
On 15 December 2016 at 07:50, Arnaldo Carvalho de Melo  wrote:
> Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
>> Now that libbpf under tools/lib/bpf/* is synced with the version from
>> samples/bpf, we can get rid most of the libbpf library here.
>>
>> Signed-off-by: Joe Stringer 
>> Cc: Alexei Starovoitov 
>> Cc: Daniel Borkmann 
>> Cc: Wang Nan 
>> Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
>> [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, as 
>> noticed by Wang Nan ]
>> Signed-off-by: Arnaldo Carvalho de Melo 
>
> So, right before this patch building samples/bpf works, then, after, it fails,
> investigating:
>
> [root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ headers_install
> make[1]: Entering directory '/tmp/build/linux'
>   CHK include/generated/uapi/linux/version.h
> make[1]: Leaving directory '/tmp/build/linux'
> [root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ samples/bpf/
> make[1]: Entering directory '/tmp/build/linux'
>   CHK include/config/kernel.release
>   GEN ./Makefile
>   CHK include/generated/uapi/linux/version.h
>   Using /git/linux as source for kernel
>   CHK include/generated/utsrelease.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/bounds.h
>   CHK include/generated/asm-offsets.h
>   CALL/git/linux/scripts/checksyscalls.sh
>   HOSTCC  samples/bpf/test_lru_dist.o
>   HOSTCC  samples/bpf/libbpf.o
>   HOSTCC  samples/bpf/sock_example.o
>   HOSTCC  samples/bpf/bpf_load.o
> In file included from /git/linux/samples/bpf/libbpf.c:12:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> In file included from /git/linux/samples/bpf/test_lru_dist.c:24:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/test_lru_dist.o] Error 1
> make[2]: *** Waiting for unfinished jobs
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/libbpf.o] Error 1
> In file included from /git/linux/samples/bpf/bpf_load.c:24:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/bpf_load.o] Error 1
> In file included from /git/linux/samples/bpf/sock_example.c:29:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/sock_example.o] Error 1
> make[1]: *** [/git/linux/Makefile:1659: samples/bpf/] Error 2
> make[1]: Leaving directory '/tmp/build/linux'
> make: *** [Makefile:150: sub-make] Error 2
> [root@1e797fdfbf4f linux]#

Sorry about that.

It looks like this fragment which ended up in "samples/bpf: Remove
perf_event_open() declaration" patch should be here instead:

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index add514e2984a..9718f664fedf 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -108,6 +108,8 @@ always += xdp_tx_iptunnel_kern.o

HOSTCFLAGS += -I$(objtree)/usr/include
HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
+HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
+HOSTCFLAGS += -I$(srctree)/tools/perf

HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
HOSTLOADLIBES_fds_example += -lelf


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Arnaldo Carvalho de Melo
Em Thu, Dec 15, 2016 at 12:50:22PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
> > Now that libbpf under tools/lib/bpf/* is synced with the version from
> > samples/bpf, we can get rid most of the libbpf library here.
> > 
> > Signed-off-by: Joe Stringer 
> > Cc: Alexei Starovoitov 
> > Cc: Daniel Borkmann 
> > Cc: Wang Nan 
> > Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
> > [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, as 
> > noticed by Wang Nan ]

So, the above comment no longer applied to this adjusted patch from you,
as you removed one hunk too much, that, after applied, gets samples/bpf/
to build successfully:

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index add514e2984a..81b0ef2f7994 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -107,6 +107,7 @@ always += lwt_len_hist_kern.o
 always += xdp_tx_iptunnel_kern.o
 
 HOSTCFLAGS += -I$(objtree)/usr/include
+HOSTCFLAGS += -I$(srctree)/tools/lib/
 HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
 
 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable

-

I added it, continuing...

- Arnaldo

> > Signed-off-by: Arnaldo Carvalho de Melo 
> 
> So, right before this patch building samples/bpf works, then, after, it fails,
> investigating:
> 
> [root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ headers_install
> make[1]: Entering directory '/tmp/build/linux'
>   CHK include/generated/uapi/linux/version.h
> make[1]: Leaving directory '/tmp/build/linux'
> [root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ samples/bpf/
> make[1]: Entering directory '/tmp/build/linux'
>   CHK include/config/kernel.release
>   GEN ./Makefile
>   CHK include/generated/uapi/linux/version.h
>   Using /git/linux as source for kernel
>   CHK include/generated/utsrelease.h
>   CHK include/generated/timeconst.h
>   CHK include/generated/bounds.h
>   CHK include/generated/asm-offsets.h
>   CALL/git/linux/scripts/checksyscalls.sh
>   HOSTCC  samples/bpf/test_lru_dist.o
>   HOSTCC  samples/bpf/libbpf.o
>   HOSTCC  samples/bpf/sock_example.o
>   HOSTCC  samples/bpf/bpf_load.o
> In file included from /git/linux/samples/bpf/libbpf.c:12:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> In file included from /git/linux/samples/bpf/test_lru_dist.c:24:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/test_lru_dist.o] Error 1
> make[2]: *** Waiting for unfinished jobs
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/libbpf.o] Error 1
> In file included from /git/linux/samples/bpf/bpf_load.c:24:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/bpf_load.o] Error 1
> In file included from /git/linux/samples/bpf/sock_example.c:29:0:
> /git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
> directory
>  #include 
>  ^
> compilation terminated.
> make[2]: *** [scripts/Makefile.host:124: samples/bpf/sock_example.o] Error 1
> make[1]: *** [/git/linux/Makefile:1659: samples/bpf/] Error 2
> make[1]: Leaving directory '/tmp/build/linux'
> make: *** [Makefile:150: sub-make] Error 2
> [root@1e797fdfbf4f linux]# 


Re: [PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-15 Thread Arnaldo Carvalho de Melo
Em Wed, Dec 14, 2016 at 02:43:39PM -0800, Joe Stringer escreveu:
> Now that libbpf under tools/lib/bpf/* is synced with the version from
> samples/bpf, we can get rid most of the libbpf library here.
> 
> Signed-off-by: Joe Stringer 
> Cc: Alexei Starovoitov 
> Cc: Daniel Borkmann 
> Cc: Wang Nan 
> Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
> [ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, as 
> noticed by Wang Nan ]
> Signed-off-by: Arnaldo Carvalho de Melo 

So, right before this patch building samples/bpf works, then, after, it fails,
investigating:

[root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ headers_install
make[1]: Entering directory '/tmp/build/linux'
  CHK include/generated/uapi/linux/version.h
make[1]: Leaving directory '/tmp/build/linux'
[root@1e797fdfbf4f linux]# make -j4 O=/tmp/build/linux/ samples/bpf/
make[1]: Entering directory '/tmp/build/linux'
  CHK include/config/kernel.release
  GEN ./Makefile
  CHK include/generated/uapi/linux/version.h
  Using /git/linux as source for kernel
  CHK include/generated/utsrelease.h
  CHK include/generated/timeconst.h
  CHK include/generated/bounds.h
  CHK include/generated/asm-offsets.h
  CALL/git/linux/scripts/checksyscalls.sh
  HOSTCC  samples/bpf/test_lru_dist.o
  HOSTCC  samples/bpf/libbpf.o
  HOSTCC  samples/bpf/sock_example.o
  HOSTCC  samples/bpf/bpf_load.o
In file included from /git/linux/samples/bpf/libbpf.c:12:0:
/git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
directory
 #include 
 ^
compilation terminated.
In file included from /git/linux/samples/bpf/test_lru_dist.c:24:0:
/git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
directory
 #include 
 ^
compilation terminated.
make[2]: *** [scripts/Makefile.host:124: samples/bpf/test_lru_dist.o] Error 1
make[2]: *** Waiting for unfinished jobs
make[2]: *** [scripts/Makefile.host:124: samples/bpf/libbpf.o] Error 1
In file included from /git/linux/samples/bpf/bpf_load.c:24:0:
/git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
directory
 #include 
 ^
compilation terminated.
make[2]: *** [scripts/Makefile.host:124: samples/bpf/bpf_load.o] Error 1
In file included from /git/linux/samples/bpf/sock_example.c:29:0:
/git/linux/samples/bpf/libbpf.h:5:21: fatal error: bpf/bpf.h: No such file or 
directory
 #include 
 ^
compilation terminated.
make[2]: *** [scripts/Makefile.host:124: samples/bpf/sock_example.o] Error 1
make[1]: *** [/git/linux/Makefile:1659: samples/bpf/] Error 2
make[1]: Leaving directory '/tmp/build/linux'
make: *** [Makefile:150: sub-make] Error 2
[root@1e797fdfbf4f linux]# 


[PATCH perf/core REBASE 2/5] samples/bpf: Switch over to libbpf

2016-12-14 Thread Joe Stringer
Now that libbpf under tools/lib/bpf/* is synced with the version from
samples/bpf, we can get rid most of the libbpf library here.

Signed-off-by: Joe Stringer 
Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Wang Nan 
Link: http://lkml.kernel.org/r/20161209024620.31660-6-...@ovn.org
[ Use -I$(srctree)/tools/lib/ to support out of source code tree builds, as 
noticed by Wang Nan ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 samples/bpf/Makefile   |  67 +++--
 samples/bpf/README.rst |   4 +-
 samples/bpf/libbpf.c   | 111 -
 samples/bpf/libbpf.h   |  19 +
 4 files changed, 39 insertions(+), 162 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index f2219c1489e5..add514e2984a 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -35,40 +35,43 @@ hostprogs-y += tc_l2_redirect
 hostprogs-y += lwt_len_hist
 hostprogs-y += xdp_tx_iptunnel
 
-test_lru_dist-objs := test_lru_dist.o libbpf.o
-sock_example-objs := sock_example.o libbpf.o
-fds_example-objs := bpf_load.o libbpf.o fds_example.o
-sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
-sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
-sockex3-objs := bpf_load.o libbpf.o sockex3_user.o
-tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
-tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
-tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
-tracex4-objs := bpf_load.o libbpf.o tracex4_user.o
-tracex5-objs := bpf_load.o libbpf.o tracex5_user.o
-tracex6-objs := bpf_load.o libbpf.o tracex6_user.o
-test_probe_write_user-objs := bpf_load.o libbpf.o test_probe_write_user_user.o
-trace_output-objs := bpf_load.o libbpf.o trace_output_user.o
-lathist-objs := bpf_load.o libbpf.o lathist_user.o
-offwaketime-objs := bpf_load.o libbpf.o offwaketime_user.o
-spintest-objs := bpf_load.o libbpf.o spintest_user.o
-map_perf_test-objs := bpf_load.o libbpf.o map_perf_test_user.o
-test_overhead-objs := bpf_load.o libbpf.o test_overhead_user.o
-test_cgrp2_array_pin-objs := libbpf.o test_cgrp2_array_pin.o
-test_cgrp2_attach-objs := libbpf.o test_cgrp2_attach.o
-test_cgrp2_attach2-objs := libbpf.o test_cgrp2_attach2.o cgroup_helpers.o
-test_cgrp2_sock-objs := libbpf.o test_cgrp2_sock.o
-test_cgrp2_sock2-objs := bpf_load.o libbpf.o test_cgrp2_sock2.o
-xdp1-objs := bpf_load.o libbpf.o xdp1_user.o
+# Libbpf dependencies
+LIBBPF := libbpf.o ../../tools/lib/bpf/bpf.o
+
+test_lru_dist-objs := test_lru_dist.o $(LIBBPF)
+sock_example-objs := sock_example.o $(LIBBPF)
+fds_example-objs := bpf_load.o $(LIBBPF) fds_example.o
+sockex1-objs := bpf_load.o $(LIBBPF) sockex1_user.o
+sockex2-objs := bpf_load.o $(LIBBPF) sockex2_user.o
+sockex3-objs := bpf_load.o $(LIBBPF) sockex3_user.o
+tracex1-objs := bpf_load.o $(LIBBPF) tracex1_user.o
+tracex2-objs := bpf_load.o $(LIBBPF) tracex2_user.o
+tracex3-objs := bpf_load.o $(LIBBPF) tracex3_user.o
+tracex4-objs := bpf_load.o $(LIBBPF) tracex4_user.o
+tracex5-objs := bpf_load.o $(LIBBPF) tracex5_user.o
+tracex6-objs := bpf_load.o $(LIBBPF) tracex6_user.o
+test_probe_write_user-objs := bpf_load.o $(LIBBPF) test_probe_write_user_user.o
+trace_output-objs := bpf_load.o $(LIBBPF) trace_output_user.o
+lathist-objs := bpf_load.o $(LIBBPF) lathist_user.o
+offwaketime-objs := bpf_load.o $(LIBBPF) offwaketime_user.o
+spintest-objs := bpf_load.o $(LIBBPF) spintest_user.o
+map_perf_test-objs := bpf_load.o $(LIBBPF) map_perf_test_user.o
+test_overhead-objs := bpf_load.o $(LIBBPF) test_overhead_user.o
+test_cgrp2_array_pin-objs := $(LIBBPF) test_cgrp2_array_pin.o
+test_cgrp2_attach-objs := $(LIBBPF) test_cgrp2_attach.o
+test_cgrp2_attach2-objs := $(LIBBPF) test_cgrp2_attach2.o cgroup_helpers.o
+test_cgrp2_sock-objs := $(LIBBPF) test_cgrp2_sock.o
+test_cgrp2_sock2-objs := bpf_load.o $(LIBBPF) test_cgrp2_sock2.o
+xdp1-objs := bpf_load.o $(LIBBPF) xdp1_user.o
 # reuse xdp1 source intentionally
-xdp2-objs := bpf_load.o libbpf.o xdp1_user.o
-test_current_task_under_cgroup-objs := bpf_load.o libbpf.o cgroup_helpers.o \
+xdp2-objs := bpf_load.o $(LIBBPF) xdp1_user.o
+test_current_task_under_cgroup-objs := bpf_load.o $(LIBBPF) cgroup_helpers.o \
   test_current_task_under_cgroup_user.o
-trace_event-objs := bpf_load.o libbpf.o trace_event_user.o
-sampleip-objs := bpf_load.o libbpf.o sampleip_user.o
-tc_l2_redirect-objs := bpf_load.o libbpf.o tc_l2_redirect_user.o
-lwt_len_hist-objs := bpf_load.o libbpf.o lwt_len_hist_user.o
-xdp_tx_iptunnel-objs := bpf_load.o libbpf.o xdp_tx_iptunnel_user.o
+trace_event-objs := bpf_load.o $(LIBBPF) trace_event_user.o
+sampleip-objs := bpf_load.o $(LIBBPF) sampleip_user.o
+tc_l2_redirect-objs := bpf_load.o $(LIBBPF) tc_l2_redirect_user.o
+lwt_len_hist-objs := bpf_load.o $(LIBBPF) lwt_len_hist_user.o
+xdp_tx_iptunnel-objs := bpf_load.o $(LIBBPF) xdp_tx_iptunnel_user.o
 
 # Tell kbuild to always build the programs
 always := $(hostprogs-y)
diff --git a/samples/bpf/README.rst b/samples/bpf/README.rst
in