Skip to content

Commit

Permalink
build perf with support for bpf (#117)
Browse files Browse the repository at this point in the history
* build perf with support for bpf

* put perf build in its own Dockerfile stage
  • Loading branch information
harp-intel authored Dec 10, 2024
1 parent 8d60a47 commit 70d79cd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
11 changes: 6 additions & 5 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
default: tools
.PHONY: default tools async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw lspci msr-tools pcm perf spectre-meltdown-checker sshpass stress-ng sysstat tsc turbostat

tools: async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw lspci msr-tools pcm perf spectre-meltdown-checker sshpass stress-ng sysstat tsc turbostat
tools: async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw lspci msr-tools pcm spectre-meltdown-checker sshpass stress-ng sysstat tsc turbostat
mkdir -p bin
cp -R async-profiler bin/
cp avx-turbo/avx-turbo bin/
Expand All @@ -23,7 +23,6 @@ tools: async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw
cp msr-tools/wrmsr bin/
cp pcm/build/bin/pcm-tpmi bin/
cp pcm/scripts/bhs-power-mode.sh bin/
cp linux_perf/tools/perf/perf bin/
cp spectre-meltdown-checker/spectre-meltdown-checker.sh bin/
cp sshpass/sshpass bin/
cp stress-ng/stress-ng bin/
Expand Down Expand Up @@ -146,7 +145,10 @@ PERF_LINUX_VERSION := 6.1.52
perf:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$(PERF_LINUX_VERSION).tar.xz
tar -xf linux-$(PERF_LINUX_VERSION).tar.xz && mv linux-$(PERF_LINUX_VERSION)/ linux_perf/
cd linux_perf/tools/perf && make LDFLAGS="-static --static"
cd linux_perf/tools/perf && make LDFLAGS="-static --static" BUILD_BPF_SKEL=1 NO_JVMTI=1
mkdir -p bin
cp linux_perf/tools/perf/perf bin/
strip --strip-unneeded bin/perf

spectre-meltdown-checker:
ifeq ("$(wildcard spectre-meltdown-checker)","")
Expand Down Expand Up @@ -208,7 +210,6 @@ reset:
cd lspci && git clean -fdx && git reset --hard
cd pcm && git clean -fdx && git reset --hard
cd msr-tools && git clean -fdx && git reset --hard
cd linux_perf/tools/perf && make clean
cd spectre-meltdown-checker
cd sshpass && make clean
cd stress-ng && git clean -fdx && git reset --hard
Expand All @@ -226,5 +227,5 @@ libcrypt.tar.gz:
libs: glibc-2.19.tar.bz2 zlib.tar.gz libcrypt.tar.gz

oss-source: reset libs
tar --exclude-vcs -czf oss_source.tgz async-profiler/ cpuid/ dmidecode/ ethtool/ flamegraph/ ipmitool/ lshw/ lspci/ msr-tools/ pcm/ linux_perf/tools/perf spectre-meltdown-checker/ sshpass/ stress-ng/ sysstat/ linux_turbostat/tools/power/x86/turbostat glibc-2.19.tar.bz2 zlib.tar.gz libcrypt.tar.gz
tar --exclude-vcs -czf oss_source.tgz async-profiler/ cpuid/ dmidecode/ ethtool/ flamegraph/ ipmitool/ lshw/ lspci/ msr-tools/ pcm/ spectre-meltdown-checker/ sshpass/ stress-ng/ sysstat/ linux_turbostat/tools/power/x86/turbostat glibc-2.19.tar.bz2 zlib.tar.gz libcrypt.tar.gz
md5sum oss_source.tgz > oss_source.tgz.md5
28 changes: 24 additions & 4 deletions tools/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# build output oss_source* will be in workdir
# build image (from project root directory):
# $ docker build -f tools/build.Dockerfile --tag perfspect-tools:$TAG ./tools

FROM ubuntu:18.04 AS builder
ENV http_proxy=${http_proxy}
ENV https_proxy=${https_proxy}
Expand All @@ -17,23 +18,42 @@ RUN add-apt-repository ppa:git-core/ppa -y
RUN apt-get update && apt-get install -y git build-essential autotools-dev automake \
gawk zlib1g-dev libtool libaio-dev libaio1 pandoc pkgconf libcap-dev docbook-utils \
libreadline-dev default-jre default-jdk cmake flex bison libssl-dev

ENV JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64

# need golang to build go tools
RUN rm -rf /usr/local/go && wget -qO- https://go.dev/dl/go1.23.0.linux-amd64.tar.gz | tar -C /usr/local -xz
ENV PATH="${PATH}:/usr/local/go/bin"

# need up-to-date zlib (used by stress-ng static build) to fix security vulnerabilities
RUN git clone https://github.com/madler/zlib.git && cd zlib && ./configure && make install
RUN cp /usr/local/lib/libz.a /usr/lib/x86_64-linux-gnu/libz.a

# Build third-party components
RUN mkdir workdir
ADD . /workdir
WORKDIR /workdir
RUN make tools && make oss-source

FROM ubuntu:22.04 AS perf-builder
ENV http_proxy=${http_proxy}
ENV https_proxy=${https_proxy}
ENV LANG=en_US.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y apt-utils locales wget curl git netcat-openbsd software-properties-common jq zip unzip
RUN locale-gen en_US.UTF-8 && echo "LANG=en_US.UTF-8" > /etc/default/locale
RUN add-apt-repository ppa:git-core/ppa -y
RUN apt-get update && apt-get install -y \
automake autotools-dev binutils-dev bison build-essential clang cmake debuginfod \
default-jdk default-jre docbook-utils flex gawk git libaio-dev libaio1 \
libbabeltrace-dev libbpf-dev libc6 libcap-dev libdw-dev libdwarf-dev libelf-dev \
libiberty-dev liblzma-dev libnuma-dev libperl-dev libpfm4-dev libreadline-dev \
libslang2-dev libssl-dev libtool libtraceevent-dev libunwind-dev libzstd-dev \
libzstd1 llvm-13 pandoc pkgconf python-setuptools python2-dev python3 python3-dev \
python3-pip systemtap-sdt-dev zlib1g-dev
ENV PATH="${PATH}:/usr/lib/llvm-13/bin"
RUN mkdir workdir
ADD . /workdir
WORKDIR /workdir
RUN make perf

FROM scratch AS output
COPY --from=builder workdir/bin /bin
COPY --from=builder workdir/oss_source* /
COPY --from=perf-builder workdir/bin/ /bin

0 comments on commit 70d79cd

Please sign in to comment.