^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef BENCH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define BENCH_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <sys/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) extern struct timeval bench__start, bench__end, bench__runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * The madvise transparent hugepage constants were added in glibc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * 2.13. For compatibility with older versions of glibc, define these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * tokens if they are not already defined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * PA-RISC uses different madvise values from other architectures and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * needs to be special-cased.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef __hppa__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) # ifndef MADV_HUGEPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # define MADV_HUGEPAGE 67
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # ifndef MADV_NOHUGEPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # define MADV_NOHUGEPAGE 68
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) # endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) # ifndef MADV_HUGEPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # define MADV_HUGEPAGE 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) # endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) # ifndef MADV_NOHUGEPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) # define MADV_NOHUGEPAGE 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) # endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int bench_numa(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int bench_sched_messaging(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int bench_sched_pipe(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int bench_syscall_basic(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int bench_mem_memcpy(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int bench_mem_memset(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int bench_mem_find_bit(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int bench_futex_hash(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int bench_futex_wake(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int bench_futex_wake_parallel(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int bench_futex_requeue(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* pi futexes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int bench_futex_lock_pi(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int bench_epoll_wait(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int bench_epoll_ctl(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int bench_synthesize(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int bench_kallsyms_parse(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int bench_inject_build_id(int argc, const char **argv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define BENCH_FORMAT_DEFAULT_STR "default"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define BENCH_FORMAT_DEFAULT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define BENCH_FORMAT_SIMPLE_STR "simple"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define BENCH_FORMAT_SIMPLE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define BENCH_FORMAT_UNKNOWN -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) extern int bench_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) extern unsigned int bench_repeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #include <pthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) size_t cpusetsize __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) cpu_set_t *cpuset __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #endif