From 68ac797b2001652cf3baf5266ea372b28a0f992c Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 16 Apr 2023 21:56:33 -0400 Subject: memory allocation test Signed-off-by: Kent Overstreet --- tests/memory_alloc.ktest | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 tests/memory_alloc.ktest diff --git a/tests/memory_alloc.ktest b/tests/memory_alloc.ktest new file mode 100755 index 0000000..80b5c7d --- /dev/null +++ b/tests/memory_alloc.ktest @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +. $(dirname $(readlink -e "${BASH_SOURCE[0]}"))/test-libs.sh + +config-timeout $(stress_timeout) + +#require-kernel-append nomem_profiling + +test_bench() +{ + cat > /root/bench.c <<-ZZ +#include +#include +#include +#include +#include + +int madvise_test(long in1, long in2) +{ + return madvise((void*)in1, (size_t)in2, 25); +} + +int main(int argc, char *argv[]) +{ + long in1 = 0, in2 = 0; + int res; + + if (argc > 1) { + in1 = atol(argv[1]); + if (argc > 2) { + in2 = atol(argv[2]); + } + } + res = madvise_test(in1, in2); + printf("madvise_test(%ld, %ld) returned %d\n", in1, in2, res); + + return res; +} +ZZ + + gcc -o /root/bench /root/bench.c + + time /root/bench 2 + perf record -- /root/bench 2 + perf report --sort=symbol|head -n60|cut -b1-50 || true +} + +main "$@" -- cgit v1.2.3