Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-27 Thread Jiri Olsa
On Mon, Aug 26, 2019 at 07:41:36PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Aug 26, 2019 at 07:14:19PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, Aug 26, 2019 at 06:58:52PM +0200, Jiri Olsa escreveu:
> > > On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > > 
> > > SNIP
> > > 
> > > > [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' 
> > > > /tmp/build/perf/builtin-sched.i
> > > >  printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, 
> > > > sample->cpu);
> > > > [perfbuilder@490c2c7bdaab ~]$
> > > > 
> > > > And if we do this on a fedora:30 x86_64:
> > > > 
> > > > $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> > > > [acme@quaco perf]$ grep -A4 'printf("lost' 
> > > > /tmp/build/perf/builtin-sched.i
> > > >  printf("lost %" "l" 
> > > > # 2646 "builtin-sched.c" 3 4
> > > > "l" "u" 
> > > > # 2646 "builtin-sched.c"
> > > >  " events on cpu %d\n", event->lost.lost, 
> > > > sample->cpu);
> > > > [acme@quaco perf]$
> > > > 
> > > > I.e. on 32-bit arches we shouldn't add that extra "l", right?
> > > 
> > > hum, I guess we could #ifdef it 64/32 bits
> > 
> > I tried to figure out how to fix this better, but the int-ll64.h versus
> > int-l64.h versus how __u64 is defined got me confused and I ended up
> > with:
> > 
> > #if __WORDSIZE == 64
> 
> Make that:
> 
> #ifdef __LP64__ to build on Alpine/musl libc.

awesome, thanks ;-)

jirka


Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Arnaldo Carvalho de Melo
Em Mon, Aug 26, 2019 at 07:14:19PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Aug 26, 2019 at 06:58:52PM +0200, Jiri Olsa escreveu:
> > On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > 
> > SNIP
> > 
> > > [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' 
> > > /tmp/build/perf/builtin-sched.i
> > >  printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, 
> > > sample->cpu);
> > > [perfbuilder@490c2c7bdaab ~]$
> > > 
> > > And if we do this on a fedora:30 x86_64:
> > > 
> > > $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> > > [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
> > >  printf("lost %" "l" 
> > > # 2646 "builtin-sched.c" 3 4
> > > "l" "u" 
> > > # 2646 "builtin-sched.c"
> > >  " events on cpu %d\n", event->lost.lost, 
> > > sample->cpu);
> > > [acme@quaco perf]$
> > > 
> > > I.e. on 32-bit arches we shouldn't add that extra "l", right?
> > 
> > hum, I guess we could #ifdef it 64/32 bits
> 
> I tried to figure out how to fix this better, but the int-ll64.h versus
> int-l64.h versus how __u64 is defined got me confused and I ended up
> with:
> 
> #if __WORDSIZE == 64

Make that:

#ifdef __LP64__ to build on Alpine/musl libc.

- Arnaldo

> /*
>  * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining
>  * __u64 as long long unsigned int, and then -Werror=format= kicks in and
>  * complains of the mismatched types, so use these two special extra PRI
>  * macros to overcome that.
>  */
> #define PRI_lu64 "l" PRIu64
> #define PRI_lx64 "l" PRIx64
> #else
> #define PRI_lu64 PRIu64
> #define PRI_lx64 PRIx64
> #endif
> 
> Builds in all the containers I have, 32-bit, 64-bit, old gccs/clangs,
> new ones, uclibc, musl libc, glibc, etc
>  
> > > 
> > > I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
> > > both failed:
> > > 
> > > 
> >> [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> >> dm.log/debian\:experimental-x-mips
> > > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> > > format [-Werror=format=]
> > >   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> > > sample->cpu);
> > >  ^~~~
> > > In file included from builtin-sched.c:31:
> > > /usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is 
> > > defined here
> > >  #  define __PRI64_PREFIX "ll"
> > > ^
> > > [root@quaco ~]#
> > > 
> > > [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> > > dm.log/debian\:experimental-x-mipsel
> > > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> > > format [-Werror=format=]
> > >   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> > > sample->cpu);
> > >  ^~~~
> > > In file included from builtin-sched.c:31:
> > > /usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is 
> > > defined here
> > >  #  define __PRI64_PREFIX "ll"
> > > ^
> > > [root@quaco ~]#
> > > 
> > > And also on a uclibc ARC arch container:
> > > 
> > > [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> > > dm.log/fedora\:24-x-ARC-uClibc
> > > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> > > format [-Werror=format=]
> > >   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> > > sample->cpu);
> > >  ^~~~
> > > In file included from builtin-sched.c:31:0:
> > > /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28:
> > >  note: format string is defined here
> > >  #  define __PRI64_PREFIX "ll"
> > > ^
> > > [root@quaco ~]#
> > > 
> > > The _fix_ will come after lunch :)
> > 
> > thanks ;-)
> > 
> > jirka
> 
> -- 
> 
> - Arnaldo

