~ubuntu-branches/ubuntu/precise/linux-lts-quantal/precise-updates

« back to all changes in this revision

Viewing changes to tools/perf/builtin-test.c

  • Committer: Package Import Robot
  • Author(s): Luis Henriques, Luis Henriques, Tim Gardner
  • Date: 2013-02-07 12:08:38 UTC
  • Revision ID: package-import@ubuntu.com-20130207120838-8jaukepmb85dkevq
Tags: 3.5.0-24.37~precise1
[Luis Henriques]

* Release Tracking Bug
  - LP: #1118287

[ Tim Gardner ]

* [Config] CONFIG_ALX=m for x86 only
  - LP: #927782

Show diffs side-by-side

added added

removed removed

Lines of Context:
604
604
#undef nsyscalls
605
605
}
606
606
 
607
 
static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t **maskp,
608
 
                                         size_t *sizep)
 
607
static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp)
609
608
{
610
 
        cpu_set_t *mask;
611
 
        size_t size;
612
609
        int i, cpu = -1, nrcpus = 1024;
613
610
realloc:
614
 
        mask = CPU_ALLOC(nrcpus);
615
 
        size = CPU_ALLOC_SIZE(nrcpus);
616
 
        CPU_ZERO_S(size, mask);
 
611
        CPU_ZERO(maskp);
617
612
 
618
 
        if (sched_getaffinity(pid, size, mask) == -1) {
619
 
                CPU_FREE(mask);
 
613
        if (sched_getaffinity(pid, sizeof(*maskp), maskp) == -1) {
620
614
                if (errno == EINVAL && nrcpus < (1024 << 8)) {
621
615
                        nrcpus = nrcpus << 2;
622
616
                        goto realloc;
626
620
        }
627
621
 
628
622
        for (i = 0; i < nrcpus; i++) {
629
 
                if (CPU_ISSET_S(i, size, mask)) {
630
 
                        if (cpu == -1) {
 
623
                if (CPU_ISSET(i, maskp)) {
 
624
                        if (cpu == -1)
631
625
                                cpu = i;
632
 
                                *maskp = mask;
633
 
                                *sizep = size;
634
 
                        } else
635
 
                                CPU_CLR_S(i, size, mask);
 
626
                        else
 
627
                                CPU_CLR(i, maskp);
636
628
                }
637
629
        }
638
630
 
639
 
        if (cpu == -1)
640
 
                CPU_FREE(mask);
641
 
 
642
631
        return cpu;
643
632
}
644
633
 
653
642
                .freq       = 10,
654
643
                .mmap_pages = 256,
655
644
        };
656
 
        cpu_set_t *cpu_mask = NULL;
657
 
        size_t cpu_mask_size = 0;
 
645
        cpu_set_t cpu_mask;
 
646
        size_t cpu_mask_size = sizeof(cpu_mask);
658
647
        struct perf_evlist *evlist = perf_evlist__new(NULL, NULL);
659
648
        struct perf_evsel *evsel;
660
649
        struct perf_sample sample;
718
707
        evsel->attr.sample_type |= PERF_SAMPLE_TIME;
719
708
        perf_evlist__config_attrs(evlist, &opts);
720
709
 
721
 
        err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask,
722
 
                                            &cpu_mask_size);
 
710
        err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask);
723
711
        if (err < 0) {
724
712
                pr_debug("sched__get_first_possible_cpu: %s\n", strerror(errno));
725
713
                goto out_delete_evlist;
730
718
        /*
731
719
         * So that we can check perf_sample.cpu on all the samples.
732
720
         */
733
 
        if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, cpu_mask) < 0) {
 
721
        if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) {
734
722
                pr_debug("sched_setaffinity: %s\n", strerror(errno));
735
 
                goto out_free_cpu_mask;
 
723
                goto out_delete_evlist;
736
724
        }
737
725
 
738
726
        /*
925
913
        }
926
914
out_err:
927
915
        perf_evlist__munmap(evlist);
928
 
out_free_cpu_mask:
929
 
        CPU_FREE(cpu_mask);
930
916
out_delete_evlist:
931
917
        perf_evlist__delete(evlist);
932
918
out: