diff options
| -rw-r--r-- | benchmarks/create/source.mk | 2 | ||||
| -rw-r--r-- | benchmarks/fork/source.mk | 2 | ||||
| -rw-r--r-- | benchmarks/ipc-req/source.mk | 2 | ||||
| -rw-r--r-- | benchmarks/malloc/source.mk | 2 | ||||
| -rwxr-xr-x | benchmarks/scripts/gen-benchmark | 47 | ||||
| -rw-r--r-- | benchmarks/scripts/makefile | 5 | ||||
| -rw-r--r-- | benchmarks/spawn/init.c | 46 | ||||
| -rw-r--r-- | benchmarks/spawn/source.mk | 1 | ||||
| -rw-r--r-- | benchmarks/spawn/spawn.c | 14 |
9 files changed, 99 insertions, 22 deletions
diff --git a/benchmarks/create/source.mk b/benchmarks/create/source.mk index 0377337..48b022d 100644 --- a/benchmarks/create/source.mk +++ b/benchmarks/create/source.mk @@ -1 +1 @@ -DO != ./scripts/gen-benchmark -n create +DO != ./scripts/gen-benchmark -n create -p init diff --git a/benchmarks/fork/source.mk b/benchmarks/fork/source.mk index 46bde60..9c82080 100644 --- a/benchmarks/fork/source.mk +++ b/benchmarks/fork/source.mk @@ -1 +1 @@ -DO != ./scripts/gen-benchmark -n fork +DO != ./scripts/gen-benchmark -n fork -p init diff --git a/benchmarks/ipc-req/source.mk b/benchmarks/ipc-req/source.mk index 21dc0e0..3a31d47 100644 --- a/benchmarks/ipc-req/source.mk +++ b/benchmarks/ipc-req/source.mk @@ -1 +1 @@ -DO != ./scripts/gen-benchmark -n ipc-req +DO != ./scripts/gen-benchmark -n ipc-req -p init diff --git a/benchmarks/malloc/source.mk b/benchmarks/malloc/source.mk index 3367314..0c54306 100644 --- a/benchmarks/malloc/source.mk +++ b/benchmarks/malloc/source.mk @@ -1 +1 @@ -DO != ./scripts/gen-benchmark -n malloc +DO != ./scripts/gen-benchmark -n malloc -p init diff --git a/benchmarks/scripts/gen-benchmark b/benchmarks/scripts/gen-benchmark index 459040d..6545d11 100755 --- a/benchmarks/scripts/gen-benchmark +++ b/benchmarks/scripts/gen-benchmark @@ -1,32 +1,45 @@ #!/bin/sh NAME= +PROGS= while getopts "n:p:" opt; do case "$opt" in n) NAME="$OPTARG";; + p) PROGS="$PROGS $OPTARG";; *) echo "unrecognised options -$OPTARG" >&2; exit 1; esac done -obj="build/${NAME}/init.o" -dep="${obj}.d" +mkdir -p "build/$NAME" -echo "${dep}:" >> benchmarks.mk -echo "-include ${dep}" >> benchmarks.mk -echo "${obj}: $NAME/${s}" >> benchmarks.mk -echo " mkdir -p build/$NAME" >> benchmarks.mk -echo " \$(COMPILE_BENCHMARK) -c $NAME/init.c -o ${obj}" >> benchmarks.mk +if [ -z "$NAME" ]; then + echo "No name given for benchmark" >&2; exit 2; +fi -echo "build/${NAME}/initrd: ${obj} \$(COMMON)" >> benchmarks.mk -echo " \$(COMPILE_BENCHMARK) ${obj} \ - \$(COMMON) -o build/${NAME}/init" >> benchmarks.mk +if [ -z "$PROGS" ]; then + echo "No programs to add to initrd" >&2; exit 3; +fi -echo " echo build/${NAME}/init | \ - \$(GEN_INITRD) build/${NAME}/initrd" >> benchmarks.mk +for p in $PROGS +do + dep="build/${NAME}/${p}.d" -echo "BENCHMARKS += ${NAME}" >> benchmarks.mk -echo ".PHONY: ${NAME}" >> benchmarks.mk -echo "${NAME}: build/${NAME}/initrd" >> benchmarks.mk -echo " mkdir -p reports/${NAME}" >> benchmarks.mk + echo "${NAME}_PROGS += build/${NAME}/${p}" >> benchmarks.mk + echo "${dep}:" >> benchmarks.mk + echo "-include ${dep}" >> benchmarks.mk + echo "build/${NAME}/${p}: $NAME/$p.c \$(COMMON)" >> benchmarks.mk + echo " \$(COMPILE_BENCHMARK) $NAME/${p}.c \$(COMMON) \\" >> benchmarks.mk + echo " -o build/${NAME}/${p}" >> benchmarks.mk +done + +echo "build/${NAME}/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)" >> benchmarks.mk +echo " for p in \$(${NAME}_PROGS); do \\" >> benchmarks.mk +echo " echo \$\$p; \\" >> benchmarks.mk +echo " done | \$(GEN_INITRD) build/$NAME/initrd" >> benchmarks.mk + +echo "BENCHMARKS += ${NAME}" >> benchmarks.mk +echo ".PHONY: ${NAME}" >> benchmarks.mk +echo "${NAME}: build/${NAME}/initrd" >> benchmarks.mk +echo " mkdir -p reports/${NAME}" >> benchmarks.mk echo " timeout --foreground 30s \ - \$(QEMU) build/${NAME}/initrd > reports/${NAME}/log" >> benchmarks.mk + \$(QEMU) build/${NAME}/initrd > reports/${NAME}/log" >> benchmarks.mk diff --git a/benchmarks/scripts/makefile b/benchmarks/scripts/makefile index 7140c05..f862305 100644 --- a/benchmarks/scripts/makefile +++ b/benchmarks/scripts/makefile @@ -32,11 +32,14 @@ QEMU := qemu-system-$(ARCH) -machine virt -kernel ../kmi.bin \ -initrd KMI := ../kmi.bin -COMMON := build/printf.o +COMMON := build/printf.o build/string.o build/printf.o: common/printf.c $(KMI) $(COMPILE_BENCHMARK) -c common/printf.c -o build/printf.o +build/string.o: common/string.c $(KMI) + $(COMPILE_BENCHMARK) -c common/string.c -o build/string.o + BENCHMARKS := include benchmarks.mk diff --git a/benchmarks/spawn/init.c b/benchmarks/spawn/init.c new file mode 100644 index 0000000..d4c2504 --- /dev/null +++ b/benchmarks/spawn/init.c @@ -0,0 +1,46 @@ +#include <common/benchmark.h> +#include <common/cpio.h> + +void callback() +{ + sys_exit(1); +} + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(pid); + UNUSED(tid); + UNUSED(d0); + UNUSED(d1); + UNUSED(d2); + UNUSED(d3); + + if (d0 == SYS_USER_ORPHANED) { + sys_exit(1); + } + + printf("finding spawn in cpio archive %lx...\n", d2); + struct cpio_header *cp = cpio_find_file((const void *)d2, + "spawn", sizeof("spawn") - 1); + + if (!cp) { + printf("couldn't find spawn?\n"); + report(0, 0, 0); + } + + long name_len = convnum(cp->c_namesize, 8, 16); + uintptr_t spawn = (uintptr_t)(cp) + align_up(sizeof(struct cpio_header) + name_len, 4); + printf("found spawn at %lx\n", spawn); + + uint64_t timebase = sys_timebase(); + uint64_t start = sys_ticks(); + + for (size_t i = 0; i < 1000; ++i) { + id_t new_id = sys_spawn(spawn, 0); + sys_detach(new_id); + sys_swap(new_id); + } + + uint64_t end = sys_ticks(); + report(start, end, timebase); +} diff --git a/benchmarks/spawn/source.mk b/benchmarks/spawn/source.mk new file mode 100644 index 0000000..20ce8d4 --- /dev/null +++ b/benchmarks/spawn/source.mk @@ -0,0 +1 @@ +DO != ./scripts/gen-benchmark -n spawn -p init -p spawn diff --git a/benchmarks/spawn/spawn.c b/benchmarks/spawn/spawn.c new file mode 100644 index 0000000..c6a2f8e --- /dev/null +++ b/benchmarks/spawn/spawn.c @@ -0,0 +1,14 @@ +#include <common/benchmark.h> + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(pid); + UNUSED(tid); + UNUSED(d0); + UNUSED(d1); + UNUSED(d2); + UNUSED(d3); + + printf("not sure how we got here?\n"); + /* die or something */ +} |