-- 

- Arnaldo


Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Arnaldo Carvalho de Melo
Em Mon, Aug 26, 2019 at 06:58:52PM +0200, Jiri Olsa escreveu:
> On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> 
> SNIP
> 
> > [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' 
> > /tmp/build/perf/builtin-sched.i
> >  printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, 
> > sample->cpu);
> > [perfbuilder@490c2c7bdaab ~]$
> > 
> > And if we do this on a fedora:30 x86_64:
> > 
> > $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> > [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
> >  printf("lost %" "l" 
> > # 2646 "builtin-sched.c" 3 4
> > "l" "u" 
> > # 2646 "builtin-sched.c"
> >  " events on cpu %d\n", event->lost.lost, 
> > sample->cpu);
> > [acme@quaco perf]$
> > 
> > I.e. on 32-bit arches we shouldn't add that extra "l", right?
> 
> hum, I guess we could #ifdef it 64/32 bits

I tried to figure out how to fix this better, but the int-ll64.h versus
int-l64.h versus how __u64 is defined got me confused and I ended up
with:

#if __WORDSIZE == 64
/*
 * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining
 * __u64 as long long unsigned int, and then -Werror=format= kicks in and
 * complains of the mismatched types, so use these two special extra PRI
 * macros to overcome that.
 */
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
#else
#define PRI_lu64 PRIu64
#define PRI_lx64 PRIx64
#endif

Builds in all the containers I have, 32-bit, 64-bit, old gccs/clangs,
new ones, uclibc, musl libc, glibc, etc
 
> > 
> > I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
> > both failed:
> > 
> > 
>> [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
>> dm.log/debian\:experimental-x-mips
> > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> > format [-Werror=format=]
> >   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> > sample->cpu);
> >  ^~~~
> > In file included from builtin-sched.c:31:
> > /usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is 
> > defined here
> >  #  define __PRI64_PREFIX "ll"
> > ^
> > [root@quaco ~]#
> > 
> > [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> > dm.log/debian\:experimental-x-mipsel
> > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> > format [-Werror=format=]
> >   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> > sample->cpu);
> >  ^~~~
> > In file included from builtin-sched.c:31:
> > /usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is 
> > defined here
> >  #  define __PRI64_PREFIX "ll"
> > ^
> > [root@quaco ~]#
> > 
> > And also on a uclibc ARC arch container:
> > 
> > [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> > dm.log/fedora\:24-x-ARC-uClibc
> > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> > format [-Werror=format=]
> >   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> > sample->cpu);
> >  ^~~~
> > In file included from builtin-sched.c:31:0:
> > /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28:
> >  note: format string is defined here
> >  #  define __PRI64_PREFIX "ll"
> > ^
> > [root@quaco ~]#
> > 
> > The _fix_ will come after lunch :)
> 
> thanks ;-)
> 
> jirka

-- 

- Arnaldo


Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Arnaldo Carvalho de Melo
Em Mon, Aug 26, 2019 at 06:47:34PM +0200, Jiri Olsa escreveu:
> On Mon, Aug 26, 2019 at 12:41:38PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> > > hi,
> > > as a preparation for sampling libperf interface, moving event
> > > definitions into the library header. Moving just the kernel 
> > > non-AUX events now.
> > > 
> > > In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> > > types used events to their generic '__u*' versions.
> > > 
> > > Perf added 'u*' types mainly to ease up printing __u64 values
> > > as stated in the linux/types.h comment:
> > > 
> > >   /*
> > >* We define u64 as uint64_t for every architecture
> > >* so that we can print it with "%"PRIx64 without getting warnings.
> > >*
> > >* typedef __u64 u64;
> > >* typedef __s64 s64;
> > >*/
> > > 
> > > Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> > > that.  Using extra '_' to ease up the reading and differentiate
> > > them from standard PRI*64 macros.
> > 
> > I think we should take advantage of this moment to rename those structs
> > to have the 'perf_record_' prefix on them, I guess we could even remove
> > the _event from them, i.e.:
> > 
> > 'struct mmap_event' becomes 'perf_record_mmap', as it is the description
> > for the PERF_RECORD_MMAP meta-data event, are you ok with that?
> 
> hum, not sure about loosing the '_event' here, but we are
> not public yet, so we can always change back ;-) I do like
> it'd follow the enum name

