4 * numa: Simulate NUMA-sensitive workload and measure their NUMA performance
8 #include "../builtin.h"
9 #include "../util/util.h"
10 #include "../util/parse-options.h"
27 #include <sys/prctl.h>
28 #include <sys/types.h>
34 * Regular printout to the terminal, supressed if -q is specified:
36 #define tprintf(x...) do { if (g && g->p.show_details >= 0) printf(x); } while (0)
41 #define dprintf(x...) do { if (g && g->p.show_details >= 1) printf(x); } while (0)
45 cpu_set_t bind_cpumask
;
51 unsigned int loops_done
;
54 pthread_mutex_t
*process_lock
;
57 /* Parameters set by options: */
60 /* Startup synchronization: */
61 bool serialize_startup
;
67 /* Working set sizes: */
68 const char *mb_global_str
;
69 const char *mb_proc_str
;
70 const char *mb_proc_locked_str
;
71 const char *mb_thread_str
;
75 double mb_proc_locked
;
78 /* Access patterns to the working set: */
82 bool data_zero_memset
;
88 /* Working set initialization: */
100 long bytes_process_locked
;
106 bool show_convergence
;
107 bool measure_convergence
;
113 /* Affinity options -C and -N: */
119 /* Global, read-writable area, accessible to all processes and threads: */
124 pthread_mutex_t startup_mutex
;
125 int nr_tasks_started
;
127 pthread_mutex_t startup_done_mutex
;
129 pthread_mutex_t start_work_mutex
;
130 int nr_tasks_working
;
132 pthread_mutex_t stop_work_mutex
;
135 struct thread_data
*threads
;
137 /* Convergence latency measurement: */
146 static struct global_info
*g
= NULL
;
148 static int parse_cpus_opt(const struct option
*opt
, const char *arg
, int unset
);
149 static int parse_nodes_opt(const struct option
*opt
, const char *arg
, int unset
);
153 static const struct option options
[] = {
154 OPT_INTEGER('p', "nr_proc" , &p0
.nr_proc
, "number of processes"),
155 OPT_INTEGER('t', "nr_threads" , &p0
.nr_threads
, "number of threads per process"),
157 OPT_STRING('G', "mb_global" , &p0
.mb_global_str
, "MB", "global memory (MBs)"),
158 OPT_STRING('P', "mb_proc" , &p0
.mb_proc_str
, "MB", "process memory (MBs)"),
159 OPT_STRING('L', "mb_proc_locked", &p0
.mb_proc_locked_str
,"MB", "process serialized/locked memory access (MBs), <= process_memory"),
160 OPT_STRING('T', "mb_thread" , &p0
.mb_thread_str
, "MB", "thread memory (MBs)"),
162 OPT_UINTEGER('l', "nr_loops" , &p0
.nr_loops
, "max number of loops to run"),
163 OPT_UINTEGER('s', "nr_secs" , &p0
.nr_secs
, "max number of seconds to run"),
164 OPT_UINTEGER('u', "usleep" , &p0
.sleep_usecs
, "usecs to sleep per loop iteration"),
166 OPT_BOOLEAN('R', "data_reads" , &p0
.data_reads
, "access the data via writes (can be mixed with -W)"),
167 OPT_BOOLEAN('W', "data_writes" , &p0
.data_writes
, "access the data via writes (can be mixed with -R)"),
168 OPT_BOOLEAN('B', "data_backwards", &p0
.data_backwards
, "access the data backwards as well"),
169 OPT_BOOLEAN('Z', "data_zero_memset", &p0
.data_zero_memset
,"access the data via glibc bzero only"),
170 OPT_BOOLEAN('r', "data_rand_walk", &p0
.data_rand_walk
, "access the data with random (32bit LFSR) walk"),
173 OPT_BOOLEAN('z', "init_zero" , &p0
.init_zero
, "bzero the initial allocations"),
174 OPT_BOOLEAN('I', "init_random" , &p0
.init_random
, "randomize the contents of the initial allocations"),
175 OPT_BOOLEAN('0', "init_cpu0" , &p0
.init_cpu0
, "do the initial allocations on CPU#0"),
176 OPT_INTEGER('x', "perturb_secs", &p0
.perturb_secs
, "perturb thread 0/0 every X secs, to test convergence stability"),
178 OPT_INCR ('d', "show_details" , &p0
.show_details
, "Show details"),
179 OPT_INCR ('a', "all" , &p0
.run_all
, "Run all tests in the suite"),
180 OPT_INTEGER('H', "thp" , &p0
.thp
, "MADV_NOHUGEPAGE < 0 < MADV_HUGEPAGE"),
181 OPT_BOOLEAN('c', "show_convergence", &p0
.show_convergence
, "show convergence details"),
182 OPT_BOOLEAN('m', "measure_convergence", &p0
.measure_convergence
, "measure convergence latency"),
183 OPT_BOOLEAN('q', "quiet" , &p0
.show_quiet
, "bzero the initial allocations"),
184 OPT_BOOLEAN('S', "serialize-startup", &p0
.serialize_startup
,"serialize thread startup"),
186 /* Special option string parsing callbacks: */
187 OPT_CALLBACK('C', "cpus", NULL
, "cpu[,cpu2,...cpuN]",
188 "bind the first N tasks to these specific cpus (the rest is unbound)",
190 OPT_CALLBACK('M', "memnodes", NULL
, "node[,node2,...nodeN]",
191 "bind the first N tasks to these specific memory nodes (the rest is unbound)",
196 static const char * const bench_numa_usage
[] = {
197 "perf bench numa <options>",
201 static const char * const numa_usage
[] = {
202 "perf bench numa mem [<options>]",
206 static cpu_set_t
bind_to_cpu(int target_cpu
)
208 cpu_set_t orig_mask
, mask
;
211 ret
= sched_getaffinity(0, sizeof(orig_mask
), &orig_mask
);
216 if (target_cpu
== -1) {
219 for (cpu
= 0; cpu
< g
->p
.nr_cpus
; cpu
++)
222 BUG_ON(target_cpu
< 0 || target_cpu
>= g
->p
.nr_cpus
);
223 CPU_SET(target_cpu
, &mask
);
226 ret
= sched_setaffinity(0, sizeof(mask
), &mask
);
232 static cpu_set_t
bind_to_node(int target_node
)
234 int cpus_per_node
= g
->p
.nr_cpus
/g
->p
.nr_nodes
;
235 cpu_set_t orig_mask
, mask
;
239 BUG_ON(cpus_per_node
*g
->p
.nr_nodes
!= g
->p
.nr_cpus
);
240 BUG_ON(!cpus_per_node
);
242 ret
= sched_getaffinity(0, sizeof(orig_mask
), &orig_mask
);
247 if (target_node
== -1) {
248 for (cpu
= 0; cpu
< g
->p
.nr_cpus
; cpu
++)
251 int cpu_start
= (target_node
+ 0) * cpus_per_node
;
252 int cpu_stop
= (target_node
+ 1) * cpus_per_node
;
254 BUG_ON(cpu_stop
> g
->p
.nr_cpus
);
256 for (cpu
= cpu_start
; cpu
< cpu_stop
; cpu
++)
260 ret
= sched_setaffinity(0, sizeof(mask
), &mask
);
266 static void bind_to_cpumask(cpu_set_t mask
)
270 ret
= sched_setaffinity(0, sizeof(mask
), &mask
);
274 static void mempol_restore(void)
278 ret
= set_mempolicy(MPOL_DEFAULT
, NULL
, g
->p
.nr_nodes
-1);
283 static void bind_to_memnode(int node
)
285 unsigned long nodemask
;
291 BUG_ON(g
->p
.nr_nodes
> (int)sizeof(nodemask
));
292 nodemask
= 1L << node
;
294 ret
= set_mempolicy(MPOL_BIND
, &nodemask
, sizeof(nodemask
)*8);
295 dprintf("binding to node %d, mask: %016lx => %d\n", node
, nodemask
, ret
);
300 #define HPSIZE (2*1024*1024)
302 #define set_taskname(fmt...) \
306 snprintf(name, 20, fmt); \
307 prctl(PR_SET_NAME, name); \
310 static u8
*alloc_data(ssize_t bytes0
, int map_flags
,
311 int init_zero
, int init_cpu0
, int thp
, int init_random
)
321 /* Allocate and initialize all memory on CPU#0: */
323 orig_mask
= bind_to_node(0);
327 bytes
= bytes0
+ HPSIZE
;
329 buf
= (void *)mmap(0, bytes
, PROT_READ
|PROT_WRITE
, MAP_ANON
|map_flags
, -1, 0);
330 BUG_ON(buf
== (void *)-1);
332 if (map_flags
== MAP_PRIVATE
) {
334 ret
= madvise(buf
, bytes
, MADV_HUGEPAGE
);
335 if (ret
&& !g
->print_once
) {
337 printf("WARNING: Could not enable THP - do: 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled'\n");
341 ret
= madvise(buf
, bytes
, MADV_NOHUGEPAGE
);
342 if (ret
&& !g
->print_once
) {
344 printf("WARNING: Could not disable THP: run a CONFIG_TRANSPARENT_HUGEPAGE kernel?\n");
352 /* Initialize random contents, different in each word: */
354 u64
*wbuf
= (void *)buf
;
358 for (i
= 0; i
< bytes
/8; i
++)
363 /* Align to 2MB boundary: */
364 buf
= (void *)(((unsigned long)buf
+ HPSIZE
-1) & ~(HPSIZE
-1));
366 /* Restore affinity: */
368 bind_to_cpumask(orig_mask
);
375 static void free_data(void *data
, ssize_t bytes
)
382 ret
= munmap(data
, bytes
);
387 * Create a shared memory buffer that can be shared between processes, zeroed:
389 static void * zalloc_shared_data(ssize_t bytes
)
391 return alloc_data(bytes
, MAP_SHARED
, 1, g
->p
.init_cpu0
, g
->p
.thp
, g
->p
.init_random
);
395 * Create a shared memory buffer that can be shared between processes:
397 static void * setup_shared_data(ssize_t bytes
)
399 return alloc_data(bytes
, MAP_SHARED
, 0, g
->p
.init_cpu0
, g
->p
.thp
, g
->p
.init_random
);
403 * Allocate process-local memory - this will either be shared between
404 * threads of this process, or only be accessed by this thread:
406 static void * setup_private_data(ssize_t bytes
)
408 return alloc_data(bytes
, MAP_PRIVATE
, 0, g
->p
.init_cpu0
, g
->p
.thp
, g
->p
.init_random
);
412 * Return a process-shared (global) mutex:
414 static void init_global_mutex(pthread_mutex_t
*mutex
)
416 pthread_mutexattr_t attr
;
418 pthread_mutexattr_init(&attr
);
419 pthread_mutexattr_setpshared(&attr
, PTHREAD_PROCESS_SHARED
);
420 pthread_mutex_init(mutex
, &attr
);
423 static int parse_cpu_list(const char *arg
)
425 p0
.cpu_list_str
= strdup(arg
);
427 dprintf("got CPU list: {%s}\n", p0
.cpu_list_str
);
432 static void parse_setup_cpu_list(void)
434 struct thread_data
*td
;
438 if (!g
->p
.cpu_list_str
)
441 dprintf("g->p.nr_tasks: %d\n", g
->p
.nr_tasks
);
443 str0
= str
= strdup(g
->p
.cpu_list_str
);
448 tprintf("# binding tasks to CPUs:\n");
452 int bind_cpu
, bind_cpu_0
, bind_cpu_1
;
453 char *tok
, *tok_end
, *tok_step
, *tok_len
, *tok_mul
;
458 tok
= strsep(&str
, ",");
462 tok_end
= strstr(tok
, "-");
464 dprintf("\ntoken: {%s}, end: {%s}\n", tok
, tok_end
);
466 /* Single CPU specified: */
467 bind_cpu_0
= bind_cpu_1
= atol(tok
);
469 /* CPU range specified (for example: "5-11"): */
470 bind_cpu_0
= atol(tok
);
471 bind_cpu_1
= atol(tok_end
+ 1);
475 tok_step
= strstr(tok
, "#");
477 step
= atol(tok_step
+ 1);
478 BUG_ON(step
<= 0 || step
>= g
->p
.nr_cpus
);
483 * Eg: "--cpus 8_4-16#4" means: '--cpus 8_4,12_4,16_4',
484 * where the _4 means the next 4 CPUs are allowed.
487 tok_len
= strstr(tok
, "_");
489 bind_len
= atol(tok_len
+ 1);
490 BUG_ON(bind_len
<= 0 || bind_len
> g
->p
.nr_cpus
);
493 /* Multiplicator shortcut, "0x8" is a shortcut for: "0,0,0,0,0,0,0,0" */
495 tok_mul
= strstr(tok
, "x");
497 mul
= atol(tok_mul
+ 1);
501 dprintf("CPUs: %d_%d-%d#%dx%d\n", bind_cpu_0
, bind_len
, bind_cpu_1
, step
, mul
);
503 BUG_ON(bind_cpu_0
< 0 || bind_cpu_0
>= g
->p
.nr_cpus
);
504 BUG_ON(bind_cpu_1
< 0 || bind_cpu_1
>= g
->p
.nr_cpus
);
505 BUG_ON(bind_cpu_0
> bind_cpu_1
);
507 for (bind_cpu
= bind_cpu_0
; bind_cpu
<= bind_cpu_1
; bind_cpu
+= step
) {
510 for (i
= 0; i
< mul
; i
++) {
513 if (t
>= g
->p
.nr_tasks
) {
514 printf("\n# NOTE: ignoring bind CPUs starting at CPU#%d\n #", bind_cpu
);
522 tprintf("%2d/%d", bind_cpu
, bind_len
);
524 tprintf("%2d", bind_cpu
);
527 CPU_ZERO(&td
->bind_cpumask
);
528 for (cpu
= bind_cpu
; cpu
< bind_cpu
+bind_len
; cpu
++) {
529 BUG_ON(cpu
< 0 || cpu
>= g
->p
.nr_cpus
);
530 CPU_SET(cpu
, &td
->bind_cpumask
);
540 if (t
< g
->p
.nr_tasks
)
541 printf("# NOTE: %d tasks bound, %d tasks unbound\n", t
, g
->p
.nr_tasks
- t
);
546 static int parse_cpus_opt(const struct option
*opt __maybe_unused
,
547 const char *arg
, int unset __maybe_unused
)
552 return parse_cpu_list(arg
);
555 static int parse_node_list(const char *arg
)
557 p0
.node_list_str
= strdup(arg
);
559 dprintf("got NODE list: {%s}\n", p0
.node_list_str
);
564 static void parse_setup_node_list(void)
566 struct thread_data
*td
;
570 if (!g
->p
.node_list_str
)
573 dprintf("g->p.nr_tasks: %d\n", g
->p
.nr_tasks
);
575 str0
= str
= strdup(g
->p
.node_list_str
);
580 tprintf("# binding tasks to NODEs:\n");
584 int bind_node
, bind_node_0
, bind_node_1
;
585 char *tok
, *tok_end
, *tok_step
, *tok_mul
;
589 tok
= strsep(&str
, ",");
593 tok_end
= strstr(tok
, "-");
595 dprintf("\ntoken: {%s}, end: {%s}\n", tok
, tok_end
);
597 /* Single NODE specified: */
598 bind_node_0
= bind_node_1
= atol(tok
);
600 /* NODE range specified (for example: "5-11"): */
601 bind_node_0
= atol(tok
);
602 bind_node_1
= atol(tok_end
+ 1);
606 tok_step
= strstr(tok
, "#");
608 step
= atol(tok_step
+ 1);
609 BUG_ON(step
<= 0 || step
>= g
->p
.nr_nodes
);
612 /* Multiplicator shortcut, "0x8" is a shortcut for: "0,0,0,0,0,0,0,0" */
614 tok_mul
= strstr(tok
, "x");
616 mul
= atol(tok_mul
+ 1);
620 dprintf("NODEs: %d-%d #%d\n", bind_node_0
, bind_node_1
, step
);
622 BUG_ON(bind_node_0
< 0 || bind_node_0
>= g
->p
.nr_nodes
);
623 BUG_ON(bind_node_1
< 0 || bind_node_1
>= g
->p
.nr_nodes
);
624 BUG_ON(bind_node_0
> bind_node_1
);
626 for (bind_node
= bind_node_0
; bind_node
<= bind_node_1
; bind_node
+= step
) {
629 for (i
= 0; i
< mul
; i
++) {
630 if (t
>= g
->p
.nr_tasks
) {
631 printf("\n# NOTE: ignoring bind NODEs starting at NODE#%d\n", bind_node
);
637 tprintf(" %2d", bind_node
);
639 tprintf(",%2d", bind_node
);
641 td
->bind_node
= bind_node
;
650 if (t
< g
->p
.nr_tasks
)
651 printf("# NOTE: %d tasks mem-bound, %d tasks unbound\n", t
, g
->p
.nr_tasks
- t
);
656 static int parse_nodes_opt(const struct option
*opt __maybe_unused
,
657 const char *arg
, int unset __maybe_unused
)
662 return parse_node_list(arg
);
667 #define BIT(x) (1ul << x)
669 static inline uint32_t lfsr_32(uint32_t lfsr
)
671 const uint32_t taps
= BIT(1) | BIT(5) | BIT(6) | BIT(31);
672 return (lfsr
>>1) ^ ((0x0u
- (lfsr
& 0x1u
)) & taps
);
676 * Make sure there's real data dependency to RAM (when read
677 * accesses are enabled), so the compiler, the CPU and the
678 * kernel (KSM, zero page, etc.) cannot optimize away RAM
681 static inline u64
access_data(u64
*data
__attribute__((unused
)), u64 val
)
685 if (g
->p
.data_writes
)
691 * The worker process does two types of work, a forwards going
692 * loop and a backwards going loop.
694 * We do this so that on multiprocessor systems we do not create
695 * a 'train' of processing, with highly synchronized processes,
696 * skewing the whole benchmark.
698 static u64
do_work(u8
*__data
, long bytes
, int nr
, int nr_max
, int loop
, u64 val
)
700 long words
= bytes
/sizeof(u64
);
701 u64
*data
= (void *)__data
;
702 long chunk_0
, chunk_1
;
707 BUG_ON(!data
&& words
);
708 BUG_ON(data
&& !words
);
713 /* Very simple memset() work variant: */
714 if (g
->p
.data_zero_memset
&& !g
->p
.data_rand_walk
) {
719 /* Spread out by PID/TID nr and by loop nr: */
720 chunk_0
= words
/nr_max
;
721 chunk_1
= words
/g
->p
.nr_loops
;
722 off
= nr
*chunk_0
+ loop
*chunk_1
;
727 if (g
->p
.data_rand_walk
) {
728 u32 lfsr
= nr
+ loop
+ val
;
731 for (i
= 0; i
< words
/1024; i
++) {
734 lfsr
= lfsr_32(lfsr
);
736 start
= lfsr
% words
;
737 end
= min(start
+ 1024, words
-1);
739 if (g
->p
.data_zero_memset
) {
740 bzero(data
+ start
, (end
-start
) * sizeof(u64
));
742 for (j
= start
; j
< end
; j
++)
743 val
= access_data(data
+ j
, val
);
746 } else if (!g
->p
.data_backwards
|| (nr
+ loop
) & 1) {
752 /* Process data forwards: */
754 if (unlikely(d
>= d1
))
756 if (unlikely(d
== d0
))
759 val
= access_data(d
, val
);
764 /* Process data backwards: */
770 /* Process data forwards: */
772 if (unlikely(d
< data
))
774 if (unlikely(d
== d0
))
777 val
= access_data(d
, val
);
786 static void update_curr_cpu(int task_nr
, unsigned long bytes_worked
)
790 cpu
= sched_getcpu();
792 g
->threads
[task_nr
].curr_cpu
= cpu
;
793 prctl(0, bytes_worked
);
796 #define MAX_NR_NODES 64
799 * Count the number of nodes a process's threads
802 * A count of 1 means that the process is compressed
803 * to a single node. A count of g->p.nr_nodes means it's
804 * spread out on the whole system.
806 static int count_process_nodes(int process_nr
)
808 char node_present
[MAX_NR_NODES
] = { 0, };
812 for (t
= 0; t
< g
->p
.nr_threads
; t
++) {
813 struct thread_data
*td
;
817 task_nr
= process_nr
*g
->p
.nr_threads
+ t
;
818 td
= g
->threads
+ task_nr
;
820 node
= numa_node_of_cpu(td
->curr_cpu
);
821 node_present
[node
] = 1;
826 for (n
= 0; n
< MAX_NR_NODES
; n
++)
827 nodes
+= node_present
[n
];
833 * Count the number of distinct process-threads a node contains.
835 * A count of 1 means that the node contains only a single
836 * process. If all nodes on the system contain at most one
837 * process then we are well-converged.
839 static int count_node_processes(int node
)
844 for (p
= 0; p
< g
->p
.nr_proc
; p
++) {
845 for (t
= 0; t
< g
->p
.nr_threads
; t
++) {
846 struct thread_data
*td
;
850 task_nr
= p
*g
->p
.nr_threads
+ t
;
851 td
= g
->threads
+ task_nr
;
853 n
= numa_node_of_cpu(td
->curr_cpu
);
864 static void calc_convergence_compression(int *strong
)
866 unsigned int nodes_min
, nodes_max
;
872 for (p
= 0; p
< g
->p
.nr_proc
; p
++) {
873 unsigned int nodes
= count_process_nodes(p
);
875 nodes_min
= min(nodes
, nodes_min
);
876 nodes_max
= max(nodes
, nodes_max
);
879 /* Strong convergence: all threads compress on a single node: */
880 if (nodes_min
== 1 && nodes_max
== 1) {
884 tprintf(" {%d-%d}", nodes_min
, nodes_max
);
888 static void calc_convergence(double runtime_ns_max
, double *convergence
)
890 unsigned int loops_done_min
, loops_done_max
;
892 int nodes
[MAX_NR_NODES
];
903 if (!g
->p
.show_convergence
&& !g
->p
.measure_convergence
)
906 for (node
= 0; node
< g
->p
.nr_nodes
; node
++)
912 for (t
= 0; t
< g
->p
.nr_tasks
; t
++) {
913 struct thread_data
*td
= g
->threads
+ t
;
914 unsigned int loops_done
;
918 /* Not all threads have written it yet: */
922 node
= numa_node_of_cpu(cpu
);
926 loops_done
= td
->loops_done
;
927 loops_done_min
= min(loops_done
, loops_done_min
);
928 loops_done_max
= max(loops_done
, loops_done_max
);
932 nr_min
= g
->p
.nr_tasks
;
935 for (node
= 0; node
< g
->p
.nr_nodes
; node
++) {
937 nr_min
= min(nr
, nr_min
);
938 nr_max
= max(nr
, nr_max
);
941 BUG_ON(nr_min
> nr_max
);
943 BUG_ON(sum
> g
->p
.nr_tasks
);
945 if (0 && (sum
< g
->p
.nr_tasks
))
949 * Count the number of distinct process groups present
950 * on nodes - when we are converged this will decrease
955 for (node
= 0; node
< g
->p
.nr_nodes
; node
++) {
956 int processes
= count_node_processes(node
);
959 tprintf(" %2d/%-2d", nr
, processes
);
961 process_groups
+= processes
;
964 distance
= nr_max
- nr_min
;
966 tprintf(" [%2d/%-2d]", distance
, process_groups
);
968 tprintf(" l:%3d-%-3d (%3d)",
969 loops_done_min
, loops_done_max
, loops_done_max
-loops_done_min
);
971 if (loops_done_min
&& loops_done_max
) {
972 double skew
= 1.0 - (double)loops_done_min
/loops_done_max
;
974 tprintf(" [%4.1f%%]", skew
* 100.0);
977 calc_convergence_compression(&strong
);
979 if (strong
&& process_groups
== g
->p
.nr_proc
) {
981 *convergence
= runtime_ns_max
;
982 tprintf(" (%6.1fs converged)\n", *convergence
/1e9
);
983 if (g
->p
.measure_convergence
) {
984 g
->all_converged
= true;
990 tprintf(" (%6.1fs de-converged)", runtime_ns_max
/1e9
);
997 static void show_summary(double runtime_ns_max
, int l
, double *convergence
)
999 tprintf("\r # %5.1f%% [%.1f mins]",
1000 (double)(l
+1)/g
->p
.nr_loops
*100.0, runtime_ns_max
/1e9
/ 60.0);
1002 calc_convergence(runtime_ns_max
, convergence
);
1004 if (g
->p
.show_details
>= 0)
1008 static void *worker_thread(void *__tdata
)
1010 struct thread_data
*td
= __tdata
;
1011 struct timeval start0
, start
, stop
, diff
;
1012 int process_nr
= td
->process_nr
;
1013 int thread_nr
= td
->thread_nr
;
1014 unsigned long last_perturbance
;
1015 int task_nr
= td
->task_nr
;
1016 int details
= g
->p
.show_details
;
1017 int first_task
, last_task
;
1018 double convergence
= 0;
1020 double runtime_ns_max
;
1028 bind_to_cpumask(td
->bind_cpumask
);
1029 bind_to_memnode(td
->bind_node
);
1031 set_taskname("thread %d/%d", process_nr
, thread_nr
);
1033 global_data
= g
->data
;
1034 process_data
= td
->process_data
;
1035 thread_data
= setup_private_data(g
->p
.bytes_thread
);
1040 if (process_nr
== g
->p
.nr_proc
-1 && thread_nr
== g
->p
.nr_threads
-1)
1044 if (process_nr
== 0 && thread_nr
== 0)
1048 printf("# thread %2d / %2d global mem: %p, process mem: %p, thread mem: %p\n",
1049 process_nr
, thread_nr
, global_data
, process_data
, thread_data
);
1052 if (g
->p
.serialize_startup
) {
1053 pthread_mutex_lock(&g
->startup_mutex
);
1054 g
->nr_tasks_started
++;
1055 pthread_mutex_unlock(&g
->startup_mutex
);
1057 /* Here we will wait for the main process to start us all at once: */
1058 pthread_mutex_lock(&g
->start_work_mutex
);
1059 g
->nr_tasks_working
++;
1061 /* Last one wake the main process: */
1062 if (g
->nr_tasks_working
== g
->p
.nr_tasks
)
1063 pthread_mutex_unlock(&g
->startup_done_mutex
);
1065 pthread_mutex_unlock(&g
->start_work_mutex
);
1068 gettimeofday(&start0
, NULL
);
1070 start
= stop
= start0
;
1071 last_perturbance
= start
.tv_sec
;
1073 for (l
= 0; l
< g
->p
.nr_loops
; l
++) {
1079 val
+= do_work(global_data
, g
->p
.bytes_global
, process_nr
, g
->p
.nr_proc
, l
, val
);
1080 val
+= do_work(process_data
, g
->p
.bytes_process
, thread_nr
, g
->p
.nr_threads
, l
, val
);
1081 val
+= do_work(thread_data
, g
->p
.bytes_thread
, 0, 1, l
, val
);
1083 if (g
->p
.sleep_usecs
) {
1084 pthread_mutex_lock(td
->process_lock
);
1085 usleep(g
->p
.sleep_usecs
);
1086 pthread_mutex_unlock(td
->process_lock
);
1089 * Amount of work to be done under a process-global lock:
1091 if (g
->p
.bytes_process_locked
) {
1092 pthread_mutex_lock(td
->process_lock
);
1093 val
+= do_work(process_data
, g
->p
.bytes_process_locked
, thread_nr
, g
->p
.nr_threads
, l
, val
);
1094 pthread_mutex_unlock(td
->process_lock
);
1097 work_done
= g
->p
.bytes_global
+ g
->p
.bytes_process
+
1098 g
->p
.bytes_process_locked
+ g
->p
.bytes_thread
;
1100 update_curr_cpu(task_nr
, work_done
);
1101 bytes_done
+= work_done
;
1103 if (details
< 0 && !g
->p
.perturb_secs
&& !g
->p
.measure_convergence
&& !g
->p
.nr_secs
)
1108 gettimeofday(&stop
, NULL
);
1110 /* Check whether our max runtime timed out: */
1112 timersub(&stop
, &start0
, &diff
);
1113 if (diff
.tv_sec
>= g
->p
.nr_secs
) {
1114 g
->stop_work
= true;
1119 /* Update the summary at most once per second: */
1120 if (start
.tv_sec
== stop
.tv_sec
)
1124 * Perturb the first task's equilibrium every g->p.perturb_secs seconds,
1125 * by migrating to CPU#0:
1127 if (first_task
&& g
->p
.perturb_secs
&& (int)(stop
.tv_sec
- last_perturbance
) >= g
->p
.perturb_secs
) {
1128 cpu_set_t orig_mask
;
1132 last_perturbance
= stop
.tv_sec
;
1135 * Depending on where we are running, move into
1136 * the other half of the system, to create some
1139 this_cpu
= g
->threads
[task_nr
].curr_cpu
;
1140 if (this_cpu
< g
->p
.nr_cpus
/2)
1141 target_cpu
= g
->p
.nr_cpus
-1;
1145 orig_mask
= bind_to_cpu(target_cpu
);
1147 /* Here we are running on the target CPU already */
1149 printf(" (injecting perturbalance, moved to CPU#%d)\n", target_cpu
);
1151 bind_to_cpumask(orig_mask
);
1155 timersub(&stop
, &start
, &diff
);
1156 runtime_ns_max
= diff
.tv_sec
* 1000000000;
1157 runtime_ns_max
+= diff
.tv_usec
* 1000;
1160 printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
1161 process_nr
, thread_nr
, runtime_ns_max
/ bytes_done
, val
);
1168 timersub(&stop
, &start0
, &diff
);
1169 runtime_ns_max
= diff
.tv_sec
* 1000000000ULL;
1170 runtime_ns_max
+= diff
.tv_usec
* 1000ULL;
1172 show_summary(runtime_ns_max
, l
, &convergence
);
1175 gettimeofday(&stop
, NULL
);
1176 timersub(&stop
, &start0
, &diff
);
1177 td
->runtime_ns
= diff
.tv_sec
* 1000000000ULL;
1178 td
->runtime_ns
+= diff
.tv_usec
* 1000ULL;
1180 free_data(thread_data
, g
->p
.bytes_thread
);
1182 pthread_mutex_lock(&g
->stop_work_mutex
);
1183 g
->bytes_done
+= bytes_done
;
1184 pthread_mutex_unlock(&g
->stop_work_mutex
);
1190 * A worker process starts a couple of threads:
1192 static void worker_process(int process_nr
)
1194 pthread_mutex_t process_lock
;
1195 struct thread_data
*td
;
1196 pthread_t
*pthreads
;
1202 pthread_mutex_init(&process_lock
, NULL
);
1203 set_taskname("process %d", process_nr
);
1206 * Pick up the memory policy and the CPU binding of our first thread,
1207 * so that we initialize memory accordingly:
1209 task_nr
= process_nr
*g
->p
.nr_threads
;
1210 td
= g
->threads
+ task_nr
;
1212 bind_to_memnode(td
->bind_node
);
1213 bind_to_cpumask(td
->bind_cpumask
);
1215 pthreads
= zalloc(g
->p
.nr_threads
* sizeof(pthread_t
));
1216 process_data
= setup_private_data(g
->p
.bytes_process
);
1218 if (g
->p
.show_details
>= 3) {
1219 printf(" # process %2d global mem: %p, process mem: %p\n",
1220 process_nr
, g
->data
, process_data
);
1223 for (t
= 0; t
< g
->p
.nr_threads
; t
++) {
1224 task_nr
= process_nr
*g
->p
.nr_threads
+ t
;
1225 td
= g
->threads
+ task_nr
;
1227 td
->process_data
= process_data
;
1228 td
->process_nr
= process_nr
;
1230 td
->task_nr
= task_nr
;
1233 td
->process_lock
= &process_lock
;
1235 ret
= pthread_create(pthreads
+ t
, NULL
, worker_thread
, td
);
1239 for (t
= 0; t
< g
->p
.nr_threads
; t
++) {
1240 ret
= pthread_join(pthreads
[t
], NULL
);
1244 free_data(process_data
, g
->p
.bytes_process
);
1248 static void print_summary(void)
1250 if (g
->p
.show_details
< 0)
1254 printf(" # %d %s will execute (on %d nodes, %d CPUs):\n",
1255 g
->p
.nr_tasks
, g
->p
.nr_tasks
== 1 ? "task" : "tasks", g
->p
.nr_nodes
, g
->p
.nr_cpus
);
1256 printf(" # %5dx %5ldMB global shared mem operations\n",
1257 g
->p
.nr_loops
, g
->p
.bytes_global
/1024/1024);
1258 printf(" # %5dx %5ldMB process shared mem operations\n",
1259 g
->p
.nr_loops
, g
->p
.bytes_process
/1024/1024);
1260 printf(" # %5dx %5ldMB thread local mem operations\n",
1261 g
->p
.nr_loops
, g
->p
.bytes_thread
/1024/1024);
1265 printf("\n ###\n"); fflush(stdout
);
1268 static void init_thread_data(void)
1270 ssize_t size
= sizeof(*g
->threads
)*g
->p
.nr_tasks
;
1273 g
->threads
= zalloc_shared_data(size
);
1275 for (t
= 0; t
< g
->p
.nr_tasks
; t
++) {
1276 struct thread_data
*td
= g
->threads
+ t
;
1279 /* Allow all nodes by default: */
1282 /* Allow all CPUs by default: */
1283 CPU_ZERO(&td
->bind_cpumask
);
1284 for (cpu
= 0; cpu
< g
->p
.nr_cpus
; cpu
++)
1285 CPU_SET(cpu
, &td
->bind_cpumask
);
1289 static void deinit_thread_data(void)
1291 ssize_t size
= sizeof(*g
->threads
)*g
->p
.nr_tasks
;
1293 free_data(g
->threads
, size
);
1296 static int init(void)
1298 g
= (void *)alloc_data(sizeof(*g
), MAP_SHARED
, 1, 0, 0 /* THP */, 0);
1300 /* Copy over options: */
1303 g
->p
.nr_cpus
= numa_num_configured_cpus();
1305 g
->p
.nr_nodes
= numa_max_node() + 1;
1307 /* char array in count_process_nodes(): */
1308 BUG_ON(g
->p
.nr_nodes
> MAX_NR_NODES
|| g
->p
.nr_nodes
< 0);
1310 if (g
->p
.show_quiet
&& !g
->p
.show_details
)
1311 g
->p
.show_details
= -1;
1313 /* Some memory should be specified: */
1314 if (!g
->p
.mb_global_str
&& !g
->p
.mb_proc_str
&& !g
->p
.mb_thread_str
)
1317 if (g
->p
.mb_global_str
) {
1318 g
->p
.mb_global
= atof(g
->p
.mb_global_str
);
1319 BUG_ON(g
->p
.mb_global
< 0);
1322 if (g
->p
.mb_proc_str
) {
1323 g
->p
.mb_proc
= atof(g
->p
.mb_proc_str
);
1324 BUG_ON(g
->p
.mb_proc
< 0);
1327 if (g
->p
.mb_proc_locked_str
) {
1328 g
->p
.mb_proc_locked
= atof(g
->p
.mb_proc_locked_str
);
1329 BUG_ON(g
->p
.mb_proc_locked
< 0);
1330 BUG_ON(g
->p
.mb_proc_locked
> g
->p
.mb_proc
);
1333 if (g
->p
.mb_thread_str
) {
1334 g
->p
.mb_thread
= atof(g
->p
.mb_thread_str
);
1335 BUG_ON(g
->p
.mb_thread
< 0);
1338 BUG_ON(g
->p
.nr_threads
<= 0);
1339 BUG_ON(g
->p
.nr_proc
<= 0);
1341 g
->p
.nr_tasks
= g
->p
.nr_proc
*g
->p
.nr_threads
;
1343 g
->p
.bytes_global
= g
->p
.mb_global
*1024L*1024L;
1344 g
->p
.bytes_process
= g
->p
.mb_proc
*1024L*1024L;
1345 g
->p
.bytes_process_locked
= g
->p
.mb_proc_locked
*1024L*1024L;
1346 g
->p
.bytes_thread
= g
->p
.mb_thread
*1024L*1024L;
1348 g
->data
= setup_shared_data(g
->p
.bytes_global
);
1350 /* Startup serialization: */
1351 init_global_mutex(&g
->start_work_mutex
);
1352 init_global_mutex(&g
->startup_mutex
);
1353 init_global_mutex(&g
->startup_done_mutex
);
1354 init_global_mutex(&g
->stop_work_mutex
);
1359 parse_setup_cpu_list();
1360 parse_setup_node_list();
1368 static void deinit(void)
1370 free_data(g
->data
, g
->p
.bytes_global
);
1373 deinit_thread_data();
1375 free_data(g
, sizeof(*g
));
1380 * Print a short or long result, depending on the verbosity setting:
1382 static void print_res(const char *name
, double val
,
1383 const char *txt_unit
, const char *txt_short
, const char *txt_long
)
1388 if (g
->p
.show_quiet
)
1389 printf(" %-30s %15.3f, %-15s %s\n", name
, val
, txt_unit
, txt_short
);
1391 printf(" %14.3f %s\n", val
, txt_long
);
1394 static int __bench_numa(const char *name
)
1396 struct timeval start
, stop
, diff
;
1397 u64 runtime_ns_min
, runtime_ns_sum
;
1398 pid_t
*pids
, pid
, wpid
;
1399 double delta_runtime
;
1401 double runtime_sec_max
;
1402 double runtime_sec_min
;
1410 pids
= zalloc(g
->p
.nr_proc
* sizeof(*pids
));
1413 /* All threads try to acquire it, this way we can wait for them to start up: */
1414 pthread_mutex_lock(&g
->start_work_mutex
);
1416 if (g
->p
.serialize_startup
) {
1418 tprintf(" # Startup synchronization: ..."); fflush(stdout
);
1421 gettimeofday(&start
, NULL
);
1423 for (i
= 0; i
< g
->p
.nr_proc
; i
++) {
1425 dprintf(" # process %2d: PID %d\n", i
, pid
);
1429 /* Child process: */
1437 /* Wait for all the threads to start up: */
1438 while (g
->nr_tasks_started
!= g
->p
.nr_tasks
)
1441 BUG_ON(g
->nr_tasks_started
!= g
->p
.nr_tasks
);
1443 if (g
->p
.serialize_startup
) {
1446 pthread_mutex_lock(&g
->startup_done_mutex
);
1448 /* This will start all threads: */
1449 pthread_mutex_unlock(&g
->start_work_mutex
);
1451 /* This mutex is locked - the last started thread will wake us: */
1452 pthread_mutex_lock(&g
->startup_done_mutex
);
1454 gettimeofday(&stop
, NULL
);
1456 timersub(&stop
, &start
, &diff
);
1458 startup_sec
= diff
.tv_sec
* 1000000000.0;
1459 startup_sec
+= diff
.tv_usec
* 1000.0;
1462 tprintf(" threads initialized in %.6f seconds.\n", startup_sec
);
1466 pthread_mutex_unlock(&g
->startup_done_mutex
);
1468 gettimeofday(&start
, NULL
);
1471 /* Parent process: */
1474 for (i
= 0; i
< g
->p
.nr_proc
; i
++) {
1475 wpid
= waitpid(pids
[i
], &wait_stat
, 0);
1477 BUG_ON(!WIFEXITED(wait_stat
));
1482 runtime_ns_min
= -1LL;
1484 for (t
= 0; t
< g
->p
.nr_tasks
; t
++) {
1485 u64 thread_runtime_ns
= g
->threads
[t
].runtime_ns
;
1487 runtime_ns_sum
+= thread_runtime_ns
;
1488 runtime_ns_min
= min(thread_runtime_ns
, runtime_ns_min
);
1491 gettimeofday(&stop
, NULL
);
1492 timersub(&stop
, &start
, &diff
);
1494 BUG_ON(bench_format
!= BENCH_FORMAT_DEFAULT
);
1496 tprintf("\n ###\n");
1499 runtime_sec_max
= diff
.tv_sec
* 1000000000.0;
1500 runtime_sec_max
+= diff
.tv_usec
* 1000.0;
1501 runtime_sec_max
/= 1e9
;
1503 runtime_sec_min
= runtime_ns_min
/1e9
;
1505 bytes
= g
->bytes_done
;
1506 runtime_avg
= (double)runtime_ns_sum
/ g
->p
.nr_tasks
/ 1e9
;
1508 if (g
->p
.measure_convergence
) {
1509 print_res(name
, runtime_sec_max
,
1510 "secs,", "NUMA-convergence-latency", "secs latency to NUMA-converge");
1513 print_res(name
, runtime_sec_max
,
1514 "secs,", "runtime-max/thread", "secs slowest (max) thread-runtime");
1516 print_res(name
, runtime_sec_min
,
1517 "secs,", "runtime-min/thread", "secs fastest (min) thread-runtime");
1519 print_res(name
, runtime_avg
,
1520 "secs,", "runtime-avg/thread", "secs average thread-runtime");
1522 delta_runtime
= (runtime_sec_max
- runtime_sec_min
)/2.0;
1523 print_res(name
, delta_runtime
/ runtime_sec_max
* 100.0,
1524 "%,", "spread-runtime/thread", "% difference between max/avg runtime");
1526 print_res(name
, bytes
/ g
->p
.nr_tasks
/ 1e9
,
1527 "GB,", "data/thread", "GB data processed, per thread");
1529 print_res(name
, bytes
/ 1e9
,
1530 "GB,", "data-total", "GB data processed, total");
1532 print_res(name
, runtime_sec_max
* 1e9
/ (bytes
/ g
->p
.nr_tasks
),
1533 "nsecs,", "runtime/byte/thread","nsecs/byte/thread runtime");
1535 print_res(name
, bytes
/ g
->p
.nr_tasks
/ 1e9
/ runtime_sec_max
,
1536 "GB/sec,", "thread-speed", "GB/sec/thread speed");
1538 print_res(name
, bytes
/ runtime_sec_max
/ 1e9
,
1539 "GB/sec,", "total-speed", "GB/sec total speed");
1550 static int command_size(const char **argv
)
1559 BUG_ON(size
>= MAX_ARGS
);
1564 static void init_params(struct params
*p
, const char *name
, int argc
, const char **argv
)
1568 printf("\n # Running %s \"perf bench numa", name
);
1570 for (i
= 0; i
< argc
; i
++)
1571 printf(" %s", argv
[i
]);
1575 memset(p
, 0, sizeof(*p
));
1577 /* Initialize nonzero defaults: */
1579 p
->serialize_startup
= 1;
1580 p
->data_reads
= true;
1581 p
->data_writes
= true;
1582 p
->data_backwards
= true;
1583 p
->data_rand_walk
= true;
1585 p
->init_random
= true;
1588 static int run_bench_numa(const char *name
, const char **argv
)
1590 int argc
= command_size(argv
);
1592 init_params(&p0
, name
, argc
, argv
);
1593 argc
= parse_options(argc
, argv
, options
, bench_numa_usage
, 0);
1597 if (__bench_numa(name
))
1603 usage_with_options(numa_usage
, options
);
1607 #define OPT_BW_RAM "-s", "20", "-zZq", "--thp", " 1", "--no-data_rand_walk"
1608 #define OPT_BW_RAM_NOTHP OPT_BW_RAM, "--thp", "-1"
1610 #define OPT_CONV "-s", "100", "-zZ0qcm", "--thp", " 1"
1611 #define OPT_CONV_NOTHP OPT_CONV, "--thp", "-1"
1613 #define OPT_BW "-s", "20", "-zZ0q", "--thp", " 1"
1614 #define OPT_BW_NOTHP OPT_BW, "--thp", "-1"
1617 * The built-in test-suite executed by "perf bench numa -a".
1619 * (A minimum of 4 nodes and 16 GB of RAM is recommended.)
1621 static const char *tests
[][MAX_ARGS
] = {
1622 /* Basic single-stream NUMA bandwidth measurements: */
1623 { "RAM-bw-local,", "mem", "-p", "1", "-t", "1", "-P", "1024",
1624 "-C" , "0", "-M", "0", OPT_BW_RAM
},
1625 { "RAM-bw-local-NOTHP,",
1626 "mem", "-p", "1", "-t", "1", "-P", "1024",
1627 "-C" , "0", "-M", "0", OPT_BW_RAM_NOTHP
},
1628 { "RAM-bw-remote,", "mem", "-p", "1", "-t", "1", "-P", "1024",
1629 "-C" , "0", "-M", "1", OPT_BW_RAM
},
1631 /* 2-stream NUMA bandwidth measurements: */
1632 { "RAM-bw-local-2x,", "mem", "-p", "2", "-t", "1", "-P", "1024",
1633 "-C", "0,2", "-M", "0x2", OPT_BW_RAM
},
1634 { "RAM-bw-remote-2x,", "mem", "-p", "2", "-t", "1", "-P", "1024",
1635 "-C", "0,2", "-M", "1x2", OPT_BW_RAM
},
1637 /* Cross-stream NUMA bandwidth measurement: */
1638 { "RAM-bw-cross,", "mem", "-p", "2", "-t", "1", "-P", "1024",
1639 "-C", "0,8", "-M", "1,0", OPT_BW_RAM
},
1641 /* Convergence latency measurements: */
1642 { " 1x3-convergence,", "mem", "-p", "1", "-t", "3", "-P", "512", OPT_CONV
},
1643 { " 1x4-convergence,", "mem", "-p", "1", "-t", "4", "-P", "512", OPT_CONV
},
1644 { " 1x6-convergence,", "mem", "-p", "1", "-t", "6", "-P", "1020", OPT_CONV
},
1645 { " 2x3-convergence,", "mem", "-p", "3", "-t", "3", "-P", "1020", OPT_CONV
},
1646 { " 3x3-convergence,", "mem", "-p", "3", "-t", "3", "-P", "1020", OPT_CONV
},
1647 { " 4x4-convergence,", "mem", "-p", "4", "-t", "4", "-P", "512", OPT_CONV
},
1648 { " 4x4-convergence-NOTHP,",
1649 "mem", "-p", "4", "-t", "4", "-P", "512", OPT_CONV_NOTHP
},
1650 { " 4x6-convergence,", "mem", "-p", "4", "-t", "6", "-P", "1020", OPT_CONV
},
1651 { " 4x8-convergence,", "mem", "-p", "4", "-t", "8", "-P", "512", OPT_CONV
},
1652 { " 8x4-convergence,", "mem", "-p", "8", "-t", "4", "-P", "512", OPT_CONV
},
1653 { " 8x4-convergence-NOTHP,",
1654 "mem", "-p", "8", "-t", "4", "-P", "512", OPT_CONV_NOTHP
},
1655 { " 3x1-convergence,", "mem", "-p", "3", "-t", "1", "-P", "512", OPT_CONV
},
1656 { " 4x1-convergence,", "mem", "-p", "4", "-t", "1", "-P", "512", OPT_CONV
},
1657 { " 8x1-convergence,", "mem", "-p", "8", "-t", "1", "-P", "512", OPT_CONV
},
1658 { "16x1-convergence,", "mem", "-p", "16", "-t", "1", "-P", "256", OPT_CONV
},
1659 { "32x1-convergence,", "mem", "-p", "32", "-t", "1", "-P", "128", OPT_CONV
},
1661 /* Various NUMA process/thread layout bandwidth measurements: */
1662 { " 2x1-bw-process,", "mem", "-p", "2", "-t", "1", "-P", "1024", OPT_BW
},
1663 { " 3x1-bw-process,", "mem", "-p", "3", "-t", "1", "-P", "1024", OPT_BW
},
1664 { " 4x1-bw-process,", "mem", "-p", "4", "-t", "1", "-P", "1024", OPT_BW
},
1665 { " 8x1-bw-process,", "mem", "-p", "8", "-t", "1", "-P", " 512", OPT_BW
},
1666 { " 8x1-bw-process-NOTHP,",
1667 "mem", "-p", "8", "-t", "1", "-P", " 512", OPT_BW_NOTHP
},
1668 { "16x1-bw-process,", "mem", "-p", "16", "-t", "1", "-P", "256", OPT_BW
},
1670 { " 4x1-bw-thread,", "mem", "-p", "1", "-t", "4", "-T", "256", OPT_BW
},
1671 { " 8x1-bw-thread,", "mem", "-p", "1", "-t", "8", "-T", "256", OPT_BW
},
1672 { "16x1-bw-thread,", "mem", "-p", "1", "-t", "16", "-T", "128", OPT_BW
},
1673 { "32x1-bw-thread,", "mem", "-p", "1", "-t", "32", "-T", "64", OPT_BW
},
1675 { " 2x3-bw-thread,", "mem", "-p", "2", "-t", "3", "-P", "512", OPT_BW
},
1676 { " 4x4-bw-thread,", "mem", "-p", "4", "-t", "4", "-P", "512", OPT_BW
},
1677 { " 4x6-bw-thread,", "mem", "-p", "4", "-t", "6", "-P", "512", OPT_BW
},
1678 { " 4x8-bw-thread,", "mem", "-p", "4", "-t", "8", "-P", "512", OPT_BW
},
1679 { " 4x8-bw-thread-NOTHP,",
1680 "mem", "-p", "4", "-t", "8", "-P", "512", OPT_BW_NOTHP
},
1681 { " 3x3-bw-thread,", "mem", "-p", "3", "-t", "3", "-P", "512", OPT_BW
},
1682 { " 5x5-bw-thread,", "mem", "-p", "5", "-t", "5", "-P", "512", OPT_BW
},
1684 { "2x16-bw-thread,", "mem", "-p", "2", "-t", "16", "-P", "512", OPT_BW
},
1685 { "1x32-bw-thread,", "mem", "-p", "1", "-t", "32", "-P", "2048", OPT_BW
},
1687 { "numa02-bw,", "mem", "-p", "1", "-t", "32", "-T", "32", OPT_BW
},
1688 { "numa02-bw-NOTHP,", "mem", "-p", "1", "-t", "32", "-T", "32", OPT_BW_NOTHP
},
1689 { "numa01-bw-thread,", "mem", "-p", "2", "-t", "16", "-T", "192", OPT_BW
},
1690 { "numa01-bw-thread-NOTHP,",
1691 "mem", "-p", "2", "-t", "16", "-T", "192", OPT_BW_NOTHP
},
1694 static int bench_all(void)
1696 int nr
= ARRAY_SIZE(tests
);
1700 ret
= system("echo ' #'; echo ' # Running test on: '$(uname -a); echo ' #'");
1703 for (i
= 0; i
< nr
; i
++) {
1704 if (run_bench_numa(tests
[i
][0], tests
[i
] + 1))
1713 int bench_numa(int argc
, const char **argv
, const char *prefix __maybe_unused
)
1715 init_params(&p0
, "main,", argc
, argv
);
1716 argc
= parse_options(argc
, argv
, options
, bench_numa_usage
, 0);
1723 if (__bench_numa(NULL
))
1729 usage_with_options(numa_usage
, options
);