src/hotspot/os/solaris/os_perf_solaris.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 53911 65f2a401e0eb
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
   298   if (_counters.nProcs == 0) {
   298   if (_counters.nProcs == 0) {
   299     return false;
   299     return false;
   300   }
   300   }
   301 
   301 
   302   // Data structure(s) for saving CPU load (one per CPU)
   302   // Data structure(s) for saving CPU load (one per CPU)
   303   size_t tick_array_size = _counters.nProcs * sizeof(CPUPerfTicks);
   303   size_t array_entry_count = _counters.nProcs;
   304   _counters.jvmTicks = (CPUPerfTicks*)NEW_C_HEAP_ARRAY(char, tick_array_size, mtInternal);
   304   _counters.jvmTicks = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
   305   if (NULL == _counters.jvmTicks) {
   305   memset(_counters.jvmTicks, 0, array_entry_count * sizeof(*_counters.jvmTicks));
   306     return false;
       
   307   }
       
   308   memset(_counters.jvmTicks, 0, tick_array_size);
       
   309 
   306 
   310   // Get kstat cpu_stat counters for every CPU
   307   // Get kstat cpu_stat counters for every CPU
   311   // loop over kstat to find our cpu_stat(s)
   308   // loop over kstat to find our cpu_stat(s)
   312   int i = 0;
   309   int i = 0;
   313   for (kstat_t* kstat = _counters.kstat_ctrl->kc_chain; kstat != NULL; kstat = kstat->ks_next) {
   310   for (kstat_t* kstat = _counters.kstat_ctrl->kc_chain; kstat != NULL; kstat = kstat->ks_next) {
   324   }
   321   }
   325   return true;
   322   return true;
   326 }
   323 }
   327 
   324 
   328 CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
   325 CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
   329   if (_counters.jvmTicks != NULL) {
   326   FREE_C_HEAP_ARRAY(char, _counters.jvmTicks);
   330     FREE_C_HEAP_ARRAY(char, _counters.jvmTicks);
       
   331   }
       
   332   if (_counters.kstat_ctrl != NULL) {
   327   if (_counters.kstat_ctrl != NULL) {
   333     kstat_close(_counters.kstat_ctrl);
   328     kstat_close(_counters.kstat_ctrl);
   334   }
   329   }
   335 }
   330 }
   336 
   331 
   432   _impl = NULL;
   427   _impl = NULL;
   433 }
   428 }
   434 
   429 
   435 bool CPUPerformanceInterface::initialize() {
   430 bool CPUPerformanceInterface::initialize() {
   436   _impl = new CPUPerformanceInterface::CPUPerformance();
   431   _impl = new CPUPerformanceInterface::CPUPerformance();
   437   return _impl != NULL && _impl->initialize();
   432   return _impl->initialize();
   438 }
   433 }
   439 
   434 
   440 CPUPerformanceInterface::~CPUPerformanceInterface(void) {
   435 CPUPerformanceInterface::~CPUPerformanceInterface(void) {
   441   if (_impl != NULL) {
   436   if (_impl != NULL) {
   442     delete _impl;
   437     delete _impl;
   574       (psinfo_data.pr_psargs != NULL)) {
   569       (psinfo_data.pr_psargs != NULL)) {
   575     char *path_substring = strstr(psinfo_data.pr_psargs, psinfo_data.pr_fname);
   570     char *path_substring = strstr(psinfo_data.pr_psargs, psinfo_data.pr_fname);
   576     if (path_substring != NULL) {
   571     if (path_substring != NULL) {
   577       int len = path_substring - psinfo_data.pr_psargs;
   572       int len = path_substring - psinfo_data.pr_psargs;
   578       exe_path = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
   573       exe_path = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
   579       if (exe_path != NULL) {
   574       jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
   580         jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
   575       exe_path[len] = '\0';
   581         exe_path[len] = '\0';
       
   582       }
       
   583     }
   576     }
   584   }
   577   }
   585 
   578 
   586   process_info->set_pid(atoi(_entry->d_name));
   579   process_info->set_pid(atoi(_entry->d_name));
   587   process_info->set_name(allocate_string(psinfo_data.pr_fname));
   580   process_info->set_name(allocate_string(psinfo_data.pr_fname));
   642   _iterator = NULL;
   635   _iterator = NULL;
   643 }
   636 }
   644 
   637 
   645 bool SystemProcessInterface::SystemProcesses::initialize() {
   638 bool SystemProcessInterface::SystemProcesses::initialize() {
   646   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
   639   _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
   647   return _iterator != NULL && _iterator->initialize();
   640   return _iterator->initialize();
   648 }
   641 }
   649 
   642 
   650 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
   643 SystemProcessInterface::SystemProcesses::~SystemProcesses() {
   651   if (_iterator != NULL) {
   644   if (_iterator != NULL) {
   652     delete _iterator;
   645     delete _iterator;
   689   _impl = NULL;
   682   _impl = NULL;
   690 }
   683 }
   691 
   684 
   692 bool SystemProcessInterface::initialize() {
   685 bool SystemProcessInterface::initialize() {
   693   _impl = new SystemProcessInterface::SystemProcesses();
   686   _impl = new SystemProcessInterface::SystemProcesses();
   694   return _impl != NULL && _impl->initialize();
   687   return _impl->initialize();
   695 
   688 
   696 }
   689 }
   697 
   690 
   698 SystemProcessInterface::~SystemProcessInterface() {
   691 SystemProcessInterface::~SystemProcessInterface() {
   699   if (_impl != NULL) {
   692   if (_impl != NULL) {
   705   _cpu_info = NULL;
   698   _cpu_info = NULL;
   706 }
   699 }
   707 
   700 
   708 bool CPUInformationInterface::initialize() {
   701 bool CPUInformationInterface::initialize() {
   709   _cpu_info = new CPUInformation();
   702   _cpu_info = new CPUInformation();
   710   if (_cpu_info == NULL) {
       
   711     return false;
       
   712   }
       
   713   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   703   _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
   714   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   704   _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
   715   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   705   _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
   716   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   706   _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
   717   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
   707   _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
   820   }
   810   }
   821 }
   811 }
   822 
   812 
   823 bool NetworkPerformanceInterface::initialize() {
   813 bool NetworkPerformanceInterface::initialize() {
   824   _impl = new NetworkPerformanceInterface::NetworkPerformance();
   814   _impl = new NetworkPerformanceInterface::NetworkPerformance();
   825   return _impl != NULL && _impl->initialize();
   815   return _impl->initialize();
   826 }
   816 }
   827 
   817 
   828 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
   818 int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
   829   return _impl->network_utilization(network_interfaces);
   819   return _impl->network_utilization(network_interfaces);
   830 }
   820 }