So I'm making the already exported to libperf to be renamed to have the
same name as the PERF_RECORD_ enum they map to, just all lowercase.

Looks nice and also makes something exported by libperf to have a perf_
namespace prefix.

BTW: you forgot to move PERF_RECORD_CONTEXT_SWITCH :-)

> > I can go ahead and do it myself, updating each patch on this series to
> > do that.
> 
> sure, I thought we'd do it later, but feel free to do it,
> maybe in separate changes?

I did it as a separate patch, one patch for all the PERF_RECORD_ already
moved to libperf.

Also some other minor stuff, like having that
perf_event.{bpf,ksymbol}_event renamed to play perf_event.{bpf,ksymbol},
like the other records. so to make this idiom more compact and less
redundant:

event->bpf_event

becomes:

event->bpf

ditto for ksymbol_event.

- Arnaldo


Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Jiri Olsa
On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

> [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' 
> /tmp/build/perf/builtin-sched.i
>  printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, 
> sample->cpu);
> [perfbuilder@490c2c7bdaab ~]$
> 
> And if we do this on a fedora:30 x86_64:
> 
> $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
>  printf("lost %" "l" 
> # 2646 "builtin-sched.c" 3 4
> "l" "u" 
> # 2646 "builtin-sched.c"
>  " events on cpu %d\n", event->lost.lost, 
> sample->cpu);
> [acme@quaco perf]$
> 
> I.e. on 32-bit arches we shouldn't add that extra "l", right?

hum, I guess we could #ifdef it 64/32 bits

> 
> I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
> both failed:
> 
> 
> [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> dm.log/debian\:experimental-x-mips
> builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> format [-Werror=format=]
>   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> sample->cpu);
>  ^~~~
> In file included from builtin-sched.c:31:
> /usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is defined 
> here
>  #  define __PRI64_PREFIX "ll"
> ^
> [root@quaco ~]#
> 
> [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> dm.log/debian\:experimental-x-mipsel
> builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> format [-Werror=format=]
>   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> sample->cpu);
>  ^~~~
> In file included from builtin-sched.c:31:
> /usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is 
> defined here
>  #  define __PRI64_PREFIX "ll"
> ^
> [root@quaco ~]#
> 
> And also on a uclibc ARC arch container:
> 
> [root@quaco ~]# grep -m1 -A6 -- -Werror=format=  
> dm.log/fedora\:24-x-ARC-uClibc
> builtin-sched.c:2646:9: error: unknown conversion type character 'l' in 
> format [-Werror=format=]
>   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> sample->cpu);
>  ^~~~
> In file included from builtin-sched.c:31:0:
> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28:
>  note: format string is defined here
>  #  define __PRI64_PREFIX "ll"
> ^
> [root@quaco ~]#
> 
> The _fix_ will come after lunch :)

thanks ;-)

jirka


Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Jiri Olsa
On Mon, Aug 26, 2019 at 12:41:38PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> > hi,
> > as a preparation for sampling libperf interface, moving event
> > definitions into the library header. Moving just the kernel 
> > non-AUX events now.
> > 
> > In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> > types used events to their generic '__u*' versions.
> > 
> > Perf added 'u*' types mainly to ease up printing __u64 values
> > as stated in the linux/types.h comment:
> > 
> >   /*
> >* We define u64 as uint64_t for every architecture
> >* so that we can print it with "%"PRIx64 without getting warnings.
> >*
> >* typedef __u64 u64;
> >* typedef __s64 s64;
> >*/
> > 
> > Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> > that.  Using extra '_' to ease up the reading and differentiate
> > them from standard PRI*64 macros.
> 
> I think we should take advantage of this moment to rename those structs
> to have the 'perf_record_' prefix on them, I guess we could even remove
> the _event from them, i.e.:
> 
> 'struct mmap_event' becomes 'perf_record_mmap', as it is the description
> for the PERF_RECORD_MMAP meta-data event, are you ok with that?

