diff options
author | Zheng Liu <gnehzuil.liu@gmail.com> | 2012-11-08 19:58:46 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-09 09:34:49 -0500 |
commit | 12f8f74b2a4d26c4facfa7ef99487cf0930f6ef7 (patch) | |
tree | 22d5c1c871d8028ca54b56022322e03a44ec0a4e /tools/perf | |
parent | 69d2591a829132492662bbfe164fcde5e44ad1c4 (diff) |
perf test: fix a build error on builtin-test
Recently I build perf and get a build error on builtin-test.c. The error is as
following:
$ make
CC perf.o
CC builtin-test.o
cc1: warnings being treated as errors
builtin-test.c: In function ‘sched__get_first_possible_cpu’:
builtin-test.c:977: warning: implicit declaration of function ‘CPU_ALLOC’
builtin-test.c:977: warning: nested extern declaration of ‘CPU_ALLOC’
builtin-test.c:977: warning: assignment makes pointer from integer without a cast
builtin-test.c:978: warning: implicit declaration of function ‘CPU_ALLOC_SIZE’
builtin-test.c:978: warning: nested extern declaration of ‘CPU_ALLOC_SIZE’
builtin-test.c:979: warning: implicit declaration of function ‘CPU_ZERO_S’
builtin-test.c:979: warning: nested extern declaration of ‘CPU_ZERO_S’
builtin-test.c:982: warning: implicit declaration of function ‘CPU_FREE’
builtin-test.c:982: warning: nested extern declaration of ‘CPU_FREE’
builtin-test.c:992: warning: implicit declaration of function ‘CPU_ISSET_S’
builtin-test.c:992: warning: nested extern declaration of ‘CPU_ISSET_S’
builtin-test.c:998: warning: implicit declaration of function ‘CPU_CLR_S’
builtin-test.c:998: warning: nested extern declaration of ‘CPU_CLR_S’
make: *** [builtin-test.o] Error 1
This problem is introduced in 3e7c439a. CPU_ALLOC and related macros are
missing in sched__get_first_possible_cpu function. In 54489c18, commiter
mentioned that CPU_ALLOC has been removed. So CPU_ALLOC calls in this
function are removed to let perf to be built.
Signed-off-by: Vinson Lee <vlee@twitter.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vinson Lee <vlee@twitter.com>
Cc: Zheng Liu <wenqing.lz@taobao.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1352422726-31114-1-git-send-email-vlee@twitter.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/tests/builtin-test.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index b5a544d1b381..5d4354e24457 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -605,19 +605,13 @@ out_free_threads: | |||
605 | #undef nsyscalls | 605 | #undef nsyscalls |
606 | } | 606 | } |
607 | 607 | ||
608 | static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t **maskp, | 608 | static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp) |
609 | size_t *sizep) | ||
610 | { | 609 | { |
611 | cpu_set_t *mask; | ||
612 | size_t size; | ||
613 | int i, cpu = -1, nrcpus = 1024; | 610 | int i, cpu = -1, nrcpus = 1024; |
614 | realloc: | 611 | realloc: |
615 | mask = CPU_ALLOC(nrcpus); | 612 | CPU_ZERO(maskp); |
616 | size = CPU_ALLOC_SIZE(nrcpus); | ||
617 | CPU_ZERO_S(size, mask); | ||
618 | 613 | ||
619 | if (sched_getaffinity(pid, size, mask) == -1) { | 614 | if (sched_getaffinity(pid, sizeof(*maskp), maskp) == -1) { |
620 | CPU_FREE(mask); | ||
621 | if (errno == EINVAL && nrcpus < (1024 << 8)) { | 615 | if (errno == EINVAL && nrcpus < (1024 << 8)) { |
622 | nrcpus = nrcpus << 2; | 616 | nrcpus = nrcpus << 2; |
623 | goto realloc; | 617 | goto realloc; |
@@ -627,19 +621,14 @@ realloc: | |||
627 | } | 621 | } |
628 | 622 | ||
629 | for (i = 0; i < nrcpus; i++) { | 623 | for (i = 0; i < nrcpus; i++) { |
630 | if (CPU_ISSET_S(i, size, mask)) { | 624 | if (CPU_ISSET(i, maskp)) { |
631 | if (cpu == -1) { | 625 | if (cpu == -1) |
632 | cpu = i; | 626 | cpu = i; |
633 | *maskp = mask; | 627 | else |
634 | *sizep = size; | 628 | CPU_CLR(i, maskp); |
635 | } else | ||
636 | CPU_CLR_S(i, size, mask); | ||
637 | } | 629 | } |
638 | } | 630 | } |
639 | 631 | ||
640 | if (cpu == -1) | ||
641 | CPU_FREE(mask); | ||
642 | |||
643 | return cpu; | 632 | return cpu; |
644 | } | 633 | } |
645 | 634 | ||
@@ -654,8 +643,8 @@ static int test__PERF_RECORD(void) | |||
654 | .freq = 10, | 643 | .freq = 10, |
655 | .mmap_pages = 256, | 644 | .mmap_pages = 256, |
656 | }; | 645 | }; |
657 | cpu_set_t *cpu_mask = NULL; | 646 | cpu_set_t cpu_mask; |
658 | size_t cpu_mask_size = 0; | 647 | size_t cpu_mask_size = sizeof(cpu_mask); |
659 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); | 648 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); |
660 | struct perf_evsel *evsel; | 649 | struct perf_evsel *evsel; |
661 | struct perf_sample sample; | 650 | struct perf_sample sample; |
@@ -719,8 +708,7 @@ static int test__PERF_RECORD(void) | |||
719 | evsel->attr.sample_type |= PERF_SAMPLE_TIME; | 708 | evsel->attr.sample_type |= PERF_SAMPLE_TIME; |
720 | perf_evlist__config_attrs(evlist, &opts); | 709 | perf_evlist__config_attrs(evlist, &opts); |
721 | 710 | ||
722 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask, | 711 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); |
723 | &cpu_mask_size); | ||
724 | if (err < 0) { | 712 | if (err < 0) { |
725 | pr_debug("sched__get_first_possible_cpu: %s\n", strerror(errno)); | 713 | pr_debug("sched__get_first_possible_cpu: %s\n", strerror(errno)); |
726 | goto out_delete_evlist; | 714 | goto out_delete_evlist; |
@@ -731,9 +719,9 @@ static int test__PERF_RECORD(void) | |||
731 | /* | 719 | /* |
732 | * So that we can check perf_sample.cpu on all the samples. | 720 | * So that we can check perf_sample.cpu on all the samples. |
733 | */ | 721 | */ |
734 | if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, cpu_mask) < 0) { | 722 | if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) { |
735 | pr_debug("sched_setaffinity: %s\n", strerror(errno)); | 723 | pr_debug("sched_setaffinity: %s\n", strerror(errno)); |
736 | goto out_free_cpu_mask; | 724 | goto out_delete_evlist; |
737 | } | 725 | } |
738 | 726 | ||
739 | /* | 727 | /* |
@@ -917,8 +905,6 @@ found_exit: | |||
917 | } | 905 | } |
918 | out_err: | 906 | out_err: |
919 | perf_evlist__munmap(evlist); | 907 | perf_evlist__munmap(evlist); |
920 | out_free_cpu_mask: | ||
921 | CPU_FREE(cpu_mask); | ||
922 | out_delete_evlist: | 908 | out_delete_evlist: |
923 | perf_evlist__delete(evlist); | 909 | perf_evlist__delete(evlist); |
924 | out: | 910 | out: |