Re: [PATCH 1/2] perf-bench: Add epoll parallel epoll_wait benchmark

From: Arnaldo Carvalho de Melo
Date: Thu Nov 08 2018 - 08:45:08 EST


Em Tue, Nov 06, 2018 at 04:13:25PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Nov 06, 2018 at 10:23:49AM -0800, Davidlohr Bueso escreveu:
> > Mind this fixlet for using et/oneshot and the multiq option.
>
> Yes sir, applied the fixup to the first patch in the series, applied the
> second, tested, merged.

So, one of these two is making the build to fail in all the Alpine Linux
(3.4 -- 3.8 and edge) and also on some others

On Alpine the error is:

CC /tmp/build/perf/bench/futex-lock-pi.o
CC /tmp/build/perf/bench/epoll-wait.o
bench/epoll-wait.c: In function 'do_threads':
bench/epoll-wait.c:345:10: error: implicit declaration of function 'pthread_attr_setaffinity_np' [-Werror=implicit-function-declaration]
ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cpu_set_t), &cpuset);
^
bench/epoll-wait.c:345:4: error: nested extern declaration of 'pthread_attr_setaffinity_np' [-Werror=nested-externs]
ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cpu_set_t), &cpuset);
^
bench/epoll-wait.c: In function 'bench_epoll_wait':
bench/epoll-wait.c:462:12: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'rlim_t {aka long long unsigned int}' [-Werror=format=]
printinfo("Setting RLIMIT_NOFILE rlimit from %lu to: %lu\n", prevrl.rlim_max, rl.rlim_max);
^
bench/epoll-wait.c:85:31: note: in definition of macro 'printinfo'
do { if (__verbose) { printf(fmt, ## arg); fflush(stdout); } } while (0)
^
bench/epoll-wait.c:462:12: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'rlim_t {aka long long unsigned int}' [-Werror=format=]
printinfo("Setting RLIMIT_NOFILE rlimit from %lu to: %lu\n", prevrl.rlim_max, rl.rlim_max);
^
bench/epoll-wait.c:85:31: note: in definition of macro 'printinfo'
do { if (__verbose) { printf(fmt, ## arg); fflush(stdout); } } while (0)
^
CC /tmp/build/perf/util/trace-event-info.o
CC /tmp/build/perf/perf.o
cc1: all warnings being treated as errors
mv: can't rename '/tmp/build/perf/bench/.epoll-wait.o.tmp': No such file or directory
/git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/bench/epoll-wait.o' failed
make[4]: *** [/tmp/build/perf/bench/epoll-wait.o] Error 1
/git/linux/tools/build/Makefile.build:139: recipe for target 'bench' failed
make[3]: *** [bench] Error 2
make[3]: *** Waiting for unfinished jobs....
CC /tmp/build/perf/util/trace-event-scripting.o


On AmazonLinux 1 and 2, oops, these are mine:

LINK /tmp/build/perf/perf
/tmp/build/perf/perf-in.o: In function `bpf_map__set_filter_pids':
/git/linux/tools/perf/builtin-trace.c:2573: undefined reference to `bpf_map(float, double)'
/tmp/build/perf/perf-in.o: In function `cmd_trace':
(.text+0x4c71e): undefined reference to `bpf_map_update_elem'
/tmp/build/perf/perf-in.o: In function `cmd_trace':
(.text+0x4cab6): undefined reference to `bpf_map(float, double)'
/tmp/build/perf/perf-in.o: In function `cmd_trace':
(.text+0x4cae8): undefined reference to `bpf_map_update_elem'
collect2: error: ld returned 1 exit status
make[2]: *** [/tmp/build/perf/perf] Error 1
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/git/linux/tools/perf'
[root@seventh ~]#

I need to do that conditionally, i.e. it seems libbpf is not being built
in that distro...

centos:5 is about perf bench:

CC /tmp/build/perf/bench/epoll-wait.o
bench/epoll-wait.c:74:25: error: sys/eventfd.h: No such file or directory
cc1: warnings being treated as errors
bench/epoll-wait.c: In function 'do_threads':
bench/epoll-wait.c:328: warning: implicit declaration of function 'eventfd'
bench/epoll-wait.c:328: warning: nested extern declaration of 'eventfd'
bench/epoll-wait.c:328: error: 'EFD_NONBLOCK' undeclared (first use in this function)
bench/epoll-wait.c:328: error: (Each undeclared identifier is reported only once
bench/epoll-wait.c:328: error: for each function it appears in.)
mv: cannot stat `/tmp/build/perf/bench/.epoll-wait.o.tmp': No such file or directory
make[4]: *** [/tmp/build/perf/bench/epoll-wait.o] Error 1
make[3]: *** [bench] Error 2
make[3]: *** Waiting for unfinished jobs....
MKDIR /tmp/build/perf/tests/


centos:6 and 7 are ok with perf bench, not so much with my bpf changes :-\

LINK /tmp/build/perf/libperf-gtk.so
/tmp/build/perf/perf-in.o: In function `bpf_map__set_filter_pids':
/git/linux/tools/perf/builtin-trace.c:2573: undefined reference to `bpf_map(float, double)'
/git/linux/tools/perf/builtin-trace.c:2577: undefined reference to `bpf_map_update_elem'
/git/linux/tools/perf/builtin-trace.c:2573: undefined reference to `bpf_map(float, double)'
/git/linux/tools/perf/builtin-trace.c:2577: undefined reference to `bpf_map_update_elem'
collect2: ld returned 1 exit status
make[2]: *** [/tmp/build/perf/perf] Error 1
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/git/linux/tools/perf'
[root@seventh ~]#
[root@seventh ~]#

- Arnaldo

> - Arnaldo
>
> > diff --git a/tools/perf/bench/epoll-wait.c b/tools/perf/bench/epoll-wait.c
> > index c4c5ef60feb4..4e4efc5cfe22 100644
> > --- a/tools/perf/bench/epoll-wait.c
> > +++ b/tools/perf/bench/epoll-wait.c
> > @@ -215,13 +215,13 @@ static void *workerfn(void *arg)
> >
> > if (et) {
> > ev.events = EPOLLIN | EPOLLET;
> > - ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev);
> > + ret = epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ev);
> > }
> >
> > if (oneshot) {
> > /* rearm the file descriptor with a new event mask */
> > ev.events |= EPOLLIN | EPOLLONESHOT;
> > - ret = epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, &ev);
> > + ret = epoll_ctl(efd, EPOLL_CTL_MOD, fd, &ev);
> > }
> >
> > ops++;
> > @@ -249,7 +249,7 @@ static void nest_epollfd(struct worker *w)
> >
> > for (i = 0; i < nested; i++) {
> > epollfdp[i] = epoll_create(1);
> > - if (epollfd < 0)
> > + if (epollfdp[i] < 0)
> > err(EXIT_FAILURE, "epoll_create");
> > }
> >