diff --git a/.github/workflows/Dockerfile b/.github/workflows/Dockerfile index a85591ca6551dc..88e7f210f02a2e 100644 --- a/.github/workflows/Dockerfile +++ b/.github/workflows/Dockerfile @@ -7,6 +7,8 @@ ADD rcS /etc/init.d/. RUN sed "s/\'/\"/g" /etc/profile > /.profile ADD bench.sh / +ADD iperf3.sh /root/ +ADD iperf3.static /root/ ADD do_getpid /root/. ADD clone /root/. ADD futex /root/. @@ -22,7 +24,7 @@ ADD lmbench2/ /lmbench2 ADD lmbench_run.sh /lmbench2/bin/x86_64-linux-gnulibc1/ -RUN apk update && apk add utmps-libs libtirpc curl make +RUN apk update && apk add utmps-libs libtirpc curl make iperf3 RUN mkdir -p setup && cd setup && curl -L -o output.zip \ 'https://gitlab.alpinelinux.org/thehajime/aports/-/jobs/1619053/artifacts/download?file_type=archive' \ && unzip output.zip @@ -31,4 +33,4 @@ RUN apk add --allow-untrusted \ setup/packages/main/x86_64/musl-nommu-1.2.5-r0.apk RUN rm -rf setup -ENTRYPOINT ["/root/vmlinux", "eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1", "root=/dev/root", "rootflags=/", "rootfstype=hostfs", "rw", "mem=1024m", "loglevel=8", "init=/sbin/init"] +ENTRYPOINT ["/root/vmlinux", "vec0:transport=tap,ifname=tap100,depth=128,gro=1", "root=/dev/root", "rootflags=/", "rootfstype=hostfs", "rw", "mem=1024m", "loglevel=8", "init=/sbin/init"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89252d1102e39b..e6fcde5d24419b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: debug_enabled: description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false - default: false + default: true jobs: tests: @@ -24,12 +24,14 @@ jobs: runs_on: ubuntu-22.04 shell: bash defconfig: defconfig + add_configs: CONFIG_UML_NET_VECTOR=y CFLAGS+="-DCONFIG_UML_NET_VECTOR" testname: um-mmu - displayTargetName: ubuntu-22.04 (nommu) os: unix runs_on: ubuntu-22.04 shell: bash defconfig: x86_64_nommu_defconfig + add_configs: CONFIG_UML_NET_VECTOR=y CFLAGS+="-DCONFIG_UML_NET_VECTOR" kunit_opts: --kconfig_add CONFIG_MMU=n testname: um-nommu timeout-minutes: 100 @@ -42,12 +44,16 @@ jobs: shell: ${{ matrix.shell }} steps: + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} + with: + detached: true - name: Set env shell: bash run: | echo "/usr/lib/ccache/bin:/usr/lib/ccache:${{ github.workspace }}/bin" >> $GITHUB_PATH echo "export PATH=/usr/lib/ccache/bin:/usr/lib/ccache:${{ github.workspace }}/bin:$PATH" >> $HOME/.bashrc - - name: Checkout uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -58,7 +64,7 @@ jobs: - name: Install packages run: | sudo apt update -y - sudo apt install -y ccache sparse + sudo apt install -y ccache iperf3 - name: Setup latest Alpine Linux uses: jirutka/setup-alpine@v1 with: @@ -79,18 +85,20 @@ jobs: make -C .github/workflows/ shell: alpine.sh {0} # --root {0} - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} - with: - detached: true - name: Setup faketty uses: Yuri6037/Action-FakeTTY@v1.1 + - name: setup tap interface + run: | + set -x + sudo ip tuntap add dev tap100 mode tap user ${USER} + sudo ip add add 192.168.122.1/24 dev tap100 + sudo ip link set up dev tap100 + iperf3 -s & - name: build-0 (static) run: | make ARCH=um ${{ matrix.defconfig }} O=build cat build/.config | sed "s/.*CONFIG_STATIC_LINK.*/CONFIG_STATIC_LINK=y/" > /tmp/a; mv /tmp/a build/.config - make -j8 ARCH=um O=build + make -j8 ARCH=um O=build ${{ matrix.add_configs }} - name: prep for docker build run: | cp build/vmlinux .github/workflows/ @@ -104,12 +112,12 @@ jobs: ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }} - name: image for test run: | - container_id=$(docker create ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }}) - docker start $container_id - docker wait $container_id - docker logs $container_id - docker export $container_id > alpine.tar - docker rm $container_id + docker create --name alpine-nommu ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }} + docker start alpine-nommu + docker wait alpine-nommu + docker logs alpine-nommu + docker export alpine-nommu > alpine.tar + docker rm alpine-nommu mnt=$(mktemp -d) dd if=/dev/zero of=alpine.ext4 bs=1 count=0 seek=1G sudo chmod og+wr "alpine.ext4" @@ -117,11 +125,13 @@ jobs: sudo mount "alpine.ext4" $mnt sudo tar -xf alpine.tar -C $mnt sudo umount $mnt + mkdir -p rootfs + sudo tar -xf alpine.tar -C rootfs + sudo chown -R ${USER} rootfs - name: test-0 (static) run: | sudo sh -c "echo 0 > /proc/sys/vm/mmap_min_addr" - sudo ip tuntap add dev tap100 mode tap user ${USER} - faketty ./build/vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty init=/sbin/init 2>&1 | tee /tmp/log.txt & + faketty ./build/vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty init=/sbin/init 2>&1 | tee /tmp/log.txt & sleep 10 && pkill vmlinux echo "=========" cat /tmp/log.txt @@ -134,10 +144,10 @@ jobs: - name: build-1 run: | make ARCH=um ${{ matrix.defconfig }} - make -j8 ARCH=um + make -j8 ARCH=um ${{ matrix.add_configs }} - name: test-1 run: | - faketty ./vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine.ext4 rw mem=1024m loglevel=8 init=/sbin/init 2>&1 | tee /tmp/log.txt & + faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 ubd0=./alpine.ext4 rw mem=1024m loglevel=8 init=/sbin/init 2>&1 | tee /tmp/log.txt & sleep 10 && pkill vmlinux echo "=========" cat /tmp/log.txt @@ -145,19 +155,34 @@ jobs: if: matrix.testname == 'um-nommu' run: | mkdir -p output - faketty ./vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine.ext4 rw mem=1024m \ - loglevel=8 console=tty zpoline=1 init=/bench.sh \ + faketty ./vmlinux ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty zpoline=1 init=/bench.sh \ | tee output/${{ matrix.testname }}-zpoline.dat || true # XXX: until 6.12 pulled - faketty ./vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine.ext4 rw mem=1024m \ - loglevel=8 console=tty zpoline=0 init=/bench.sh \ + faketty ./vmlinux ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty zpoline=0 init=/bench.sh \ | tee output/${{ matrix.testname }}-seccomp.dat || true # XXX: until 6.12 pulled - name: benchmark-1 if: matrix.testname == 'um-mmu' run: | mkdir -p output - faketty ./vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine.ext4 rw mem=1024m \ - loglevel=0 console=tty init=/bench.sh \ + faketty ./vmlinux ubd0=./alpine.ext4 rw mem=1024m loglevel=0 console=tty init=/bench.sh \ | tee output/${{ matrix.testname }}.dat + - name: benchmark-2-iperf3 + run: | + mkdir -p output + if [ "${{ matrix.testname }}" == "um-nommu" ] ; then + faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ + root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ + loglevel=0 console=tty init=/root/iperf3.sh \ + | tee output/${{ matrix.testname }}-seccomp-iperf3.dat + faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ + root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ + loglevel=0 console=tty zpoline=1 init=/root/iperf3.sh \ + | tee output/${{ matrix.testname }}-zpoline-iperf3.dat + else + faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ + root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ + loglevel=0 console=tty init=/root/iperf3.sh \ + | tee output/${{ matrix.testname }}-iperf3.dat + fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: @@ -178,7 +203,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: bench-result-${{ matrix.testname }} - path: output/${{ matrix.testname }}*.dat + path: output/${{ matrix.testname }}* checkpatch: runs-on: ubuntu-22.04 @@ -257,7 +282,7 @@ jobs: - name: Install packages run: | sudo apt update -y - sudo apt install -y gnuplot lmbench + sudo apt install -y gnuplot lmbench iperf3 - name: benchmark-host run: | mkdir -p output @@ -267,6 +292,9 @@ jobs: sh .github/workflows/lmbench_run.sh |& tee output/native.dat gcc -o do_getpid .github/workflows/do_getpid.c ./do_getpid -c 100 | tee -a output/native.dat + iperf3 -s & + iperf3 -c localhost -fm | tee output/native-iperf3.dat + iperf3 -c localhost -fm -R | tee -a output/native-iperf3.dat - name: bench data parse/out run: | export TMP_OUTPUT=$(bash .github/workflows/um-nommu-plot.sh output) @@ -280,13 +308,19 @@ jobs: path: output/out/lmbench.* - name: publish to imgur uses: devicons/public-upload-to-imgur@v2.2.2 - id: publish-to-imgur + id: lmbench-imgur + with: + path: "output/out/lmbench.png" + client_id: ${{secrets.IMGUR_CLIENT_ID}} + - name: publish to imgur-iperf + uses: devicons/public-upload-to-imgur@v2.2.2 + id: iperf3-imgur with: - path: "output/out/*.png" + path: "output/out/iperf3.png" client_id: ${{secrets.IMGUR_CLIENT_ID}} - name: bench data parse/out run: | - export SCRIPT_OUTPUT="${{ join(fromJSON(steps.publish-to-imgur.outputs.markdown_urls)) }}" + export SCRIPT_OUTPUT="${{ join(fromJSON(steps.lmbench-imgur.outputs.markdown_urls)) }} ${{ join(fromJSON(steps.iperf3-imgur.outputs.markdown_urls)) }}" echo "SCRIPT_OUTPUT<> $GITHUB_ENV echo "$TMP_OUTPUT" >> $GITHUB_ENV echo "" >> $GITHUB_ENV diff --git a/.github/workflows/iperf3.sh b/.github/workflows/iperf3.sh new file mode 100755 index 00000000000000..4a8a2f264897d1 --- /dev/null +++ b/.github/workflows/iperf3.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +NIC=vec0 +mount proc /proc -t proc +echo "nameserver 8.8.8.8" > /etc/resolv.conf +/sbin/ifconfig lo 127.0.0.1 up +/sbin/ifconfig $NIC 192.168.122.2 up + +sleep 5 +IPERF=/root/iperf3.static +echo "===iperf3 forward===" +$IPERF -c 192.168.122.1 -fm +echo "===iperf3 reverse===" +$IPERF -c 192.168.122.1 -R -fm +/sbin/halt -f diff --git a/.github/workflows/iperf3.static b/.github/workflows/iperf3.static new file mode 100755 index 00000000000000..79155612c05c8a Binary files /dev/null and b/.github/workflows/iperf3.static differ diff --git a/.github/workflows/rcS b/.github/workflows/rcS index 3d918872f3c8d4..a7efe02c4c20c9 100755 --- a/.github/workflows/rcS +++ b/.github/workflows/rcS @@ -1,10 +1,11 @@ #!/bin/sh +NIC=vec0 mount proc /proc -t proc echo "nameserver 8.8.8.8" > /etc/resolv.conf /sbin/ifconfig lo 127.0.0.1 up -/sbin/ifconfig eth0 192.168.122.2 up -/sbin/ip route add default via 192.168.122.1 dev eth0 +/sbin/ifconfig $NIC 192.168.122.2 up +/sbin/ip route add default via 192.168.122.1 dev $NIC export PATH=/home:/sbin:/usr/sbin:/bin:/usr/bin export TERM=linux diff --git a/.github/workflows/um-nommu-bench.sh b/.github/workflows/um-nommu-bench.sh index 84c4540ca873ba..601e128ccbb9f5 100755 --- a/.github/workflows/um-nommu-bench.sh +++ b/.github/workflows/um-nommu-bench.sh @@ -13,11 +13,11 @@ RUNTIMES="build/mmu build" echo "$(tput bold)== um (mmu) ($test-$num-$vsize) ==$(tput sgr0)" -../linux-um-nommu/build-mmu/vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine-test.ext3 rw mem=1024m loglevel=0 init=/bench.sh \ +../linux-um-nommu/build-mmu/vmlinux ubd0=./alpine-test.ext3 rw mem=1024m loglevel=0 init=/bench.sh \ | tee "$OUTPUT/um-mmu.dat" echo "$(tput bold)== um (nommu) ($test-$num-$vsize) ==$(tput sgr0)" -../linux-um-nommu/build/vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine-test.ext3 rw mem=1024m loglevel=0 init=/bench.sh \ +../linux-um-nommu/build/vmlinux ubd0=./alpine-test.ext3 rw mem=1024m loglevel=0 init=/bench.sh \ | tee "$OUTPUT/um-nommu.dat" echo "$(tput bold)== host (mmu) ($test-$num-$vsize) ==$(tput sgr0)" diff --git a/.github/workflows/um-nommu-plot.sh b/.github/workflows/um-nommu-plot.sh index 9175ce80b76567..c148b408e95eb9 100755 --- a/.github/workflows/um-nommu-plot.sh +++ b/.github/workflows/um-nommu-plot.sh @@ -9,15 +9,22 @@ mkdir -p "$OUTPUT/out/" # parse outputs -for f in `ls $OUTPUT/*.dat` +for f in `ls $OUTPUT/*.dat |grep -v iperf3` do cat $f | grep microsec | sed "s/.*:\(.*\)/\1/" | awk '{print $1}' \ - > $OUTPUT/out/`basename $f .dat`-out.dat + > $OUTPUT/out/`basename $f .dat`-lmbench-out.dat cat $f | grep average |grep -v time | awk '{print $2 $3}' \ > $OUTPUT/out/`basename $f .dat`-getpid-out.dat done +# parse iperf3 result +for f in `ls $OUTPUT/*-iperf3.dat` +do + cat $f | grep receiver | awk '{print $7}' \ + > $OUTPUT/out/`basename $f .dat`-out.dat +done + gnuplot << EndGNUPLOT set terminal postscript eps lw 3 "Helvetica" 24 set output "${OUTPUT}/out/lmbench.eps" @@ -40,10 +47,10 @@ set ylabel "Latency (usec)" set logscale y plot \ - '${OUTPUT}/out/um-mmu-out.dat' usin (\$0-0.3):(\$1) w boxes fill patter 2 lt 1 lc rgb "green" title "um(mmu)" ,\ - '${OUTPUT}/out/um-nommu-zpoline-out.dat' usin (\$0-0.1):(\$1) w boxes fill patter 2 lt 1 lc rgb "blue" title "um(nommu(z))" ,\ - '${OUTPUT}/out/um-nommu-seccomp-out.dat' usin (\$0+0.1):(\$1) w boxes fill patter 2 lt 1 lc rgb "royalblue" title "um(nommu(s))" ,\ - '${OUTPUT}/out/native-out.dat' usin (\$0+0.3):(\$1) w boxes fill patter 2 lt 1 lc rgb "red" title "native" + '${OUTPUT}/out/um-mmu-lmbench-out.dat' usin (\$0-0.3):(\$1) w boxes fill patter 2 lt 1 lc rgb "green" title "um(mmu)" ,\ + '${OUTPUT}/out/um-nommu-zpoline-lmbench-out.dat' usin (\$0-0.1):(\$1) w boxes fill patter 2 lt 1 lc rgb "blue" title "um(nommu(z))" ,\ + '${OUTPUT}/out/um-nommu-seccomp-lmbench-out.dat' usin (\$0+0.1):(\$1) w boxes fill patter 2 lt 1 lc rgb "royalblue" title "um(nommu(s))" ,\ + '${OUTPUT}/out/native-lmbench-out.dat' usin (\$0+0.3):(\$1) w boxes fill patter 2 lt 1 lc rgb "red" title "native" set terminal png lw 3 14 crop set output "${OUTPUT}/out/lmbench.png" @@ -54,15 +61,61 @@ EndGNUPLOT echo -e "### lmbench (usec)\n" echo -e "|select-10\n|select-100\n|select-1000\n|syscall\n|read\n|write\n|stat\n|open/close\n|fork+sh\n|fork+execve" > /tmp/a -echo -e "||native|um|um-nommu(s)|um-nommu(z)|\n|--|--|--|--|--|"; paste -d "|" `ls ${OUTPUT}/out/*.dat |grep -v getpid` | sed "s/\(.*\)/\|\1\|/" | paste /tmp/a - | column -t +echo -e "||native|um|um-nommu(s)|um-nommu(z)|\n|--|--|--|--|--|"; paste -d "|" `ls ${OUTPUT}/out/*-lmbench-out.dat` | sed "s/\(.*\)/\|\1\|/" | paste /tmp/a - | column -t rm -f /tmp/a echo "" echo -e "### do_getpid bench (nsec)\n" -for f in `ls $OUTPUT/*.dat` +for f in `ls $OUTPUT/*.dat |grep -v iperf3` do export $(basename $f .dat|sed "s/-/_/g")=`grep aver $f | grep -v time | awk '{print $2}'` done echo -e "||native|um|um-nommu(s)|um-nommu(z)|\n|--|--|--|--|--|" echo "|getpid | ${native} | ${um_mmu} | ${um_nommu_seccomp}| ${um_nommu_zpoline}|" + + +# iperf result + +gnuplot << EndGNUPLOT +set terminal postscript eps lw 3 "Helvetica" 24 +set output "${OUTPUT}/out/iperf3.eps" +#set xtics font "Helvetica,14" +set pointsize 2 +set xzeroaxis + +set boxwidth 0.2 +set style fill pattern + +set size 1.0,0.8 +set key top left + +set xrange [-0.5:1.5] +set xtics ('iperf(f)' 0, 'iperf(r)' 1) +#set xtics rotate by 45 right +set yrange [:50] +set ytics 10 +set ylabel "Goodput (Gbps)" + +plot \ + '${OUTPUT}/out/um-mmu-iperf3-out.dat' usin (\$0-0.3):(\$1/1000) w boxes fill patter 2 lt 1 lc rgb "green" title "um(mmu)" ,\ + '${OUTPUT}/out/um-nommu-zpoline-iperf3-out.dat' usin (\$0-0.1):(\$1/1000) w boxes fill patter 2 lt 1 lc rgb "blue" title "um(nommu(z))" ,\ + '${OUTPUT}/out/um-nommu-seccomp-iperf3-out.dat' usin (\$0+0.1):(\$1/1000) w boxes fill patter 2 lt 1 lc rgb "royalblue" title "um(nommu(s))" ,\ + '${OUTPUT}/out/native-iperf3-out.dat' usin (\$0+0.3):(\$1/1000) w boxes fill patter 2 lt 1 lc rgb "red" title "native" + +set terminal png lw 3 14 crop +set output "${OUTPUT}/out/iperf3.png" +replot + +EndGNUPLOT + +echo "" +echo -e "### iperf3 bench (Mbps)\n" +for f in `ls $OUTPUT/out/*iperf3*.dat` +do + export $(basename $f .dat|sed "s/-/_/g" | sed "s/_iperf3_out/_f/")=`cat $f|head -1` + export $(basename $f .dat|sed "s/-/_/g" | sed "s/_iperf3_out/_r/")=`cat $f|tail -1` +done +echo -e "||native|um|um-nommu(s)|um-nommu(z)|\n|--|--|--|--|--|" +echo "|iperf3(f) | ${native_f} | ${um_mmu_f} | ${um_nommu_seccomp_f}| ${um_nommu_zpoline_f}|" +echo "|iperf3(r) | ${native_r} | ${um_mmu_r} | ${um_nommu_seccomp_r}| ${um_nommu_zpoline_r}|"