Blame view

tools/perf/bench/mem-functions.c 8.6 KB
827f3b497   Hitoshi Mitake   perf bench: Add m...
1
2
3
  /*
   * mem-memcpy.c
   *
13839ec49   Ingo Molnar   perf bench: Impro...
4
   * Simple memcpy() and memset() benchmarks
827f3b497   Hitoshi Mitake   perf bench: Add m...
5
6
7
   *
   * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
   */
827f3b497   Hitoshi Mitake   perf bench: Add m...
8

c2a218c63   Arnaldo Carvalho de Melo   perf bench: Remov...
9
  #include "debug.h"
827f3b497   Hitoshi Mitake   perf bench: Add m...
10
11
  #include "../perf.h"
  #include "../util/util.h"
4b6ab94ea   Josh Poimboeuf   perf subcmd: Crea...
12
  #include <subcmd/parse-options.h>
827f3b497   Hitoshi Mitake   perf bench: Add m...
13
  #include "../util/header.h"
57480d2cd   Yann Droneaud   perf tools: Enabl...
14
  #include "../util/cloexec.h"
a067558e2   Arnaldo Carvalho de Melo   perf tools: Move ...
15
  #include "../util/string2.h"
827f3b497   Hitoshi Mitake   perf bench: Add m...
16
  #include "bench.h"
49ce8fc65   Hitoshi Mitake   perf bench: Print...
17
  #include "mem-memcpy-arch.h"
5bce1a577   Rabin Vincent   perf bench: Merge...
18
  #include "mem-memset-arch.h"
827f3b497   Hitoshi Mitake   perf bench: Add m...
19
20
21
22
23
24
  
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <sys/time.h>
  #include <errno.h>
f2b91be73   Arnaldo Carvalho de Melo   perf bench mem: U...
25
  #include <linux/time64.h>
827f3b497   Hitoshi Mitake   perf bench: Add m...
26
27
  
  #define K 1024
a69b4f741   Ingo Molnar   perf bench mem: F...
28
  static const char	*size_str	= "1MB";
2f211c84a   Ingo Molnar   perf bench mem: R...
29
  static const char	*function_str	= "all";
b0d22e52e   Ingo Molnar   perf bench: Harmo...
30
  static int		nr_loops	= 1;
b14f2d357   Ingo Molnar   perf bench mem: C...
31
32
  static bool		use_cycles;
  static int		cycles_fd;
827f3b497   Hitoshi Mitake   perf bench: Add m...
33
34
  
  static const struct option options[] = {
b0d22e52e   Ingo Molnar   perf bench: Harmo...
35
  	OPT_STRING('s', "size", &size_str, "1MB",
a69b4f741   Ingo Molnar   perf bench mem: F...
36
  		    "Specify the size of the memory buffers. "
13b1fdce8   Ingo Molnar   perf bench mem: I...
37
  		    "Available units: B, KB, MB, GB and TB (case insensitive)"),
2f211c84a   Ingo Molnar   perf bench mem: R...
38
39
  	OPT_STRING('f', "function", &function_str, "all",
  		    "Specify the function to run, \"all\" runs all available functions, \"help\" lists them"),
13b1fdce8   Ingo Molnar   perf bench mem: I...
40

b0d22e52e   Ingo Molnar   perf bench: Harmo...
41
42
  	OPT_INTEGER('l', "nr_loops", &nr_loops,
  		    "Specify the number of loops to run. (default: 1)"),
13b1fdce8   Ingo Molnar   perf bench mem: I...
43

b14f2d357   Ingo Molnar   perf bench mem: C...
44
45
  	OPT_BOOLEAN('c', "cycles", &use_cycles,
  		    "Use a cycles event instead of gettimeofday() to measure performance"),
13b1fdce8   Ingo Molnar   perf bench mem: I...
46

827f3b497   Hitoshi Mitake   perf bench: Add m...
47
48
  	OPT_END()
  };
49ce8fc65   Hitoshi Mitake   perf bench: Print...
49
  typedef void *(*memcpy_t)(void *, const void *, size_t);
5bce1a577   Rabin Vincent   perf bench: Merge...
50
  typedef void *(*memset_t)(void *, int, size_t);
49ce8fc65   Hitoshi Mitake   perf bench: Print...
51

