aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-test.c
diff options
context:
space:
mode:
authorHan Pingtian <phan@redhat.com>2011-01-20 06:47:07 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-01-21 13:44:14 -0500
commitffb5e0fb44d0829021a51f972df90166bc9b700e (patch)
treed0fc058c018522d940aceb56350e83f7a93a0be3 /tools/perf/builtin-test.c
parentb2f8fb237e9cc407a02aca401369c15babae35dd (diff)
perf test: Use cpu_map->[cpu] when setting affinity
When some of CPUs are offline: # cat /sys/devices/system/cpu/online 0,6-31 perf test will fail on #3 testcase: 3: detect open syscall event on all cpus: --- start --- perf_evsel__read_on_cpu: expected to intercept 111 calls on cpu 0, got 681 perf_evsel__read_on_cpu: expected to intercept 112 calls on cpu 1, got 117 perf_evsel__read_on_cpu: expected to intercept 113 calls on cpu 2, got 118 perf_evsel__read_on_cpu: expected to intercept 114 calls on cpu 3, got 119 perf_evsel__read_on_cpu: expected to intercept 115 calls on cpu 4, got 120 perf_evsel__read_on_cpu: expected to intercept 116 calls on cpu 5, got 121 perf_evsel__read_on_cpu: expected to intercept 117 calls on cpu 6, got 122 perf_evsel__read_on_cpu: expected to intercept 118 calls on cpu 7, got 123 perf_evsel__read_on_cpu: expected to intercept 119 calls on cpu 8, got 124 perf_evsel__read_on_cpu: expected to intercept 120 calls on cpu 9, got 125 perf_evsel__read_on_cpu: expected to intercept 121 calls on cpu 10, got 126 .... This patch try to use 'cpus->map[cpu]' when setting cpu affinity, and will check the return code of sched_setaffinity() LKML-Reference: <20110120114707.GA11781@hpt.nay.redhat.com> Signed-off-by: Han Pingtian <phan@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-test.c')
-rw-r--r--tools/perf/builtin-test.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
index ed5696198d3d..02958d6a807f 100644
--- a/tools/perf/builtin-test.c
+++ b/tools/perf/builtin-test.c
@@ -380,13 +380,18 @@ static int test__open_syscall_event_on_all_cpus(void)
380 for (cpu = 0; cpu < cpus->nr; ++cpu) { 380 for (cpu = 0; cpu < cpus->nr; ++cpu) {
381 unsigned int ncalls = nr_open_calls + cpu; 381 unsigned int ncalls = nr_open_calls + cpu;
382 382
383 CPU_SET(cpu, cpu_set); 383 CPU_SET_S(cpus->map[cpu], cpu_set_size, cpu_set);
384 sched_setaffinity(0, cpu_set_size, cpu_set); 384 if (sched_setaffinity(0, cpu_set_size, cpu_set) < 0) {
385 pr_debug("sched_setaffinity() failed on CPU %d: %s ",
386 cpus->map[cpu],
387 strerror(errno));
388 goto out_close_fd;
389 }
385 for (i = 0; i < ncalls; ++i) { 390 for (i = 0; i < ncalls; ++i) {
386 fd = open("/etc/passwd", O_RDONLY); 391 fd = open("/etc/passwd", O_RDONLY);
387 close(fd); 392 close(fd);
388 } 393 }
389 CPU_CLR(cpu, cpu_set); 394 CPU_CLR_S(cpus->map[cpu], cpu_set_size, cpu_set);
390 } 395 }
391 396
392 /* 397 /*
@@ -410,7 +415,7 @@ static int test__open_syscall_event_on_all_cpus(void)
410 expected = nr_open_calls + cpu; 415 expected = nr_open_calls + cpu;
411 if (evsel->counts->cpu[cpu].val != expected) { 416 if (evsel->counts->cpu[cpu].val != expected) {
412 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %Ld\n", 417 pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %Ld\n",
413 expected, cpu, evsel->counts->cpu[cpu].val); 418 expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
414 goto out_close_fd; 419 goto out_close_fd;
415 } 420 }
416 } 421 }