hum, not sure about loosing the '_event' here, but we are
not public yet, so we can always change back ;-) I do like
it'd follow the enum name

> I can go ahead and do it myself, updating each patch on this series to
> do that.

sure, I thought we'd do it later, but feel free to do it,
maybe in separate changes?

thanks,
jirka


Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Arnaldo Carvalho de Melo
Em Mon, Aug 26, 2019 at 01:06:28PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> > hi,
> > as a preparation for sampling libperf interface, moving event
> > definitions into the library header. Moving just the kernel 
> > non-AUX events now.
> > 
> > In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> > types used events to their generic '__u*' versions.
> > 
> > Perf added 'u*' types mainly to ease up printing __u64 values
> > as stated in the linux/types.h comment:
> > 
> >   /*
> >* We define u64 as uint64_t for every architecture
> >* so that we can print it with "%"PRIx64 without getting warnings.
> >*
> >* typedef __u64 u64;
> >* typedef __s64 s64;
> >*/
> > 
> > Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> > that.  Using extra '_' to ease up the reading and differentiate
> > them from standard PRI*64 macros.
> 
> So, this is not building on android env:
> 
> builtin-sched.c: In function 'process_lost':
> builtin-sched.c:2646:2: error: unknown conversion type character 'l' in 
> format [-Werror=format=]
>   printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
> sample->cpu);
>   ^
> builtin-sched.c:2646:2: error: format '%d' expects argument of type 'int', 
> but argument 2 has type '__u64' [-Werror=format=]
> builtin-sched.c:2646:2: error: too many arguments for format 
> [-Werror=format-extra-args]
>   MKDIR/tmp/build/perf/util/
> 
> 
> [perfbuilder@490c2c7bdaab ~]$ 
> /opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
>  -v
> Using built-in specs.
> COLLECT_GCC=/opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
> COLLECT_LTO_WRAPPER=/opt/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
> Target: arm-linux-androideabi
> Configured with: 
> /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure
>  --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 
> --target=arm-linux-androideabi --host=x86_64-linux-gnu 
> --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ 
> --with-gmp=/buildbot/tmp/build/toolchain/temp-install 
> --with-mpfr=/buildbot/tmp/build/toolchain/temp-install 
> --with-mpc=/buildbot/tmp/build/toolchain/temp-install 
> --with-cloog=/buildbot/tmp/build/toolchain/temp-install 
> --with-isl=/buildbot/tmp/build/toolchain/temp-install 
> --with-ppl=/buildbot/tmp/build/toolchain/temp-install 
> --disable-ppl-version-check --disable-cloog-version-check 
> --disable-isl-version-check --enable-cloog-backend=isl 
> --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' 
> --disable-libssp --enable-threads --disable-nls --disable-libmudflap 
> --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions 
> --disable-shared --disable-tls --disable-libitm --with-float=soft 
> --with-fpu=vfp --with-arch=armv5te --enable-target-optspace 
> --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array 
> --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 
> --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot 
> --with-binutils-version=2.25 --with-mpfr-version=3.1.1 
> --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 
> --with-gdb-version=none 
> --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x
>  --with-bugurl=http://source.android.com/source/report-bugs.html 
> --enable-languages=c,c++ --disable-bootstrap --enable-plugins 
> --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer 
> --enable-gold --enable-threads --enable-eh-frame-hdr-for-static 
> --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 
> --with-arch=armv5te --program-transform-name='s&^&' 
> --enable-gold=default
> Thread model: posix
> gcc version 4.9.x 20150123 (prerelease) (GCC)
> [perfbuilder@490c2c7bdaab ~]$
> 
> It doesn't build on the r15b as well.
> 
> I'll investigate after lunch.

$ make $EXTRA_MAKE_ARGS ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE 
EXTRA_CFLAGS="$EXTRA_CFLAGS" -C /git/perf/tools/perf O=/tmp/build/perf 
/tmp/build/perf/builtin-sched.i

We end up with one 'l' too many?

[perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' 
/tmp/build/perf/builtin-sched.i
 printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, 
sample->cpu);
[perfbuilder@490c2c7bdaab ~]$

And if we do this on a fedora:30 x86_64:

$ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
[acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
 printf("lost %" "l" 
# 2646 "builtin-sched.c" 3 4
"l" "u" 
# 2646 "builtin-sched.c"
 " events on cpu %d\n", event->lost.lost, sample->cpu);
[acme@quaco perf]$

I.e. on 32-bit arches we shouldn't 

Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Arnaldo Carvalho de Melo
Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> hi,
> as a preparation for sampling libperf interface, moving event
> definitions into the library header. Moving just the kernel 
> non-AUX events now.
> 
> In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> types used events to their generic '__u*' versions.
> 
> Perf added 'u*' types mainly to ease up printing __u64 values
> as stated in the linux/types.h comment:
> 
>   /*
>* We define u64 as uint64_t for every architecture
>* so that we can print it with "%"PRIx64 without getting warnings.
>*
>* typedef __u64 u64;
>* typedef __s64 s64;
>*/
> 
> Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> that.  Using extra '_' to ease up the reading and differentiate
> them from standard PRI*64 macros.

So, this is not building on android env:

builtin-sched.c: In function 'process_lost':
builtin-sched.c:2646:2: error: unknown conversion type character 'l' in format 
[-Werror=format=]
  printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, 
sample->cpu);
  ^
builtin-sched.c:2646:2: error: format '%d' expects argument of type 'int', but 
argument 2 has type '__u64' [-Werror=format=]
builtin-sched.c:2646:2: error: too many arguments for format 
[-Werror=format-extra-args]
  MKDIR/tmp/build/perf/util/


[perfbuilder@490c2c7bdaab ~]$ 
/opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
 -v
Using built-in specs.
COLLECT_GCC=/opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=/opt/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
Target: arm-linux-androideabi
Configured with: 
/usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure
 --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi 
--host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld 
--enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install 
--with-mpfr=/buildbot/tmp/build/toolchain/temp-install 
--with-mpc=/buildbot/tmp/build/toolchain/temp-install 
--with-cloog=/buildbot/tmp/build/toolchain/temp-install 
--with-isl=/buildbot/tmp/build/toolchain/temp-install 
--with-ppl=/buildbot/tmp/build/toolchain/temp-install 
--disable-ppl-version-check --disable-cloog-version-check 
--disable-isl-version-check --enable-cloog-backend=isl 
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' 
--disable-libssp --enable-threads --disable-nls --disable-libmudflap 
--disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions 
--disable-shared --disable-tls --disable-libitm --with-float=soft 
--with-fpu=vfp --with-arch=armv5te --enable-target-optspace 
--enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array 
--disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 
--with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot 
--with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 
--with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none 
--with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x 
--with-bugurl=http://source.android.com/source/report-bugs.html 
--enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp 
--enable-gnu-indirect-function --disable-libsanitizer --enable-gold 
--enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes 
--with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te 
--program-transform-name='s&^&' --enable-gold=default
Thread model: posix
gcc version 4.9.x 20150123 (prerelease) (GCC)
[perfbuilder@490c2c7bdaab ~]$

It doesn't build on the r15b as well.

I'll investigate after lunch.

- Arnaldo
 
> It's also available in here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/fixes
> 
> thanks,
> jirka
> 
> 
> ---
> Jiri Olsa (12):
>   libperf: Add mmap_event to perf/event.h
>   libperf: Add mmap2_event to perf/event.h
>   libperf: Add comm_event to perf/event.h
>   libperf: Add namespaces_event to perf/event.h
>   libperf: Add fork_event to perf/event.h
>   libperf: Add lost_event to perf/event.h
>   libperf: Add lost_samples_event to perf/event.h
>   libperf: Add read_event to perf/event.h
>   libperf: Add throttle_event to perf/event.h
>   libperf: Add ksymbol_event to perf/event.h
>   libperf: Add bpf_event to perf/event.h
>   libperf: Add sample_event to perf/event.h
> 
>  tools/perf/builtin-sched.c  |   2 +-
>  tools/perf/lib/include/perf/event.h | 112 
> 
>  tools/perf/util/event.c |  12 ++--
>  tools/perf/util/event.h  

Re: [PATCH 00/12] libperf: Add events to perf/event.h

