src/share/vm/runtime/os_perf.hpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

     1 /*
     2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_RUNTIME_OS_PERF_HPP
    26 #define SHARE_VM_RUNTIME_OS_PERF_HPP
    28 #include "utilities/macros.hpp"
    29 #include "memory/allocation.inline.hpp"
    30 #include "utilities/globalDefinitions.hpp"
    32 #define FUNCTIONALITY_NOT_IMPLEMENTED -8
    34 // XXX
    35 //class EnvironmentVariable : public CHeapObj<mtInternal> {
    36 // public:
    37 //  char* _key;
    38 //  char* _value;
    39 //
    40 //  EnvironmentVariable() {
    41 //    _key = NULL;
    42 //    _value = NULL;
    43 //  }
    44 //
    45 //  ~EnvironmentVariable() {
    46 //    if (_key != NULL) {
    47 //      FREE_C_HEAP_ARRAY(char, _key);
    48 //    }
    49 //    if (_value != NULL) {
    50 //      FREE_C_HEAP_ARRAY(char, _value);
    51 //    }
    52 //  }
    53 //
    54 //  EnvironmentVariable(char* key, char* value) {
    55 //    _key = key;
    56 //    _value = value;
    57 //  }
    58 //
    59 //};
    62 class CPUInformation : public CHeapObj<mtInternal> {
    63  private:
    64   int   _no_of_sockets;
    65   int   _no_of_cores;
    66   int   _no_of_hw_threads;
    67   const char* _description;
    68   const char* _name;
    70  public:
    71   CPUInformation() {
    72     _no_of_sockets = 0;
    73     _no_of_cores = 0;
    74     _no_of_hw_threads = 0;
    75     _description = NULL;
    76     _name = NULL;
    77   }
    79   int number_of_sockets(void) const {
    80     return _no_of_sockets;
    81   }
    83   void set_number_of_sockets(int no_of_sockets) {
    84     _no_of_sockets = no_of_sockets;
    85   }
    87   int number_of_cores(void) const {
    88     return _no_of_cores;
    89   }
    91   void set_number_of_cores(int no_of_cores) {
    92     _no_of_cores = no_of_cores;
    93   }
    95   int number_of_hardware_threads(void) const {
    96     return _no_of_hw_threads;
    97   }
    99   void set_number_of_hardware_threads(int no_of_hw_threads) {
   100     _no_of_hw_threads = no_of_hw_threads;
   101   }
   103   const char* cpu_name(void)  const {
   104     return _name;
   105   }
   107   void set_cpu_name(const char* cpu_name) {
   108     _name = cpu_name;
   109   }
   111   const char* cpu_description(void) const {
   112     return _description;
   113   }
   115   void set_cpu_description(const char* cpu_description) {
   116     _description = cpu_description;
   117   }
   118 };
   120 class SystemProcess : public CHeapObj<mtInternal> {
   121  private:
   122   int   _pid;
   123   char* _name;
   124   char* _path;
   125   char* _command_line;
   126   SystemProcess* _next;
   128  public:
   129   SystemProcess() {
   130     _pid  = 0;
   131     _name = NULL;
   132     _path = NULL;
   133     _command_line = NULL;
   134     _next = NULL;
   135   }
   137   SystemProcess(int pid, char* name, char* path, char* command_line, SystemProcess* next) {
   138     _pid = pid;
   139     _name = name;
   140     _path = path;
   141     _command_line = command_line;
   142     _next = next;
   143   }
   145   void set_next(SystemProcess* sys_process) {
   146     _next = sys_process;
   147   }
   149   SystemProcess* next(void) const {
   150     return _next;
   151   }
   153   int pid(void) const {
   154     return _pid;
   155   }
   157   void set_pid(int pid) {
   158     _pid = pid;
   159   }
   161   const char* name(void) const {
   162     return _name;
   163   }
   165   void set_name(char* name) {
   166     _name = name;
   167   }
   169   const char* path(void) const {
   170     return _path;
   171   }
   173   void set_path(char* path) {
   174     _path = path;
   175   }
   177   const char* command_line(void) const {
   178     return _command_line;
   179   }
   181   void set_command_line(char* command_line) {
   182     _command_line = command_line;
   183   }
   185   virtual ~SystemProcess(void) {
   186     if (_name != NULL) {
   187       FREE_C_HEAP_ARRAY(char, _name, mtInternal);
   188     }
   189     if (_path != NULL) {
   190       FREE_C_HEAP_ARRAY(char, _path, mtInternal);
   191     }
   192     if (_command_line != NULL) {
   193       FREE_C_HEAP_ARRAY(char, _command_line, mtInternal);
   194     }
   195   }
   196 };
   198 class NetworkInterface : public ResourceObj {
   199  private:
   200   char* _name;
   201   uint64_t _bytes_in;
   202   uint64_t _bytes_out;
   203   NetworkInterface* _next;
   205   NetworkInterface(); // no impl
   206   NetworkInterface(const NetworkInterface& rhs); // no impl
   207   NetworkInterface& operator=(const NetworkInterface& rhs); // no impl
   208  public:
   209   NetworkInterface(const char* name, uint64_t bytes_in, uint64_t bytes_out, NetworkInterface* next) :
   210   _name(NULL),
   211   _bytes_in(bytes_in),
   212   _bytes_out(bytes_out),
   213   _next(next) {
   214     assert(name != NULL, "invariant");
   215     const size_t length = strlen(name);
   216     assert(allocated_on_res_area(), "invariant");
   217     _name = NEW_RESOURCE_ARRAY(char, length + 1);
   218     strncpy(_name, name, length + 1);
   219     assert(strncmp(_name, name, length) == 0, "invariant");
   220   }
   222   NetworkInterface* next() const {
   223     return _next;
   224   }
   226   const char* get_name() const {
   227     return _name;
   228   }
   230   uint64_t get_bytes_out() const {
   231     return _bytes_out;
   232   }
   234   uint64_t get_bytes_in() const {
   235     return _bytes_in;
   236   }
   237 };
   239 class CPUInformationInterface : public CHeapObj<mtInternal> {
   240  private:
   241   CPUInformation* _cpu_info;
   242  public:
   243   CPUInformationInterface();
   244   bool initialize();
   245   ~CPUInformationInterface();
   246   int cpu_information(CPUInformation& cpu_info);
   247 };
   249 class CPUPerformanceInterface : public CHeapObj<mtInternal> {
   250  private:
   251   class CPUPerformance;
   252   CPUPerformance* _impl;
   253  public:
   254   CPUPerformanceInterface();
   255   ~CPUPerformanceInterface();
   256   bool initialize();
   258   int cpu_load(int which_logical_cpu, double* const cpu_load) const;
   259   int context_switch_rate(double* const rate) const;
   260   int cpu_load_total_process(double* const cpu_load) const;
   261   int cpu_loads_process(double* const pjvmUserLoad,
   262                         double* const pjvmKernelLoad,
   263                         double* const psystemTotalLoad) const;
   264 };
   266 class SystemProcessInterface : public CHeapObj<mtInternal> {
   267  private:
   268    class SystemProcesses;
   269    SystemProcesses* _impl;
   270  public:
   271    SystemProcessInterface();
   272    ~SystemProcessInterface();
   273    bool initialize();
   275   // information about system processes
   276   int system_processes(SystemProcess** system_procs, int* const no_of_sys_processes) const;
   277 };
   279 class NetworkPerformanceInterface : public CHeapObj<mtInternal> {
   280  private:
   281   class NetworkPerformance;
   282   NetworkPerformance* _impl;
   283   NetworkPerformanceInterface(const NetworkPerformanceInterface& rhs); // no impl
   284   NetworkPerformanceInterface& operator=(const NetworkPerformanceInterface& rhs); // no impl
   285  public:
   286   NetworkPerformanceInterface();
   287   bool initialize();
   288   ~NetworkPerformanceInterface();
   289   int network_utilization(NetworkInterface** network_interfaces) const;
   290 };
   292 #endif // SHARE_VM_RUNTIME_OS_PERF_HPP

mercurial