Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Access to Processor Counter Monitor has denied

Matias_C_
Beginner
1,321 Views

Hi all, I've been trying to run the pcm.x binary but keep hitting the below error:

> ./pcm.x

 Processor Counter Monitor  ($Format:%ci ID=%h$)

Detected a hypervisor/virtualization technology. Some metrics might not be available due to configuration or availability of virtual hardware features.
apic_ids_per_package == 0
Access to Processor Counter Monitor has denied (no MSR or PCI CFG space access).

I'm running this from a VM machine (Over KVM hypervisor) on the following processor:

cpu family    : 6
model        : 79
model name    : Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz

Linux:

> uname -a
Linux fwd-1 3.14.25-00285-g7c35e43 #2 SMP Thu Mar 16 09:20:58 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

I've tried to look into GDB and find out what was wrong but haven't had to much luck. The error seems to be being hit in the following code path:

pcm.cpp (snippet)

// program() creates common semaphore for the singleton, so ideally to be called before any other references to PCM
    PCM::ErrorCode status = m->program();

    switch (status)
    {
    case PCM::Success:
        break;
    case PCM::MSRAccessDenied:
        cerr << "Access to Processor Counter Monitor has denied (no MSR or PCI CFG space access)." << endl;
        exit(EXIT_FAILURE);

Program seems to be invoked here (cpucounters.cpp, line:1613):

PCM::ErrorCode PCM::program(const PCM::ProgramMode mode_, const void * parameter_)
{
    if(allow_multiple_instances && (EXT_CUSTOM_CORE_EVENTS == mode_ || CUSTOM_CORE_EVENTS == mode_))
    {
        allow_multiple_instances = false;
        std::cerr << "Warning: multiple PCM instance mode is not allowed with custom events." << std::endl;
    }

    InstanceLock lock(allow_multiple_instances);
    if (MSR.empty()) return PCM::MSRAccessDenied;

I'm not sure what MSR empty means to be honest. From GDB I have printed both main data structures:

(gdb) bt
#0  PCM::program (this=0x64d040, mode_=PCM::DEFAULT_EVENTS, parameter_=0x0) at cpucounters.cpp:1613
#1  0x0000000000416bd6 in main (argc=<optimized out>, argv=<optimized out>) at pcm.cpp:1232
(gdb) p MSR
$5 = {<std::_Vector_base<std::shared_ptr<SafeMsrHandle>, std::allocator<std::shared_ptr<SafeMsrHandle> > >> = {
    _M_impl = {<std::allocator<std::shared_ptr<SafeMsrHandle> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<SafeMsrHandle> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
      _M_end_of_storage = 0x0}}, <No data fields>}

(gdb) fr 1
#1  0x0000000000416bd6 in main (argc=<optimized out>, argv=<optimized out>) at pcm.cpp:1232
1232    pcm.cpp: No such file or directory.
(gdb) p *m
$6 = {cpu_family = 6, cpu_model = 79, original_cpu_model = 79, cpu_stepping = 1, threads_per_core = 0, num_cores = 0, num_sockets = 0, num_phys_cores_per_socket = 0, num_online_cores = 0, core_gen_counter_num_max = 4,
  core_gen_counter_num_used = 0, core_gen_counter_width = 48, core_fixed_counter_num_max = 3, core_fixed_counter_num_used = 0, core_fixed_counter_width = 48, uncore_gen_counter_num_max = 8, uncore_gen_counter_num_used = 0,
  uncore_gen_counter_width = 48, uncore_fixed_counter_num_max = 1, uncore_fixed_counter_num_used = 0, uncore_fixed_counter_width = 48, perfmon_version = 2, perfmon_config_anythread = 1, nominal_frequency = 0, max_qpi_speed = 0,
  L3ScalingFactor = 0, pkgThermalSpecPower = -1, pkgMinimumPower = -1, pkgMaximumPower = -1, topology = {<std::_Vector_base<TopologyEntry, std::allocator<TopologyEntry> >> = {
      _M_impl = {<std::allocator<TopologyEntry>> = {<__gnu_cxx::new_allocator<TopologyEntry>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, errorMessage = {
    static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x64c798 <_ZNSs4_Rep20_S_empty_rep_storageE@@GLIBCXX_3.4+24> ""}},
  static instance = 0x64d040, allow_multiple_instances = false, programmed_pmu = false, MSR = {<std::_Vector_base<std::shared_ptr<SafeMsrHandle>, std::allocator<std::shared_ptr<SafeMsrHandle> > >> = {
      _M_impl = {<std::allocator<std::shared_ptr<SafeMsrHandle> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<SafeMsrHandle> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
        _M_end_of_storage = 0x0}}, <No data fields>}, server_pcicfg_uncore = {<std::_Vector_base<std::shared_ptr<ServerPCICFGUncore>, std::allocator<std::shared_ptr<ServerPCICFGUncore> > >> = {
      _M_impl = {<std::allocator<std::shared_ptr<ServerPCICFGUncore> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<ServerPCICFGUncore> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
        _M_end_of_storage = 0x0}}, <No data fields>}, PCU_MSR_PMON_BOX_CTL_ADDR = 0, PCU_MSR_PMON_CTRX_ADDR = {0, 0, 0, 0}, joulesPerEnergyUnit = 0,
  energy_status = {<std::_Vector_base<std::shared_ptr<CounterWidthExtender>, std::allocator<std::shared_ptr<CounterWidthExtender> > >> = {
      _M_impl = {<std::allocator<std::shared_ptr<CounterWidthExtender> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<CounterWidthExtender> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
        _M_end_of_storage = 0x0}}, <No data fields>}, dram_energy_status = {<std::_Vector_base<std::shared_ptr<CounterWidthExtender>, std::allocator<std::shared_ptr<CounterWidthExtender> > >> = {
      _M_impl = {<std::allocator<std::shared_ptr<CounterWidthExtender> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<CounterWidthExtender> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
        _M_end_of_storage = 0x0}}, <No data fields>}, memory_bw_local = {<std::_Vector_base<std::shared_ptr<CounterWidthExtender>, std::allocator<std::shared_ptr<CounterWidthExtender> > >> = {
      _M_impl = {<std::allocator<std::shared_ptr<CounterWidthExtender> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<CounterWidthExtender> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
        _M_end_of_storage = 0x0}}, <No data fields>}, memory_bw_total = {<std::_Vector_base<std::shared_ptr<CounterWidthExtender>, std::allocator<std::shared_ptr<CounterWidthExtender> > >> = {
      _M_impl = {<std::allocator<std::shared_ptr<CounterWidthExtender> >> = {<__gnu_cxx::new_allocator<std::shared_ptr<CounterWidthExtender> >> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0,
        _M_end_of_storage = 0x0}}, <No data fields>}, clientBW = {<std::__shared_ptr<ClientBW, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0x0, _M_refcount = {_M_pi = 0x0}}, <No data fields>},
  clientImcReads = {<std::__shared_ptr<CounterWidthExtender, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0x0, _M_refcount = {_M_pi = 0x0}}, <No data fields>},
  clientImcWrites = {<std::__shared_ptr<CounterWidthExtender, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0x0, _M_refcount = {_M_pi = 0x0}}, <No data fields>},
  clientIoRequests = {<std::__shared_ptr<CounterWidthExtender, (__gnu_cxx::_Lock_policy)2>> = {_M_ptr = 0x0, _M_refcount = {_M_pi = 0x0}}, <No data fields>}, disable_JKT_workaround = false, blocked = false,
  coreCStateMsr = 0x64be80 <PCM::initCStateSupportTables()::tmp>, pkgCStateMsr = 0x64bfa0 <PCM::initCStateSupportTables()::tmp>, mode = PCM::INVALID_MODE, coreEventDesc = {{event_number = 0, umask_value = 0}, {event_number = 0,
      umask_value = 0}, {event_number = 0, umask_value = 0}, {event_number = 0, umask_value = 0}}, numInstancesSemaphore = 0x0, socketRefCore = {<std::_Vector_base<int, std::allocator<int> >> = {
      _M_impl = {<std::allocator<int>> = {<__gnu_cxx::new_allocator<int>> = {<No data fields>}, <No data fields>}, _M_start = 0x0, _M_finish = 0x0, _M_end_of_storage = 0x0}}, <No data fields>}, canUsePerf = false, outfile = 0x0,
---Type <return> to continue, or q <return> to quit---
  backup_ofile = 0x0, run_state = 1}
(gdb)

If anybody has any pointers as to what might be going wrong here please let me know.

Best,

Matias

0 Kudos
2 Replies
gaston-hillar
Valued Contributor I
1,321 Views
0 Kudos
gaston-hillar
Valued Contributor I
1,321 Views
0 Kudos
Reply