[PATCH] perf tools: Work around lack of sched_getcpu in glibc < 2.6.

From: Vinson Lee
Date: Mon Mar 23 2015 - 15:09:16 EST


This patch fixes this build error with glibc < 2.6.

CC util/cloexec.o
cc1: warnings being treated as errors
util/cloexec.c: In function _perf_flag_probe_:
util/cloexec.c:24: error: implicit declaration of function
_sched_getcpu_
util/cloexec.c:24: error: nested extern declaration of _sched_getcpu_
make: *** [util/cloexec.o] Error 1

Signed-off-by: Vinson Lee <vlee@xxxxxxxxxxx>
Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@xxxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Yann Droneaud <ydroneaud@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # 3.18+
Link: http://lkml.kernel.org/r/1427137761-16119-1-git-send-email-vlee@xxxxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>


# git log --oneline e1e455f
e1e455f perf tools: Work around lack of sched_getcpu in glibc < 2.6.
77cfe38 perf kmem: Print big numbers using thousands' group
929a6bb tools lib traceevent: Factor out allocating and processing args
e6d7c91 perf probe: Fix to get ummapped symbol address on kernel
228f14f perf tools: Remove (null) value of "Sort order" for perf mem report
2c7da8c perf annotate: Allow annotation for decompressed kernel modules
bc84f46 perf tools: Try to lookup kernel module map before creating one
907fb50 perf tools: Remove is_kmodule_extension function
e746b3e perf tools: Remove compressed argument from is_kernel_module
8dee9ff perf tools: Use kmod_path__parse in is_kernel_module

To further verify if the problem is because of e1e455f commit, I did roll back to e1e455f
and its parent 77cfe38. I see this problem on more than one system.

# rpm -qa | grep glibc-2
glibc-2.17-55.el7.x86_64


git reset --hard e1e455f

# Running 'numa/mem' benchmark:

# Running main, "perf bench numa numa-mem --no-data_rand_walk -p 1 -t 64 -G 0 -P 0 -T 32 -l 800 -zZ0c"
#
#

###
# 64 tasks will execute (on 4 nodes, 64 CPUs):
# 800x 0MB global shared mem operations
# 800x 0MB process shared mem operations
# 800x 32MB thread local mem operations
###

###
#
# Startup synchronization: ... threads initialized in 0.512908 seconds.
#
# 0.1% [0.0 mins] 0/0 0/0 0/0 0/0 [ 0/0 ] l: -1-0 ( 1) {0-0}
# 0.6% [0.0 mins] 0/0 0/0 0/0 0/0 [ 0/0 ] l: -1-0 ( 1) {0-0}
# 5.1% [0.0 mins] 0/0 0/0 0/0 0/0 [ 0/0 ] l: -1-0 ( 1) {0-0}
# 9.6% [0.1 mins] 0/0 0/0 0/0 0/0 [ 0/0 ] l: -1-0 ( 1) {0-0}
# 14.0% [0.1 mins] 0/0 0/0 0/0 0/0 [ 0/0 ] l: -1-0 ( 1) {0-0}

###

4.903 secs slowest (max) thread-runtime
4.873 secs fastest (min) thread-runtime
4.941 secs average thread-runtime
0.301 % difference between max/avg runtime
4.228 GB data processed, per thread
270.583 GB data processed, total
1.160 nsecs/byte/thread runtime
0.862 GB/sec/thread speed
55.193 GB/sec total speed

and its parent 77cfe38
# git reset --hard 77cfe38

# Running 'numa/mem' benchmark:


# Running main, "perf bench numa numa-mem --no-data_rand_walk -p 1 -t 64 -G 0 -P 0 -T 32 -l 800 -zZ0c"
#
#

###
# 64 tasks will execute (on 4 nodes, 64 CPUs):
# 800x 0MB global shared mem operations
# 800x 0MB process shared mem operations
# 800x 32MB thread local mem operations
###

###
#
# Startup synchronization: ... threads initialized in 0.421336 seconds.
#
# 0.4% [0.0 mins] 16/1 16/1 16/1 16/1 [ 0/4 ] l: 1-20 ( 19) [95.0%] {4-4}
# 2.6% [0.0 mins] 17/1 15/1 16/1 16/1 [ 2/4 ] l: 3-37 ( 34) [91.9%] {4-4}
# 7.1% [0.0 mins] 17/1 15/1 16/1 16/1 [ 2/4 ] l: 32-67 ( 35) [52.2%] {4-4}
# 11.8% [0.1 mins] 17/1 15/1 16/1 16/1 [ 2/4 ] l: 65-103 ( 38) [36.9%] {4-4}
# 15.9% [0.1 mins] 17/1 15/1 16/1 16/1 [ 2/4 ] l: 98-136 ( 38) [27.9%] {4-4}

###

4.970 secs slowest (max) thread-runtime
4.940 secs fastest (min) thread-runtime
4.980 secs average thread-runtime
0.300 % difference between max/avg runtime
4.237 GB data processed, per thread
271.187 GB data processed, total
1.173 nsecs/byte/thread runtime
0.853 GB/sec/thread speed
54.562 GB/sec total speed


Even reverting e1e455f on top of tip/master seems to avoid the problem.
The below patch fixes the problem.

--
Thanks and Regards
Srikar Dronamraju

---->8--------------------------------------------