1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/runtime/os_perf.hpp Mon Aug 12 18:30:40 2019 +0300 1.3 @@ -0,0 +1,292 @@ 1.4 +/* 1.5 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_RUNTIME_OS_PERF_HPP 1.29 +#define SHARE_VM_RUNTIME_OS_PERF_HPP 1.30 + 1.31 +#include "utilities/macros.hpp" 1.32 +#include "memory/allocation.inline.hpp" 1.33 +#include "utilities/globalDefinitions.hpp" 1.34 + 1.35 +#define FUNCTIONALITY_NOT_IMPLEMENTED -8 1.36 + 1.37 +// XXX 1.38 +//class EnvironmentVariable : public CHeapObj<mtInternal> { 1.39 +// public: 1.40 +// char* _key; 1.41 +// char* _value; 1.42 +// 1.43 +// EnvironmentVariable() { 1.44 +// _key = NULL; 1.45 +// _value = NULL; 1.46 +// } 1.47 +// 1.48 +// ~EnvironmentVariable() { 1.49 +// if (_key != NULL) { 1.50 +// FREE_C_HEAP_ARRAY(char, _key); 1.51 +// } 1.52 +// if (_value != NULL) { 1.53 +// FREE_C_HEAP_ARRAY(char, _value); 1.54 +// } 1.55 +// } 1.56 +// 1.57 +// EnvironmentVariable(char* key, char* value) { 1.58 +// _key = key; 1.59 +// _value = value; 1.60 +// } 1.61 +// 1.62 +//}; 1.63 + 1.64 + 1.65 +class CPUInformation : public CHeapObj<mtInternal> { 1.66 + private: 1.67 + int _no_of_sockets; 1.68 + int _no_of_cores; 1.69 + int _no_of_hw_threads; 1.70 + const char* _description; 1.71 + const char* _name; 1.72 + 1.73 + public: 1.74 + CPUInformation() { 1.75 + _no_of_sockets = 0; 1.76 + _no_of_cores = 0; 1.77 + _no_of_hw_threads = 0; 1.78 + _description = NULL; 1.79 + _name = NULL; 1.80 + } 1.81 + 1.82 + int number_of_sockets(void) const { 1.83 + return _no_of_sockets; 1.84 + } 1.85 + 1.86 + void set_number_of_sockets(int no_of_sockets) { 1.87 + _no_of_sockets = no_of_sockets; 1.88 + } 1.89 + 1.90 + int number_of_cores(void) const { 1.91 + return _no_of_cores; 1.92 + } 1.93 + 1.94 + void set_number_of_cores(int no_of_cores) { 1.95 + _no_of_cores = no_of_cores; 1.96 + } 1.97 + 1.98 + int number_of_hardware_threads(void) const { 1.99 + return _no_of_hw_threads; 1.100 + } 1.101 + 1.102 + void set_number_of_hardware_threads(int no_of_hw_threads) { 1.103 + _no_of_hw_threads = no_of_hw_threads; 1.104 + } 1.105 + 1.106 + const char* cpu_name(void) const { 1.107 + return _name; 1.108 + } 1.109 + 1.110 + void set_cpu_name(const char* cpu_name) { 1.111 + _name = cpu_name; 1.112 + } 1.113 + 1.114 + const char* cpu_description(void) const { 1.115 + return _description; 1.116 + } 1.117 + 1.118 + void set_cpu_description(const char* cpu_description) { 1.119 + _description = cpu_description; 1.120 + } 1.121 +}; 1.122 + 1.123 +class SystemProcess : public CHeapObj<mtInternal> { 1.124 + private: 1.125 + int _pid; 1.126 + char* _name; 1.127 + char* _path; 1.128 + char* _command_line; 1.129 + SystemProcess* _next; 1.130 + 1.131 + public: 1.132 + SystemProcess() { 1.133 + _pid = 0; 1.134 + _name = NULL; 1.135 + _path = NULL; 1.136 + _command_line = NULL; 1.137 + _next = NULL; 1.138 + } 1.139 + 1.140 + SystemProcess(int pid, char* name, char* path, char* command_line, SystemProcess* next) { 1.141 + _pid = pid; 1.142 + _name = name; 1.143 + _path = path; 1.144 + _command_line = command_line; 1.145 + _next = next; 1.146 + } 1.147 + 1.148 + void set_next(SystemProcess* sys_process) { 1.149 + _next = sys_process; 1.150 + } 1.151 + 1.152 + SystemProcess* next(void) const { 1.153 + return _next; 1.154 + } 1.155 + 1.156 + int pid(void) const { 1.157 + return _pid; 1.158 + } 1.159 + 1.160 + void set_pid(int pid) { 1.161 + _pid = pid; 1.162 + } 1.163 + 1.164 + const char* name(void) const { 1.165 + return _name; 1.166 + } 1.167 + 1.168 + void set_name(char* name) { 1.169 + _name = name; 1.170 + } 1.171 + 1.172 + const char* path(void) const { 1.173 + return _path; 1.174 + } 1.175 + 1.176 + void set_path(char* path) { 1.177 + _path = path; 1.178 + } 1.179 + 1.180 + const char* command_line(void) const { 1.181 + return _command_line; 1.182 + } 1.183 + 1.184 + void set_command_line(char* command_line) { 1.185 + _command_line = command_line; 1.186 + } 1.187 + 1.188 + virtual ~SystemProcess(void) { 1.189 + if (_name != NULL) { 1.190 + FREE_C_HEAP_ARRAY(char, _name, mtInternal); 1.191 + } 1.192 + if (_path != NULL) { 1.193 + FREE_C_HEAP_ARRAY(char, _path, mtInternal); 1.194 + } 1.195 + if (_command_line != NULL) { 1.196 + FREE_C_HEAP_ARRAY(char, _command_line, mtInternal); 1.197 + } 1.198 + } 1.199 +}; 1.200 + 1.201 +class NetworkInterface : public ResourceObj { 1.202 + private: 1.203 + char* _name; 1.204 + uint64_t _bytes_in; 1.205 + uint64_t _bytes_out; 1.206 + NetworkInterface* _next; 1.207 + 1.208 + NetworkInterface(); // no impl 1.209 + NetworkInterface(const NetworkInterface& rhs); // no impl 1.210 + NetworkInterface& operator=(const NetworkInterface& rhs); // no impl 1.211 + public: 1.212 + NetworkInterface(const char* name, uint64_t bytes_in, uint64_t bytes_out, NetworkInterface* next) : 1.213 + _name(NULL), 1.214 + _bytes_in(bytes_in), 1.215 + _bytes_out(bytes_out), 1.216 + _next(next) { 1.217 + assert(name != NULL, "invariant"); 1.218 + const size_t length = strlen(name); 1.219 + assert(allocated_on_res_area(), "invariant"); 1.220 + _name = NEW_RESOURCE_ARRAY(char, length + 1); 1.221 + strncpy(_name, name, length + 1); 1.222 + assert(strncmp(_name, name, length) == 0, "invariant"); 1.223 + } 1.224 + 1.225 + NetworkInterface* next() const { 1.226 + return _next; 1.227 + } 1.228 + 1.229 + const char* get_name() const { 1.230 + return _name; 1.231 + } 1.232 + 1.233 + uint64_t get_bytes_out() const { 1.234 + return _bytes_out; 1.235 + } 1.236 + 1.237 + uint64_t get_bytes_in() const { 1.238 + return _bytes_in; 1.239 + } 1.240 +}; 1.241 + 1.242 +class CPUInformationInterface : public CHeapObj<mtInternal> { 1.243 + private: 1.244 + CPUInformation* _cpu_info; 1.245 + public: 1.246 + CPUInformationInterface(); 1.247 + bool initialize(); 1.248 + ~CPUInformationInterface(); 1.249 + int cpu_information(CPUInformation& cpu_info); 1.250 +}; 1.251 + 1.252 +class CPUPerformanceInterface : public CHeapObj<mtInternal> { 1.253 + private: 1.254 + class CPUPerformance; 1.255 + CPUPerformance* _impl; 1.256 + public: 1.257 + CPUPerformanceInterface(); 1.258 + ~CPUPerformanceInterface(); 1.259 + bool initialize(); 1.260 + 1.261 + int cpu_load(int which_logical_cpu, double* const cpu_load) const; 1.262 + int context_switch_rate(double* const rate) const; 1.263 + int cpu_load_total_process(double* const cpu_load) const; 1.264 + int cpu_loads_process(double* const pjvmUserLoad, 1.265 + double* const pjvmKernelLoad, 1.266 + double* const psystemTotalLoad) const; 1.267 +}; 1.268 + 1.269 +class SystemProcessInterface : public CHeapObj<mtInternal> { 1.270 + private: 1.271 + class SystemProcesses; 1.272 + SystemProcesses* _impl; 1.273 + public: 1.274 + SystemProcessInterface(); 1.275 + ~SystemProcessInterface(); 1.276 + bool initialize(); 1.277 + 1.278 + // information about system processes 1.279 + int system_processes(SystemProcess** system_procs, int* const no_of_sys_processes) const; 1.280 +}; 1.281 + 1.282 +class NetworkPerformanceInterface : public CHeapObj<mtInternal> { 1.283 + private: 1.284 + class NetworkPerformance; 1.285 + NetworkPerformance* _impl; 1.286 + NetworkPerformanceInterface(const NetworkPerformanceInterface& rhs); // no impl 1.287 + NetworkPerformanceInterface& operator=(const NetworkPerformanceInterface& rhs); // no impl 1.288 + public: 1.289 + NetworkPerformanceInterface(); 1.290 + bool initialize(); 1.291 + ~NetworkPerformanceInterface(); 1.292 + int network_utilization(NetworkInterface** network_interfaces) const; 1.293 +}; 1.294 + 1.295 +#endif // SHARE_VM_RUNTIME_OS_PERF_HPP