2f211c84a   Ingo Molnar   perf bench mem: R...
52
  struct function {
827f3b497   Hitoshi Mitake   perf bench: Add m...
53
54
  	const char *name;
  	const char *desc;
308197b94   Rabin Vincent   perf bench: Prepa...
55
56
  	union {
  		memcpy_t memcpy;
5bce1a577   Rabin Vincent   perf bench: Merge...
57
  		memset_t memset;
308197b94   Rabin Vincent   perf bench: Prepa...
58
  	} fn;
827f3b497   Hitoshi Mitake   perf bench: Add m...
59
  };
17d7a1123   Hitoshi Mitake   perf bench: Fix c...
60
  static struct perf_event_attr cycle_attr = {
12eac0bf0   Hitoshi Mitake   perf bench: Make ...
61
62
  	.type		= PERF_TYPE_HARDWARE,
  	.config		= PERF_COUNT_HW_CPU_CYCLES
827f3b497   Hitoshi Mitake   perf bench: Add m...
63
  };
c2a218c63   Arnaldo Carvalho de Melo   perf bench: Remov...
64
  static int init_cycles(void)
827f3b497   Hitoshi Mitake   perf bench: Add m...
65
  {
b14f2d357   Ingo Molnar   perf bench mem: C...
66
  	cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
12eac0bf0   Hitoshi Mitake   perf bench: Make ...
67

c2a218c63   Arnaldo Carvalho de Melo   perf bench: Remov...
68
69
70
71
72
73
74
  	if (cycles_fd < 0 && errno == ENOSYS) {
  		pr_debug("No CONFIG_PERF_EVENTS=y kernel support configured?
  ");
  		return -1;
  	}
  
  	return cycles_fd;
827f3b497   Hitoshi Mitake   perf bench: Add m...
75
  }
b14f2d357   Ingo Molnar   perf bench mem: C...
76
  static u64 get_cycles(void)
827f3b497   Hitoshi Mitake   perf bench: Add m...
77
78
79
  {
  	int ret;
  	u64 clk;
b14f2d357   Ingo Molnar   perf bench mem: C...
80
  	ret = read(cycles_fd, &clk, sizeof(u64));
827f3b497   Hitoshi Mitake   perf bench: Add m...
81
82
83
84
85
86
87
  	BUG_ON(ret != sizeof(u64));
  
  	return clk;
  }
  
  static double timeval2double(struct timeval *ts)
  {
f2b91be73   Arnaldo Carvalho de Melo   perf bench mem: U...
88
  	return (double)ts->tv_sec + (double)ts->tv_usec / (double)USEC_PER_SEC;
827f3b497   Hitoshi Mitake   perf bench: Add m...
89
  }
6db175c73   Ingo Molnar   perf bench: Remov...
90
91
  #define print_bps(x) do {						\
  		if (x < K)						\
13b1fdce8   Ingo Molnar   perf bench mem: I...
92
93
  			printf(" %14lf bytes/sec
  ", x);		\
6db175c73   Ingo Molnar   perf bench: Remov...
94
  		else if (x < K * K)					\
13b1fdce8   Ingo Molnar   perf bench mem: I...
95
96
  			printf(" %14lfd KB/sec
  ", x / K);		\
6db175c73   Ingo Molnar   perf bench: Remov...
97
  		else if (x < K * K * K)					\
13b1fdce8   Ingo Molnar   perf bench mem: I...
98
99
  			printf(" %14lf MB/sec
  ", x / K / K);		\
6db175c73   Ingo Molnar   perf bench: Remov...
100
  		else							\
13b1fdce8   Ingo Molnar   perf bench mem: I...
101
102
  			printf(" %14lf GB/sec
  ", x / K / K / K);	\
49ce8fc65   Hitoshi Mitake   perf bench: Print...
103
  	} while (0)
308197b94   Rabin Vincent   perf bench: Prepa...
104
  struct bench_mem_info {
2f211c84a   Ingo Molnar   perf bench mem: R...
105
  	const struct function *functions;
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
106
107
  	u64 (*do_cycles)(const struct function *r, size_t size, void *src, void *dst);
  	double (*do_gettimeofday)(const struct function *r, size_t size, void *src, void *dst);
308197b94   Rabin Vincent   perf bench: Prepa...
108
  	const char *const *usage;
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
109
  	bool alloc_src;
308197b94   Rabin Vincent   perf bench: Prepa...
110
  };
2f211c84a   Ingo Molnar   perf bench mem: R...
111
  static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t size, double size_total)
827f3b497   Hitoshi Mitake   perf bench: Add m...
112
  {
2f211c84a   Ingo Molnar   perf bench mem: R...
113
  	const struct function *r = &info->functions[r_idx];
6db175c73   Ingo Molnar   perf bench: Remov...
114
  	double result_bps = 0.0;
b14f2d357   Ingo Molnar   perf bench mem: C...
115
  	u64 result_cycles = 0;
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
116
  	void *src = NULL, *dst = zalloc(size);
49ce8fc65   Hitoshi Mitake   perf bench: Print...
117

2f211c84a   Ingo Molnar   perf bench mem: R...
118
119
  	printf("# function '%s' (%s)
  ", r->name, r->desc);
827f3b497   Hitoshi Mitake   perf bench: Add m...
120

47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
121
122
123
124
125
126
127
128
  	if (dst == NULL)
  		goto out_alloc_failed;
  
  	if (info->alloc_src) {
  		src = zalloc(size);
  		if (src == NULL)
  			goto out_alloc_failed;
  	}
49ce8fc65   Hitoshi Mitake   perf bench: Print...
129
  	if (bench_format == BENCH_FORMAT_DEFAULT)
13b1fdce8   Ingo Molnar   perf bench mem: I...
130
131
132
  		printf("# Copying %s bytes ...
  
  ", size_str);
827f3b497   Hitoshi Mitake   perf bench: Add m...
133

b14f2d357   Ingo Molnar   perf bench mem: C...
134
  	if (use_cycles) {
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
135
  		result_cycles = info->do_cycles(r, size, src, dst);
827f3b497   Hitoshi Mitake   perf bench: Add m...
136
  	} else {
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
137
  		result_bps = info->do_gettimeofday(r, size, src, dst);
827f3b497   Hitoshi Mitake   perf bench: Add m...
138
139
140
141
  	}
  
  	switch (bench_format) {
  	case BENCH_FORMAT_DEFAULT:
b14f2d357   Ingo Molnar   perf bench mem: C...
142
  		if (use_cycles) {
13b1fdce8   Ingo Molnar   perf bench mem: I...
143
144
  			printf(" %14lf cycles/byte
  ", (double)result_cycles/size_total);
49ce8fc65   Hitoshi Mitake   perf bench: Print...
145
  		} else {
6db175c73   Ingo Molnar   perf bench: Remov...
146
  			print_bps(result_bps);
827f3b497   Hitoshi Mitake   perf bench: Add m...
147
148
  		}
  		break;
6db175c73   Ingo Molnar   perf bench: Remov...
149

827f3b497   Hitoshi Mitake   perf bench: Add m...
150
  	case BENCH_FORMAT_SIMPLE:
b14f2d357   Ingo Molnar   perf bench mem: C...
151
  		if (use_cycles) {
a69b4f741   Ingo Molnar   perf bench mem: F...
152
153
  			printf("%lf
  ", (double)result_cycles/size_total);
49ce8fc65   Hitoshi Mitake   perf bench: Print...
154
  		} else {
6db175c73   Ingo Molnar   perf bench: Remov...
155
156
  			printf("%lf
  ", result_bps);
49ce8fc65   Hitoshi Mitake   perf bench: Print...
157
  		}
827f3b497   Hitoshi Mitake   perf bench: Add m...
158
  		break;
6db175c73   Ingo Molnar   perf bench: Remov...
159

827f3b497   Hitoshi Mitake   perf bench: Add m...
160
  	default:
6db175c73   Ingo Molnar   perf bench: Remov...
161
  		BUG_ON(1);
827f3b497   Hitoshi Mitake   perf bench: Add m...
162
163
  		break;
  	}
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
164
165
166
167
168
169
170
171
172
  
  out_free:
  	free(src);
  	free(dst);
  	return;
  out_alloc_failed:
  	printf("# Memory allocation failed - maybe size (%s) is too large?
  ", size_str);
  	goto out_free;
515e23f01   Borislav Petkov   perf/bench: Carve...
173
  }
2946f59ac   Ingo Molnar   perf bench: Elimi...
174
  static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *info)
515e23f01   Borislav Petkov   perf/bench: Carve...
175
176
  {
  	int i;
a69b4f741   Ingo Molnar   perf bench mem: F...
177
178
  	size_t size;
  	double size_total;
515e23f01   Borislav Petkov   perf/bench: Carve...
179

13839ec49   Ingo Molnar   perf bench: Impro...
180
  	argc = parse_options(argc, argv, options, info->usage, 0);
515e23f01   Borislav Petkov   perf/bench: Carve...
181

c2a218c63   Arnaldo Carvalho de Melo   perf bench: Remov...
182
183
184
185
186
187
188
189
  	if (use_cycles) {
  		i = init_cycles();
  		if (i < 0) {
  			fprintf(stderr, "Failed to open cycles counter
  ");
  			return i;
  		}
  	}
515e23f01   Borislav Petkov   perf/bench: Carve...
190

a69b4f741   Ingo Molnar   perf bench mem: F...
191
  	size = (size_t)perf_atoll((char *)size_str);
b0d22e52e   Ingo Molnar   perf bench: Harmo...
192
  	size_total = (double)size * nr_loops;
515e23f01   Borislav Petkov   perf/bench: Carve...
193

a69b4f741   Ingo Molnar   perf bench mem: F...
194
195
196
  	if ((s64)size <= 0) {
  		fprintf(stderr, "Invalid size:%s
  ", size_str);
515e23f01   Borislav Petkov   perf/bench: Carve...
197
198
  		return 1;
  	}
2f211c84a   Ingo Molnar   perf bench mem: R...
199
200
201
  	if (!strncmp(function_str, "all", 3)) {
  		for (i = 0; info->functions[i].name; i++)
  			__bench_mem_function(info, i, size, size_total);
dfecb95cd   Borislav Petkov   perf/bench: Add -...
202
203
  		return 0;
  	}
2f211c84a   Ingo Molnar   perf bench mem: R...
204
205
  	for (i = 0; info->functions[i].name; i++) {
  		if (!strcmp(info->functions[i].name, function_str))
515e23f01   Borislav Petkov   perf/bench: Carve...
206
207
  			break;
  	}
2f211c84a   Ingo Molnar   perf bench mem: R...
208
209
210
211
212
213
214
  	if (!info->functions[i].name) {
  		if (strcmp(function_str, "help") && strcmp(function_str, "h"))
  			printf("Unknown function: %s
  ", function_str);
  		printf("Available functions:
  ");
  		for (i = 0; info->functions[i].name; i++) {
515e23f01   Borislav Petkov   perf/bench: Carve...
215
216
  			printf("\t%s ... %s
  ",
2f211c84a   Ingo Molnar   perf bench mem: R...
217
  			       info->functions[i].name, info->functions[i].desc);
515e23f01   Borislav Petkov   perf/bench: Carve...
218
219
220
  		}
  		return 1;
  	}
2f211c84a   Ingo Molnar   perf bench mem: R...
221
  	__bench_mem_function(info, i, size, size_total);
827f3b497   Hitoshi Mitake   perf bench: Add m...
222
223
224
  
  	return 0;
  }
308197b94   Rabin Vincent   perf bench: Prepa...
225

47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
226
  static u64 do_memcpy_cycles(const struct function *r, size_t size, void *src, void *dst)
308197b94   Rabin Vincent   perf bench: Prepa...
227
228
  {
  	u64 cycle_start = 0ULL, cycle_end = 0ULL;
308197b94   Rabin Vincent   perf bench: Prepa...
229
230
  	memcpy_t fn = r->fn.memcpy;
  	int i;
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
231
232
  	/* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */
  	memset(src, 0, size);
308197b94   Rabin Vincent   perf bench: Prepa...
233

6db175c73   Ingo Molnar   perf bench: Remov...
234
235
236
237
  	/*
  	 * We prefault the freshly allocated memory range here,
  	 * to not measure page fault overhead:
  	 */
a69b4f741   Ingo Molnar   perf bench mem: F...
238
  	fn(dst, src, size);
308197b94   Rabin Vincent   perf bench: Prepa...
239

b14f2d357   Ingo Molnar   perf bench mem: C...
240
  	cycle_start = get_cycles();
b0d22e52e   Ingo Molnar   perf bench: Harmo...
241
  	for (i = 0; i < nr_loops; ++i)
a69b4f741   Ingo Molnar   perf bench mem: F...
242
  		fn(dst, src, size);
b14f2d357   Ingo Molnar   perf bench mem: C...
243
  	cycle_end = get_cycles();
308197b94   Rabin Vincent   perf bench: Prepa...
244

308197b94   Rabin Vincent   perf bench: Prepa...
245
246
  	return cycle_end - cycle_start;
  }
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
247
  static double do_memcpy_gettimeofday(const struct function *r, size_t size, void *src, void *dst)
308197b94   Rabin Vincent   perf bench: Prepa...
248
249
250
  {
  	struct timeval tv_start, tv_end, tv_diff;
  	memcpy_t fn = r->fn.memcpy;
308197b94   Rabin Vincent   perf bench: Prepa...
251
  	int i;
6db175c73   Ingo Molnar   perf bench: Remov...
252
253
254
255
  	/*
  	 * We prefault the freshly allocated memory range here,
  	 * to not measure page fault overhead:
  	 */
a69b4f741   Ingo Molnar   perf bench mem: F...
256
  	fn(dst, src, size);
308197b94   Rabin Vincent   perf bench: Prepa...
257
258
  
  	BUG_ON(gettimeofday(&tv_start, NULL));
b0d22e52e   Ingo Molnar   perf bench: Harmo...
259
  	for (i = 0; i < nr_loops; ++i)
a69b4f741   Ingo Molnar   perf bench mem: F...
260
  		fn(dst, src, size);
308197b94   Rabin Vincent   perf bench: Prepa...
261
262
263
  	BUG_ON(gettimeofday(&tv_end, NULL));
  
  	timersub(&tv_end, &tv_start, &tv_diff);
b0d22e52e   Ingo Molnar   perf bench: Harmo...
264
  	return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
308197b94   Rabin Vincent   perf bench: Prepa...
265
  }
2f211c84a   Ingo Molnar   perf bench mem: R...
266
  struct function memcpy_functions[] = {
5dd93304a   Ingo Molnar   perf bench mem: R...
267
268
269
270
271
272
273
274
275
  	{ .name		= "default",
  	  .desc		= "Default memcpy() provided by glibc",
  	  .fn.memcpy	= memcpy },
  
  #ifdef HAVE_ARCH_X86_64_SUPPORT
  # define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
  # include "mem-memcpy-x86-64-asm-def.h"
  # undef MEMCPY_FN
  #endif
a4c6a3e8b   Arnaldo Carvalho de Melo   perf bench: Use n...
276
  	{ .name = NULL, }
5dd93304a   Ingo Molnar   perf bench mem: R...
277
278
279
280
281
282
  };
  
  static const char * const bench_mem_memcpy_usage[] = {
  	"perf bench mem memcpy <options>",
  	NULL
  };
b0ad8ea66   Arnaldo Carvalho de Melo   perf tools: Remov...
283
  int bench_mem_memcpy(int argc, const char **argv)
308197b94   Rabin Vincent   perf bench: Prepa...
284
285
  {
  	struct bench_mem_info info = {
2f211c84a   Ingo Molnar   perf bench mem: R...
286
  		.functions		= memcpy_functions,
b14f2d357   Ingo Molnar   perf bench mem: C...
287
  		.do_cycles		= do_memcpy_cycles,
13839ec49   Ingo Molnar   perf bench: Impro...
288
289
  		.do_gettimeofday	= do_memcpy_gettimeofday,
  		.usage			= bench_mem_memcpy_usage,
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
290
  		.alloc_src              = true,
308197b94   Rabin Vincent   perf bench: Prepa...
291
  	};
2946f59ac   Ingo Molnar   perf bench: Elimi...
292
  	return bench_mem_common(argc, argv, &info);
308197b94   Rabin Vincent   perf bench: Prepa...
293
  }
5bce1a577   Rabin Vincent   perf bench: Merge...
294

47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
295
  static u64 do_memset_cycles(const struct function *r, size_t size, void *src __maybe_unused, void *dst)
5bce1a577   Rabin Vincent   perf bench: Merge...
296
297
298
  {
  	u64 cycle_start = 0ULL, cycle_end = 0ULL;
  	memset_t fn = r->fn.memset;
5bce1a577   Rabin Vincent   perf bench: Merge...
299
  	int i;
6db175c73   Ingo Molnar   perf bench: Remov...
300
301
302
303
  	/*
  	 * We prefault the freshly allocated memory range here,
  	 * to not measure page fault overhead:
  	 */
a69b4f741   Ingo Molnar   perf bench mem: F...
304
  	fn(dst, -1, size);
5bce1a577   Rabin Vincent   perf bench: Merge...
305

b14f2d357   Ingo Molnar   perf bench mem: C...
306
  	cycle_start = get_cycles();
b0d22e52e   Ingo Molnar   perf bench: Harmo...
307
  	for (i = 0; i < nr_loops; ++i)
a69b4f741   Ingo Molnar   perf bench mem: F...
308
  		fn(dst, i, size);
b14f2d357   Ingo Molnar   perf bench mem: C...
309
  	cycle_end = get_cycles();
5bce1a577   Rabin Vincent   perf bench: Merge...
310

5bce1a577   Rabin Vincent   perf bench: Merge...
311
312
  	return cycle_end - cycle_start;
  }
47b5757ba   Arnaldo Carvalho de Melo   perf bench mem: M...
313
  static double do_memset_gettimeofday(const struct function *r, size_t size, void *src __maybe_unused, void *dst)
5bce1a577   Rabin Vincent   perf bench: Merge...
314
315
316
  {
  	struct timeval tv_start, tv_end, tv_diff;
  	memset_t fn = r->fn.memset;
5bce1a577   Rabin Vincent   perf bench: Merge...
317
  	int i;
6db175c73   Ingo Molnar   perf bench: Remov...
318
319
320
321
  	/*
  	 * We prefault the freshly allocated memory range here,
  	 * to not measure page fault overhead:
  	 */
a69b4f741   Ingo Molnar   perf bench mem: F...
322
  	fn(dst, -1, size);
5bce1a577   Rabin Vincent   perf bench: Merge...
323
324
  
  	BUG_ON(gettimeofday(&tv_start, NULL));
b0d22e52e   Ingo Molnar   perf bench: Harmo...
325
  	for (i = 0; i < nr_loops; ++i)
a69b4f741   Ingo Molnar   perf bench mem: F...
326
  		fn(dst, i, size);
5bce1a577   Rabin Vincent   perf bench: Merge...
327
328
329
  	BUG_ON(gettimeofday(&tv_end, NULL));
  
  	timersub(&tv_end, &tv_start, &tv_diff);
b0d22e52e   Ingo Molnar   perf bench: Harmo...
330
  	return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
5bce1a577   Rabin Vincent   perf bench: Merge...
331
332
333
334
335
336
  }
  
  static const char * const bench_mem_memset_usage[] = {
  	"perf bench mem memset <options>",
  	NULL
  };
2f211c84a   Ingo Molnar   perf bench mem: R...
337
  static const struct function memset_functions[] = {
13839ec49   Ingo Molnar   perf bench: Impro...
338
339
340
  	{ .name		= "default",
  	  .desc		= "Default memset() provided by glibc",
  	  .fn.memset	= memset },
5bce1a577   Rabin Vincent   perf bench: Merge...
341

13839ec49   Ingo Molnar   perf bench: Impro...
342
343
344
345
  #ifdef HAVE_ARCH_X86_64_SUPPORT
  # define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
  # include "mem-memset-x86-64-asm-def.h"
  # undef MEMSET_FN
5bce1a577   Rabin Vincent   perf bench: Merge...
346
  #endif
a4c6a3e8b   Arnaldo Carvalho de Melo   perf bench: Use n...
347
  	{ .name = NULL, }
5bce1a577   Rabin Vincent   perf bench: Merge...
348
  };
b0ad8ea66   Arnaldo Carvalho de Melo   perf tools: Remov...
349
  int bench_mem_memset(int argc, const char **argv)
5bce1a577   Rabin Vincent   perf bench: Merge...
350
351
  {
  	struct bench_mem_info info = {
2f211c84a   Ingo Molnar   perf bench mem: R...
352
  		.functions		= memset_functions,
b14f2d357   Ingo Molnar   perf bench mem: C...
353
  		.do_cycles		= do_memset_cycles,
13839ec49   Ingo Molnar   perf bench: Impro...
354
355
  		.do_gettimeofday	= do_memset_gettimeofday,
  		.usage			= bench_mem_memset_usage,
5bce1a577   Rabin Vincent   perf bench: Merge...
356
  	};
2946f59ac   Ingo Molnar   perf bench: Elimi...
357
  	return bench_mem_common(argc, argv, &info);
5bce1a577   Rabin Vincent   perf bench: Merge...
358
  }