diff --git a/.github/workflows/Dockerfile b/.github/workflows/Dockerfile index a85591ca6551dc..7ff3b07f0facc9 100644 --- a/.github/workflows/Dockerfile +++ b/.github/workflows/Dockerfile @@ -1,5 +1,6 @@ FROM alpine:3.20.3 +ARG MODE= ADD vmlinux /root/. ADD inittab /etc/inittab RUN mkdir /etc/init.d @@ -7,6 +8,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,13 +25,13 @@ ADD lmbench2/ /lmbench2 ADD lmbench_run.sh /lmbench2/bin/x86_64-linux-gnulibc1/ -RUN apk update && apk add utmps-libs libtirpc curl make -RUN mkdir -p setup && cd setup && curl -L -o output.zip \ +RUN apk update && apk add utmps-libs libtirpc curl make iperf3 + +RUN if [[ ${MODE} == "um-nommu" ]]; then 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 -RUN apk add --allow-untrusted \ + && unzip output.zip ; fi +RUN if [[ ${MODE} == "um-nommu" ]]; then apk add --allow-untrusted \ setup/packages/main/x86_64/busybox-nommu-1.36.1-r29.apk \ - setup/packages/main/x86_64/musl-nommu-1.2.5-r0.apk -RUN rm -rf setup + setup/packages/main/x86_64/musl-nommu-1.2.5-r0.apk && rm -rf setup; fi -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..895a3b78a895a4 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/ @@ -99,17 +107,18 @@ jobs: uses: docker/build-push-action@v6 with: context: .github/workflows + build-args: "MODE=${{ matrix.testname }}" push: false tags: | 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 +126,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 +145,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 +156,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: @@ -172,13 +198,14 @@ jobs: uses: docker/build-push-action@v6 with: context: .github/workflows + build-args: "MODE=${{ matrix.testname }}" push: true tags: | ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }} - 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 +284,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 +294,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 +310,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/gdbinit b/.github/workflows/gdbinit new file mode 100644 index 00000000000000..d202e29a1e2867 --- /dev/null +++ b/.github/workflows/gdbinit @@ -0,0 +1,221 @@ +#add-auto-load-safe-path /home/tazaki/gitworks/osv/scripts/loader.py + +handle SIGUSR1 nostop +#set annotate 1 +set history save on +set history size 10000 +set history filename ~tazaki/.gdb_history +set print pretty on +set print static-members off +set charset ASCII +set print thread-events off +directory /home/tazaki/work/nabla-linux/tests/busybox.git:/home/tazaki/work/nabla-linux/tests/musl-git/:/home/tazaki/work/deb-src/glibc-2.39/ + +define ntoa + set $ipv4 = $arg0 + echo IPV4 =. + p $ipv4 + set $val1 = ($ipv4 >> 24) & 0xff + set $val2 = ($ipv4 >> 16) & 0xff + set $val3 = ($ipv4 >> 8) & 0xff + set $val4 = ($ipv4 >> 0) & 0xff + printf "IPV4=%u=0x%02x.%02x.%02x.%02x =%d.%d.%d.%d\n", $ipv4, $val1, $val2, $val3, $val4, $val1, $val2, $val3, $val4 + end + +# change prompt +#source /home/tazaki/gdb-prompt.py + +define walk_list + set $temp = $arg0 + while ($temp) + printf "(%d,0x%X)-->",((sll*)$temp)->data,((sll*)$temp)->next + set $temp = ((sll*)$temp)->next + end + printf "Done\n" +end + +define walk_tailq + set $temp = $arg0->tqh_first + while ($temp) + printf "(%s,0x%lx,runnable=%d)-->", ((struct thread *)$temp)->name,(struct thread *)$temp, is_runnable((struct thread *)$temp) + set $temp = ((struct thread *)$temp)->thread_list->tqe_next + end + printf "Done\n" +end + +define lkl_hijack + set environment LD_LIBRARY_PATH=../openssl:tools/lkl/lib/hijack/:lib/hijack/ + set exec-wrapper env 'LD_PRELOAD=liblkl-hijack.so' +end + +define zpoline + set exec-wrapper env 'LD_PRELOAD=./libzpoline.so' + set environment LIBZPHOOK=libzphook_basic.so + set environment LD_LIBRARY_PATH=/home/tazaki/work/zpoline/zpoline/apps/basic/ +end + +define zpoline_lkl + set environment LKL_HIJACK_ZPOLINE=1 + set environment LIBZPHOOK=liblkl-zpoline.so + set environment LD_LIBRARY_PATH=../openssl:tools/lkl/lib/hijack/:lib/hijack/:/home/tazaki/work/zpoline/zpoline + set exec-wrapper env 'LD_PRELOAD=libzpoline.so' +end + +define zpoline_rsocket + set environment LIBZPHOOK=librszpoline.so + set environment LD_LIBRARY_PATH=./build/lib/:/home/tazaki/work/zpoline/zpoline + set exec-wrapper env 'LD_PRELOAD=libzpoline.so' +end + +define rsocket + set environment LD_LIBRARY_PATH=./build/lib/ + set exec-wrapper env 'LD_PRELOAD=librspreload.so' +end + +define upregs + set $regs = 0 + if $argc == 0 + set $regs = (((struct pt_regs *)current_ptregs)->regs->gp) + else + set $regs = ((struct uml_pt_regs *)$arg0)->gp + end + + printf "rax=0x%08lx\t\tAX[10]=0x%08lx\t\tO_AX[15]=0x%lx\n", $rax, $regs[10], $regs[15] + printf "rbx=0x%08lx\t\tBX[5]=0x%08lx\n", $rbx, $regs[5] + printf "rcx=0x%08lx\t\tCX[11]=0x%08lx\n", $rcx,$regs[11] + printf "rdx=0x%08lx\t\tDX[12]=0x%08lx\n", $rdx,$regs[12] + printf "rsi=0x%08lx\t\tSI[13]=0x%08lx\n", $rsi, $regs[13] + printf "rdi=0x%08lx\t\tDI[14]=0x%08lx\n", $rdi, $regs[14] + printf "rbp=0x%08lx\t\tBP[4]=0x%08lx\n", $rbp, $regs[4] + printf "rsp=0x%08lx\t\tSP[19]=0x%08lx\n", $rsp, $regs[19] + printf " r8=0x%08lx\t\tR8[9]=0x%08lx\n", $r8,$regs[9] + printf " r9=0x%08lx\t\tR9[8]=0x%08lx\n", $r9,$regs[8] + printf "r10=0x%08lx\t\tR10[7]=0x%08lx\n", $r10,$regs[7] + printf "r11=0x%08lx\t\tR11[6]=0x%08lx\n", $r11,$regs[6] + printf "r12=0x%08lx\t\tR12[3]=0x%08lx\n", $r12,$regs[3] + printf "r13=0x%08lx\t\tR13[2]=0x%08lx\n", $r13,$regs[2] + printf "r14=0x%08lx\t\tR14[1]=0x%08lx\n", $r14,$regs[1] + printf "r15=0x%08lx\t\tR15[0]=0x%08lx\n", $r15,$regs[0] + printf "rip=0x%08lx\t\tIP[16]=0x%08lx\n", $rip,$regs[16] + printf "eflags=0x%08lx\t\tEFLAGS[18]=0x%lx\n", $eflags,$regs[18] + printf "CS[17]=0x%lx, ", $regs[17] + printf "SS[20]=0x%lx\n", $regs[20] +end + +define pregs + if $argc == 1 + print $arg0 *(struct pt_regs *)current_ptregs + else + print *(struct pt_regs *)current_ptregs + end + printf "pregs=0x%x, AX[10]=%ld, CX[11]=0x%lx, DX[12]=0x%lx, ORIG_AX[15]=%ld, IP[16]=0x%x, SP[19]=0x%x HOST_FS[25]=0x%x, FS[21]=0x%x, FP=0x%x\n", \ + current_ptregs, ((struct pt_regs *)current_ptregs)->regs.gp[10], \ + ((struct pt_regs *)current_ptregs)->regs.gp[11], ((struct pt_regs *)current_ptregs)->regs.gp[12],\ + ((struct pt_regs *)current_ptregs)->regs.gp[15], ((struct pt_regs *)current_ptregs)->regs.gp[16],\ + ((struct pt_regs *)current_ptregs)->regs.gp[19], ((struct pt_regs *)current_ptregs)->regs.gp[25],\ + ((struct pt_regs *)current_ptregs)->regs.gp[21], ((struct pt_regs *)current_ptregs)->regs.fp +end + +## source /home/tazaki/.gdbinit_defs +## +## define syscall +## printf "syscall/rax\t = %d(%s)\n", ((struct pt_regs *)current_ptregs)->regs.gp[15], \ +## $syscall_tbl[((struct pt_regs *)current_ptregs)->regs.gp[15]] +## printf "ret/rax\t\t\t = %d\n", $rax +## printf "retp/rcx\t\t = 0x%x\n", $rcx +## printf "arg0/rdi\t\t = 0x%x\n", $rdi +## printf "arg1/rsi\t\t = 0x%x\n", $rsi +## printf "arg2/rdx\t\t = 0x%x\n", $rdx +## printf "arg3/r10\t\t = 0x%x\n", $r10 +## printf "arg4/r8\t\t\t = 0x%x\n", $r8 +## printf "arg5/r9\t\t\t = 0x%x\n", $r9 +## end + +source /home/tazaki/work/mino/mino/gdbinit-minoc + +python +import subprocess +import re + +def relocatesections(filename, addr): + p = subprocess.Popen(["readelf", "-S", filename], stdout = subprocess.PIPE) + + sections = [] + textaddr = '0' + for line in p.stdout.readlines(): + line = line.decode("utf-8").strip() + if not line.startswith('[') or line.startswith('[Nr]'): + continue + + line = re.sub(r' +', ' ', line) + line = re.sub(r'\[ *(\d+)\]', r"\g<1>", line) + fieldsvalue = line.split(' ') + fieldsname = ['number', 'name', 'type', 'addr', 'offset', 'size', 'entsize', 'flags', 'link', 'info', 'addralign'] + sec = dict(zip(fieldsname, fieldsvalue)) + + if sec['number'] == '0': + continue + + sections.append(sec) + + if sec['name'] == '.text': + textaddr = sec['addr'] + + return (textaddr, sections) + + +class AddSymbolFileAll(gdb.Command): + """The right version for add-symbol-file""" + + def __init__(self): + super(AddSymbolFileAll, self).__init__("add-symbol-file-all", gdb.COMMAND_USER) + self.dont_repeat() + + def invoke(self, arg, from_tty): + argv = gdb.string_to_argv(arg) + filename = argv[0] + + if len(argv) > 1: + offset = int(str(gdb.parse_and_eval(argv[1])), 0) + else: + offset = 0 + + (textaddr, sections) = relocatesections(filename, offset) + + cmd = "add-symbol-file %s 0x%08x" % (filename, int(textaddr, 16) + offset) + + for s in sections: + addr = int(s['addr'], 16) + if s['name'] == '.text' or addr == 0: + continue + + cmd += " -s %s 0x%08x" % (s['name'], addr + offset) + + gdb.execute(cmd) + +class RemoveSymbolFileAll(gdb.Command): + """The right version for remove-symbol-file""" + + def __init__(self): + super(RemoveSymbolFileAll, self).__init__("remove-symbol-file-all", gdb.COMMAND_USER) + self.dont_repeat() + + def invoke(self, arg, from_tty): + argv = gdb.string_to_argv(arg) + filename = argv[0] + + if len(argv) > 1: + offset = int(str(gdb.parse_and_eval(argv[1])), 0) + else: + offset = 0 + + (textaddr, _) = relocatesections(filename, offset) + + cmd = "remove-symbol-file -a 0x%08x" % (int(textaddr, 16) + offset) + gdb.execute(cmd) + + +AddSymbolFileAll() +RemoveSymbolFileAll() +end +#source /home/tazaki/work/gdb-symbols.py 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}|"