summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-04-16 21:56:33 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-05-29 16:03:01 -0400
commit68ac797b2001652cf3baf5266ea372b28a0f992c (patch)
treebac50a5d65797e3654585a575984dff13f054636
parent53254edc4f4f2edabe42b877e674b9ce48cd1337 (diff)
memory allocation test
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rwxr-xr-xtests/memory_alloc.ktest48
1 files changed, 48 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+
+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 "$@"