Diff of /libperf_events/operf_counter.cpp [3b11e2] .. [6ee980]  Maximize  Restore

Switch to unified view

a/libperf_events/operf_counter.cpp b/libperf_events/operf_counter.cpp
...
...
145
    return rc;
145
    return rc;
146
}
146
}
147
147
148
static event_t * _get_perf_event_from_file(struct mmap_info & info)
148
static event_t * _get_perf_event_from_file(struct mmap_info & info)
149
{
149
{
150
    uint32_t size;
150
    uint32_t size = 0;
151
    static int num_remaps = 0;
151
    static int num_remaps = 0;
152
    event_t * event;
152
    event_t * event;
153
    size_t pe_header_size = sizeof(struct perf_event_header);
153
    size_t pe_header_size = sizeof(struct perf_event_header);
154
154
155
try_again:
155
try_again:
...
...
598
    /* To set up to profile an existing thread group, we need call perf_event_open
598
    /* To set up to profile an existing thread group, we need call perf_event_open
599
     * for each thread, and we need to pass cpu=-1 on the syscall.
599
     * for each thread, and we need to pass cpu=-1 on the syscall.
600
     */
600
     */
601
    use_cpu_minus_one = use_cpu_minus_one ? true : profile_process_group;
601
    use_cpu_minus_one = use_cpu_minus_one ? true : profile_process_group;
602
    num_cpus = use_cpu_minus_one ? 1 : sysconf(_SC_NPROCESSORS_ONLN);
602
    num_cpus = use_cpu_minus_one ? 1 : sysconf(_SC_NPROCESSORS_ONLN);
603
    if (!num_cpus)
603
    if (num_cpus < 1) {
604
      throw runtime_error("Number of online CPUs is zero; cannot continue");;
604
      char int_str[256];
605
      sprintf(int_str, "Number of online CPUs is %d; cannot continue", num_cpus);
606
      throw runtime_error(int_str);
607
  }
605
608
606
    cverb << vrecord << "calling perf_event_open for pid " << pid_to_profile << " on "
609
    cverb << vrecord << "calling perf_event_open for pid " << pid_to_profile << " on "
607
          << num_cpus << " cpus" << endl;
610
          << num_cpus << " cpus" << endl;
608
    FILE * online_cpus = fopen("/sys/devices/system/cpu/online", "r");
611
    FILE * online_cpus = fopen("/sys/devices/system/cpu/online", "r");
609
    if (!online_cpus) {
612
    if (!online_cpus) {
...
...
673
                }
676
                }
674
                perfCounters.push_back(op_ctr);
677
                perfCounters.push_back(op_ctr);
675
            }
678
            }
676
        }
679
        }
677
    }
680
    }
678
  if (dir)
679
      closedir(dir);
680
    int num_mmaps;
681
    int num_mmaps;
681
    if (pid_started && (procs.size() > 1))
682
    if (pid_started && (procs.size() > 1))
682
        num_mmaps = procs.size();
683
        num_mmaps = procs.size();
683
    else
684
    else
684
        num_mmaps = num_cpus;
685
        num_mmaps = num_cpus;
...
...
689
    }
690
    }
690
    write_op_header_info();
691
    write_op_header_info();
691
692
692
    // Set bit to indicate we're set to go.
693
    // Set bit to indicate we're set to go.
693
    valid = true;
694
    valid = true;
695
  if (dir)
696
      closedir(dir);
694
    return;
697
    return;
695
698
696
error:
699
error:
697
    delete[] poll_data;
700
    delete[] poll_data;
698
    poll_data = NULL;
701
    poll_data = NULL;

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks