xref: /linux/tools/perf/bench/bench.h (revision 4241eabf59d5b7e9b5b567526f6e319f81dff894)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2c426bba0SHitoshi Mitake #ifndef BENCH_H
3c426bba0SHitoshi Mitake #define BENCH_H
4c426bba0SHitoshi Mitake 
5e4d9b04bSArnaldo Carvalho de Melo #include <sys/time.h>
6e4d9b04bSArnaldo Carvalho de Melo 
7e4d9b04bSArnaldo Carvalho de Melo extern struct timeval bench__start, bench__end, bench__runtime;
8e4d9b04bSArnaldo Carvalho de Melo 
9d1398ccfSVinson Lee /*
10d1398ccfSVinson Lee  * The madvise transparent hugepage constants were added in glibc
11d1398ccfSVinson Lee  * 2.13. For compatibility with older versions of glibc, define these
12d1398ccfSVinson Lee  * tokens if they are not already defined.
13d1398ccfSVinson Lee  *
14d1398ccfSVinson Lee  * PA-RISC uses different madvise values from other architectures and
15d1398ccfSVinson Lee  * needs to be special-cased.
16d1398ccfSVinson Lee  */
17d1398ccfSVinson Lee #ifdef __hppa__
18d1398ccfSVinson Lee # ifndef MADV_HUGEPAGE
19d1398ccfSVinson Lee #  define MADV_HUGEPAGE		67
20d1398ccfSVinson Lee # endif
21d1398ccfSVinson Lee # ifndef MADV_NOHUGEPAGE
22d1398ccfSVinson Lee #  define MADV_NOHUGEPAGE	68
23d1398ccfSVinson Lee # endif
24d1398ccfSVinson Lee #else
25d1398ccfSVinson Lee # ifndef MADV_HUGEPAGE
26d1398ccfSVinson Lee #  define MADV_HUGEPAGE		14
27d1398ccfSVinson Lee # endif
28d1398ccfSVinson Lee # ifndef MADV_NOHUGEPAGE
29d1398ccfSVinson Lee #  define MADV_NOHUGEPAGE	15
30d1398ccfSVinson Lee # endif
31d1398ccfSVinson Lee #endif
32d1398ccfSVinson Lee 
33b0ad8ea6SArnaldo Carvalho de Melo int bench_numa(int argc, const char **argv);
34b0ad8ea6SArnaldo Carvalho de Melo int bench_sched_messaging(int argc, const char **argv);
35b0ad8ea6SArnaldo Carvalho de Melo int bench_sched_pipe(int argc, const char **argv);
36c2a08203SDavidlohr Bueso int bench_syscall_basic(int argc, const char **argv);
37b0ad8ea6SArnaldo Carvalho de Melo int bench_mem_memcpy(int argc, const char **argv);
38b0ad8ea6SArnaldo Carvalho de Melo int bench_mem_memset(int argc, const char **argv);
397c43b0c1SIan Rogers int bench_mem_find_bit(int argc, const char **argv);
40b0ad8ea6SArnaldo Carvalho de Melo int bench_futex_hash(int argc, const char **argv);
41b0ad8ea6SArnaldo Carvalho de Melo int bench_futex_wake(int argc, const char **argv);
42b0ad8ea6SArnaldo Carvalho de Melo int bench_futex_wake_parallel(int argc, const char **argv);
43b0ad8ea6SArnaldo Carvalho de Melo int bench_futex_requeue(int argc, const char **argv);
44d2f3f5d2SDavidlohr Bueso /* pi futexes */
45b0ad8ea6SArnaldo Carvalho de Melo int bench_futex_lock_pi(int argc, const char **argv);
46121dd9eaSDavidlohr Bueso int bench_epoll_wait(int argc, const char **argv);
47231457ecSDavidlohr Bueso int bench_epoll_ctl(int argc, const char **argv);
482a4b5166SIan Rogers int bench_synthesize(int argc, const char **argv);
4951876bd4SIan Rogers int bench_kallsyms_parse(int argc, const char **argv);
500bf02a0dSNamhyung Kim int bench_inject_build_id(int argc, const char **argv);
51*4241eabfSRiccardo Mancini int bench_evlist_open_close(int argc, const char **argv);
52121dd9eaSDavidlohr Bueso 
53242aa14aSHitoshi Mitake #define BENCH_FORMAT_DEFAULT_STR	"default"
54242aa14aSHitoshi Mitake #define BENCH_FORMAT_DEFAULT		0
55242aa14aSHitoshi Mitake #define BENCH_FORMAT_SIMPLE_STR		"simple"
56242aa14aSHitoshi Mitake #define BENCH_FORMAT_SIMPLE		1
57242aa14aSHitoshi Mitake 
58242aa14aSHitoshi Mitake #define BENCH_FORMAT_UNKNOWN		-1
59242aa14aSHitoshi Mitake 
60242aa14aSHitoshi Mitake extern int bench_format;
61b6f0629aSDavidlohr Bueso extern unsigned int bench_repeat;
62242aa14aSHitoshi Mitake 
63d47d77c3SDavidlohr Bueso #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
64d47d77c3SDavidlohr Bueso #include <pthread.h>
65d47d77c3SDavidlohr Bueso #include <linux/compiler.h>
66d47d77c3SDavidlohr Bueso static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr __maybe_unused,
67d47d77c3SDavidlohr Bueso 					      size_t cpusetsize __maybe_unused,
68d47d77c3SDavidlohr Bueso 					      cpu_set_t *cpuset __maybe_unused)
69d47d77c3SDavidlohr Bueso {
70d47d77c3SDavidlohr Bueso 	return 0;
71d47d77c3SDavidlohr Bueso }
72d47d77c3SDavidlohr Bueso #endif
73d47d77c3SDavidlohr Bueso 
74c426bba0SHitoshi Mitake #endif
75