diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-test.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 02958d6a807f..0e01834a48d0 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -332,8 +332,7 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
332 | struct perf_evsel *evsel; | 332 | struct perf_evsel *evsel; |
333 | struct perf_event_attr attr; | 333 | struct perf_event_attr attr; |
334 | unsigned int nr_open_calls = 111, i; | 334 | unsigned int nr_open_calls = 111, i; |
335 | cpu_set_t *cpu_set; | 335 | cpu_set_t cpu_set; |
336 | size_t cpu_set_size; | ||
337 | int id = trace_event__id("sys_enter_open"); | 336 | int id = trace_event__id("sys_enter_open"); |
338 | 337 | ||
339 | if (id < 0) { | 338 | if (id < 0) { |
@@ -353,13 +352,8 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
353 | return -1; | 352 | return -1; |
354 | } | 353 | } |
355 | 354 | ||
356 | cpu_set = CPU_ALLOC(cpus->nr); | ||
357 | 355 | ||
358 | if (cpu_set == NULL) | 356 | CPU_ZERO(&cpu_set); |
359 | goto out_thread_map_delete; | ||
360 | |||
361 | cpu_set_size = CPU_ALLOC_SIZE(cpus->nr); | ||
362 | CPU_ZERO_S(cpu_set_size, cpu_set); | ||
363 | 357 | ||
364 | memset(&attr, 0, sizeof(attr)); | 358 | memset(&attr, 0, sizeof(attr)); |
365 | attr.type = PERF_TYPE_TRACEPOINT; | 359 | attr.type = PERF_TYPE_TRACEPOINT; |
@@ -367,7 +361,7 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
367 | evsel = perf_evsel__new(&attr, 0); | 361 | evsel = perf_evsel__new(&attr, 0); |
368 | if (evsel == NULL) { | 362 | if (evsel == NULL) { |
369 | pr_debug("perf_evsel__new\n"); | 363 | pr_debug("perf_evsel__new\n"); |
370 | goto out_cpu_free; | 364 | goto out_thread_map_delete; |
371 | } | 365 | } |
372 | 366 | ||
373 | if (perf_evsel__open(evsel, cpus, threads) < 0) { | 367 | if (perf_evsel__open(evsel, cpus, threads) < 0) { |
@@ -379,9 +373,19 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
379 | 373 | ||
380 | for (cpu = 0; cpu < cpus->nr; ++cpu) { | 374 | for (cpu = 0; cpu < cpus->nr; ++cpu) { |
381 | unsigned int ncalls = nr_open_calls + cpu; | 375 | unsigned int ncalls = nr_open_calls + cpu; |
376 | /* | ||
377 | * XXX eventually lift this restriction in a way that | ||
378 | * keeps perf building on older glibc installations | ||
379 | * without CPU_ALLOC. 1024 cpus in 2010 still seems | ||
380 | * a reasonable upper limit tho :-) | ||
381 | */ | ||
382 | if (cpus->map[cpu] >= CPU_SETSIZE) { | ||
383 | pr_debug("Ignoring CPU %d\n", cpus->map[cpu]); | ||
384 | continue; | ||
385 | } | ||
382 | 386 | ||
383 | CPU_SET_S(cpus->map[cpu], cpu_set_size, cpu_set); | 387 | CPU_SET(cpus->map[cpu], &cpu_set); |
384 | if (sched_setaffinity(0, cpu_set_size, cpu_set) < 0) { | 388 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { |
385 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", | 389 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", |
386 | cpus->map[cpu], | 390 | cpus->map[cpu], |
387 | strerror(errno)); | 391 | strerror(errno)); |
@@ -391,7 +395,7 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
391 | fd = open("/etc/passwd", O_RDONLY); | 395 | fd = open("/etc/passwd", O_RDONLY); |
392 | close(fd); | 396 | close(fd); |
393 | } | 397 | } |
394 | CPU_CLR_S(cpus->map[cpu], cpu_set_size, cpu_set); | 398 | CPU_CLR(cpus->map[cpu], &cpu_set); |
395 | } | 399 | } |
396 | 400 | ||
397 | /* | 401 | /* |
@@ -407,6 +411,9 @@ static int test__open_syscall_event_on_all_cpus(void) | |||
407 | for (cpu = 0; cpu < cpus->nr; ++cpu) { | 411 | for (cpu = 0; cpu < cpus->nr; ++cpu) { |
408 | unsigned int expected; | 412 | unsigned int expected; |
409 | 413 | ||
414 | if (cpus->map[cpu] >= CPU_SETSIZE) | ||
415 | continue; | ||
416 | |||
410 | if (perf_evsel__read_on_cpu(evsel, cpu, 0) < 0) { | 417 | if (perf_evsel__read_on_cpu(evsel, cpu, 0) < 0) { |
411 | pr_debug("perf_evsel__open_read_on_cpu\n"); | 418 | pr_debug("perf_evsel__open_read_on_cpu\n"); |
412 | goto out_close_fd; | 419 | goto out_close_fd; |
@@ -425,8 +432,6 @@ out_close_fd: | |||
425 | perf_evsel__close_fd(evsel, 1, threads->nr); | 432 | perf_evsel__close_fd(evsel, 1, threads->nr); |
426 | out_evsel_delete: | 433 | out_evsel_delete: |
427 | perf_evsel__delete(evsel); | 434 | perf_evsel__delete(evsel); |
428 | out_cpu_free: | ||
429 | CPU_FREE(cpu_set); | ||
430 | out_thread_map_delete: | 435 | out_thread_map_delete: |
431 | thread_map__delete(threads); | 436 | thread_map__delete(threads); |
432 | return err; | 437 | return err; |