2019-08-26 Thread Arnaldo Carvalho de Melo
Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> hi,
> as a preparation for sampling libperf interface, moving event
> definitions into the library header. Moving just the kernel 
> non-AUX events now.
> 
> In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> types used events to their generic '__u*' versions.
> 
> Perf added 'u*' types mainly to ease up printing __u64 values
> as stated in the linux/types.h comment:
> 
>   /*
>* We define u64 as uint64_t for every architecture
>* so that we can print it with "%"PRIx64 without getting warnings.
>*
>* typedef __u64 u64;
>* typedef __s64 s64;
>*/
> 
> Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> that.  Using extra '_' to ease up the reading and differentiate
> them from standard PRI*64 macros.

I think we should take advantage of this moment to rename those structs
to have the 'perf_record_' prefix on them, I guess we could even remove
the _event from them, i.e.:

'struct mmap_event' becomes 'perf_record_mmap', as it is the description
for the PERF_RECORD_MMAP meta-data event, are you ok with that?

I can go ahead and do it myself, updating each patch on this series to
do that.

- Arnaldo
 
> It's also available in here:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/fixes
> 
> thanks,
> jirka
> 
> 
> ---
> Jiri Olsa (12):
>   libperf: Add mmap_event to perf/event.h
>   libperf: Add mmap2_event to perf/event.h
>   libperf: Add comm_event to perf/event.h
>   libperf: Add namespaces_event to perf/event.h
>   libperf: Add fork_event to perf/event.h
>   libperf: Add lost_event to perf/event.h
>   libperf: Add lost_samples_event to perf/event.h
>   libperf: Add read_event to perf/event.h
>   libperf: Add throttle_event to perf/event.h
>   libperf: Add ksymbol_event to perf/event.h
>   libperf: Add bpf_event to perf/event.h
>   libperf: Add sample_event to perf/event.h
> 
>  tools/perf/builtin-sched.c  |   2 +-
>  tools/perf/lib/include/perf/event.h | 112 
> 
>  tools/perf/util/event.c |  12 ++--
>  tools/perf/util/event.h | 104 
> +++-
>  tools/perf/util/evlist.c|   2 +-
>  tools/perf/util/evsel.c |   8 
>  tools/perf/util/machine.c   |   4 ++--
>  tools/perf/util/python.c|  14 +++---
>  tools/perf/util/session.c   |   8 
>  9 files changed, 140 insertions(+), 126 deletions(-)
>  create mode 100644 tools/perf/lib/include/perf/event.h

-- 

- Arnaldo


[PATCH 00/12] libperf: Add events to perf/event.h

2019-08-25 Thread Jiri Olsa
hi,
as a preparation for sampling libperf interface, moving event
definitions into the library header. Moving just the kernel 
non-AUX events now.

In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.

Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:

  /*
   * We define u64 as uint64_t for every architecture
   * so that we can print it with "%"PRIx64 without getting warnings.
   *
   * typedef __u64 u64;
   * typedef __s64 s64;
   */

Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that.  Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.

It's also available in here:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/fixes

thanks,
jirka


---
Jiri Olsa (12):
  libperf: Add mmap_event to perf/event.h
  libperf: Add mmap2_event to perf/event.h
  libperf: Add comm_event to perf/event.h
  libperf: Add namespaces_event to perf/event.h
  libperf: Add fork_event to perf/event.h
  libperf: Add lost_event to perf/event.h
  libperf: Add lost_samples_event to perf/event.h
  libperf: Add read_event to perf/event.h
  libperf: Add throttle_event to perf/event.h
  libperf: Add ksymbol_event to perf/event.h
  libperf: Add bpf_event to perf/event.h
  libperf: Add sample_event to perf/event.h

 tools/perf/builtin-sched.c  |   2 +-
 tools/perf/lib/include/perf/event.h | 112 

 tools/perf/util/event.c |  12 ++--
 tools/perf/util/event.h | 104 
+++-
 tools/perf/util/evlist.c|   2 +-
 tools/perf/util/evsel.c |   8 
 tools/perf/util/machine.c   |   4 ++--
 tools/perf/util/python.c|  14 +++---
 tools/perf/util/session.c   |   8 
 9 files changed, 140 insertions(+), 126 deletions(-)
 create mode 100644 tools/perf/lib/include/perf/event.h