src/hotspot/os/aix/os_perf_aix.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58282 03fce7b04b42
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     1
/*
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 51106
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     4
 *
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     8
 *
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    13
 * accompanied this code).
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    14
 *
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    18
 *
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    21
 * questions.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    22
 *
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    23
 */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    24
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    25
#include "precompiled.hpp"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    26
#include "jvm.h"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    27
#include "memory/allocation.inline.hpp"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    28
#include "os_aix.inline.hpp"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    29
#include "runtime/os.hpp"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    30
#include "runtime/os_perf.hpp"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    31
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    32
#include CPU_HEADER(vm_version_ext)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    33
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    34
#include <stdio.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    35
#include <stdarg.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    36
#include <unistd.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    37
#include <errno.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    38
#include <string.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    39
#include <sys/resource.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    40
#include <sys/types.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    41
#include <sys/stat.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    42
#include <dirent.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    43
#include <stdlib.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    44
#include <dlfcn.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    45
#include <pthread.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    46
#include <limits.h>
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    47
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    48
/**
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    49
   /proc/[number]/stat
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    50
              Status information about the process.  This is used by ps(1).  It is defined in /usr/src/linux/fs/proc/array.c.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    51
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    52
              The fields, in order, with their proper scanf(3) format specifiers, are:
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    53
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    54
              1. pid %d The process id.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    55
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    56
              2. comm %s
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    57
                     The filename of the executable, in parentheses.  This is visible whether or not the executable is swapped out.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    58
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    59
              3. state %c
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    60
                     One  character  from  the  string "RSDZTW" where R is running, S is sleeping in an interruptible wait, D is waiting in uninterruptible disk
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    61
                     sleep, Z is zombie, T is traced or stopped (on a signal), and W is paging.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    62
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    63
              4. ppid %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    64
                     The PID of the parent.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    65
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    66
              5. pgrp %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    67
                     The process group ID of the process.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    68
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    69
              6. session %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    70
                     The session ID of the process.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    71
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    72
              7. tty_nr %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    73
                     The tty the process uses.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    74
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    75
              8. tpgid %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    76
                     The process group ID of the process which currently owns the tty that the process is connected to.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    77
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    78
              9. flags %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    79
                     The flags of the process.  The math bit is decimal 4, and the traced bit is decimal 10.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    80
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    81
              10. minflt %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    82
                     The number of minor faults the process has made which have not required loading a memory page from disk.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    83
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    84
              11. cminflt %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    85
                     The number of minor faults that the process's waited-for children have made.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    86
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    87
              12. majflt %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    88
                     The number of major faults the process has made which have required loading a memory page from disk.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    89
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    90
              13. cmajflt %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    91
                     The number of major faults that the process's waited-for children have made.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    92
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    93
              14. utime %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    94
                     The number of jiffies that this process has been scheduled in user mode.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    95
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    96
              15. stime %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    97
                     The number of jiffies that this process has been scheduled in kernel mode.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    98
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
    99
              16. cutime %ld
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   100
                     The number of jiffies that this process's waited-for children have been scheduled in user mode. (See also times(2).)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   101
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   102
              17. cstime %ld
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   103
                     The number of jiffies that this process' waited-for children have been scheduled in kernel mode.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   104
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   105
              18. priority %ld
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   106
                     The standard nice value, plus fifteen.  The value is never negative in the kernel.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   107
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   108
              19. nice %ld
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   109
                     The nice value ranges from 19 (nicest) to -19 (not nice to others).
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   110
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   111
              20. 0 %ld  This value is hard coded to 0 as a placeholder for a removed field.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   112
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   113
              21. itrealvalue %ld
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   114
                     The time in jiffies before the next SIGALRM is sent to the process due to an interval timer.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   115
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   116
              22. starttime %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   117
                     The time in jiffies the process started after system boot.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   118
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   119
              23. vsize %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   120
                     Virtual memory size in bytes.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   121
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   122
              24. rss %ld
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   123
                     Resident Set Size: number of pages the process has in real memory, minus 3 for administrative purposes. This is just the pages which  count
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   124
                     towards text, data, or stack space.  This does not include pages which have not been demand-loaded in, or which are swapped out.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   125
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   126
              25. rlim %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   127
                     Current limit in bytes on the rss of the process (usually 4294967295 on i386).
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   128
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   129
              26. startcode %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   130
                     The address above which program text can run.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   131
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   132
              27. endcode %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   133
                     The address below which program text can run.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   134
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   135
              28. startstack %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   136
                     The address of the start of the stack.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   137
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   138
              29. kstkesp %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   139
                     The current value of esp (stack pointer), as found in the kernel stack page for the process.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   140
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   141
              30. kstkeip %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   142
                     The current EIP (instruction pointer).
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   143
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   144
              31. signal %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   145
                     The bitmap of pending signals (usually 0).
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   146
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   147
              32. blocked %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   148
                     The bitmap of blocked signals (usually 0, 2 for shells).
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   149
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   150
              33. sigignore %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   151
                     The bitmap of ignored signals.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   152
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   153
              34. sigcatch %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   154
                     The bitmap of catched signals.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   155
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   156
              35. wchan %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   157
                     This  is the "channel" in which the process is waiting.  It is the address of a system call, and can be looked up in a namelist if you need
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   158
                     a textual name.  (If you have an up-to-date /etc/psdatabase, then try ps -l to see the WCHAN field in action.)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   159
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   160
              36. nswap %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   161
                     Number of pages swapped - not maintained.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   162
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   163
              37. cnswap %lu
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   164
                     Cumulative nswap for child processes.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   165
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   166
              38. exit_signal %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   167
                     Signal to be sent to parent when we die.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   168
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   169
              39. processor %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   170
                     CPU number last executed on.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   171
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   172
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   173
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   174
 ///// SSCANF FORMAT STRING. Copy and use.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   175
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   176
field:        1  2  3  4  5  6  7  8  9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38 39
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   177
format:       %d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   178
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   179
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   180
*/
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   181
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   182
/**
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   183
 * For platforms that have them, when declaring
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   184
 * a printf-style function,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   185
 *   formatSpec is the parameter number (starting at 1)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   186
 *       that is the format argument ("%d pid %s")
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   187
 *   params is the parameter number where the actual args to
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   188
 *       the format starts. If the args are in a va_list, this
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   189
 *       should be 0.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   190
 */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   191
#ifndef PRINTF_ARGS
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   192
#  define PRINTF_ARGS(formatSpec,  params) ATTRIBUTE_PRINTF(formatSpec, params)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   193
#endif
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   194
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   195
#ifndef SCANF_ARGS
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   196
#  define SCANF_ARGS(formatSpec,   params) ATTRIBUTE_SCANF(formatSpec, params)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   197
#endif
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   198
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   199
#ifndef _PRINTFMT_
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   200
#  define _PRINTFMT_
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   201
#endif
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   202
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   203
#ifndef _SCANFMT_
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   204
#  define _SCANFMT_
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   205
#endif
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   206
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   207
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   208
struct CPUPerfTicks {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   209
  uint64_t  used;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   210
  uint64_t  usedKernel;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   211
  uint64_t  total;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   212
};
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   213
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   214
typedef enum {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   215
  CPU_LOAD_VM_ONLY,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   216
  CPU_LOAD_GLOBAL,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   217
} CpuLoadTarget;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   218
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   219
enum {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   220
  UNDETECTED,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   221
  UNDETECTABLE,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   222
  LINUX26_NPTL,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   223
  BAREMETAL
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   224
};
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   225
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   226
struct CPUPerfCounters {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   227
  int   nProcs;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   228
  CPUPerfTicks jvmTicks;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   229
  CPUPerfTicks* cpus;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   230
};
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   231
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   232
static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, double* pkernelLoad, CpuLoadTarget target);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   233
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   234
/** reads /proc/<pid>/stat data, with some checks and some skips.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   235
 *  Ensure that 'fmt' does _NOT_ contain the first two "%d %s"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   236
 */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   237
static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const char* fmt, va_list args) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   238
  FILE*f;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   239
  int n;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   240
  char buf[2048];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   241
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   242
  if ((f = fopen(procfile, "r")) == NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   243
    return -1;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   244
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   245
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   246
  if ((n = fread(buf, 1, sizeof(buf), f)) != -1) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   247
    char *tmp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   248
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   249
    buf[n-1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   250
    /** skip through pid and exec name. */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   251
    if ((tmp = strrchr(buf, ')')) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   252
      // skip the ')' and the following space
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   253
      // but check that buffer is long enough
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   254
      tmp += 2;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   255
      if (tmp < buf + n) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   256
        n = vsscanf(tmp, fmt, args);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   257
      }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   258
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   259
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   260
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   261
  fclose(f);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   262
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   263
  return n;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   264
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   265
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   266
static int SCANF_ARGS(2, 3) read_statdata(const char* procfile, _SCANFMT_ const char* fmt, ...) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   267
  int   n;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   268
  va_list args;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   269
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   270
  va_start(args, fmt);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   271
  n = vread_statdata(procfile, fmt, args);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   272
  va_end(args);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   273
  return n;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   274
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   275
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   276
/**
54499
3ea8b5858874 8221915: cleanup ticks related coding in os_perf_aix.cpp [aix]
mbaesken
parents: 54470
diff changeset
   277
 * on Linux we got the ticks related information from /proc/stat
3ea8b5858874 8221915: cleanup ticks related coding in os_perf_aix.cpp [aix]
mbaesken
parents: 54470
diff changeset
   278
 * this does not work on AIX, libperfstat might be an alternative
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   279
 */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   280
static OSReturn get_total_ticks(int which_logical_cpu, CPUPerfTicks* pticks) {
54499
3ea8b5858874 8221915: cleanup ticks related coding in os_perf_aix.cpp [aix]
mbaesken
parents: 54470
diff changeset
   281
  return OS_ERR;
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   282
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   283
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   284
/** read user and system ticks from a named procfile, assumed to be in 'stat' format then. */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   285
static int read_ticks(const char* procfile, uint64_t* userTicks, uint64_t* systemTicks) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   286
  return read_statdata(procfile, "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " UINT64_FORMAT " " UINT64_FORMAT,
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   287
    userTicks, systemTicks);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   288
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   289
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   290
/**
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   291
 * Return the number of ticks spent in any of the processes belonging
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   292
 * to the JVM on any CPU.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   293
 */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   294
static OSReturn get_jvm_ticks(CPUPerfTicks* pticks) {
54499
3ea8b5858874 8221915: cleanup ticks related coding in os_perf_aix.cpp [aix]
mbaesken
parents: 54470
diff changeset
   295
  return OS_ERR;
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   296
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   297
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   298
/**
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   299
 * Return the load of the CPU as a double. 1.0 means the CPU process uses all
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   300
 * available time for user or system processes, 0.0 means the CPU uses all time
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   301
 * being idle.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   302
 *
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   303
 * Returns a negative value if there is a problem in determining the CPU load.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   304
 */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   305
static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, double* pkernelLoad, CpuLoadTarget target) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   306
  uint64_t udiff, kdiff, tdiff;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   307
  CPUPerfTicks* pticks;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   308
  CPUPerfTicks  tmp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   309
  double user_load;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   310
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   311
  *pkernelLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   312
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   313
  if (target == CPU_LOAD_VM_ONLY) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   314
    pticks = &counters->jvmTicks;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   315
  } else if (-1 == which_logical_cpu) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   316
    pticks = &counters->cpus[counters->nProcs];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   317
  } else {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   318
    pticks = &counters->cpus[which_logical_cpu];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   319
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   320
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   321
  tmp = *pticks;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   322
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   323
  if (target == CPU_LOAD_VM_ONLY) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   324
    if (get_jvm_ticks(pticks) != OS_OK) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   325
      return -1.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   326
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   327
  } else if (get_total_ticks(which_logical_cpu, pticks) != OS_OK) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   328
    return -1.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   329
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   330
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   331
  // seems like we sometimes end up with less kernel ticks when
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   332
  // reading /proc/self/stat a second time, timing issue between cpus?
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   333
  if (pticks->usedKernel < tmp.usedKernel) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   334
    kdiff = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   335
  } else {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   336
    kdiff = pticks->usedKernel - tmp.usedKernel;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   337
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   338
  tdiff = pticks->total - tmp.total;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   339
  udiff = pticks->used - tmp.used;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   340
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   341
  if (tdiff == 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   342
    return 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   343
  } else if (tdiff < (udiff + kdiff)) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   344
    tdiff = udiff + kdiff;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   345
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   346
  *pkernelLoad = (kdiff / (double)tdiff);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   347
  // BUG9044876, normalize return values to sane values
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   348
  *pkernelLoad = MAX2<double>(*pkernelLoad, 0.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   349
  *pkernelLoad = MIN2<double>(*pkernelLoad, 1.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   350
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   351
  user_load = (udiff / (double)tdiff);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   352
  user_load = MAX2<double>(user_load, 0.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   353
  user_load = MIN2<double>(user_load, 1.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   354
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   355
  return user_load;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   356
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   357
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   358
static int SCANF_ARGS(1, 2) parse_stat(_SCANFMT_ const char* fmt, ...) {
54499
3ea8b5858874 8221915: cleanup ticks related coding in os_perf_aix.cpp [aix]
mbaesken
parents: 54470
diff changeset
   359
  return OS_ERR;
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   360
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   361
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   362
static int get_noof_context_switches(uint64_t* switches) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   363
  return parse_stat("ctxt " UINT64_FORMAT "\n", switches);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   364
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   365
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   366
/** returns boot time in _seconds_ since epoch */
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   367
static int get_boot_time(uint64_t* time) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   368
  return parse_stat("btime " UINT64_FORMAT "\n", time);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   369
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   370
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   371
static int perf_context_switch_rate(double* rate) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   372
  static pthread_mutex_t contextSwitchLock = PTHREAD_MUTEX_INITIALIZER;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   373
  static uint64_t      lastTime;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   374
  static uint64_t      lastSwitches;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   375
  static double        lastRate;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   376
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   377
  uint64_t lt = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   378
  int res = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   379
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   380
  if (lastTime == 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   381
    uint64_t tmp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   382
    if (get_boot_time(&tmp) < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   383
      return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   384
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   385
    lt = tmp * 1000;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   386
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   387
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   388
  res = OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   389
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   390
  pthread_mutex_lock(&contextSwitchLock);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   391
  {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   392
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   393
    uint64_t sw;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   394
    s8 t, d;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   395
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   396
    if (lastTime == 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   397
      lastTime = lt;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   398
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   399
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   400
    t = os::javaTimeMillis();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   401
    d = t - lastTime;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   402
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   403
    if (d == 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   404
      *rate = lastRate;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   405
    } else if (!get_noof_context_switches(&sw)) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   406
      *rate      = ( (double)(sw - lastSwitches) / d ) * 1000;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   407
      lastRate     = *rate;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   408
      lastSwitches = sw;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   409
      lastTime     = t;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   410
    } else {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   411
      *rate = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   412
      res   = OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   413
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   414
    if (*rate <= 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   415
      *rate = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   416
      lastRate = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   417
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   418
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   419
  pthread_mutex_unlock(&contextSwitchLock);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   420
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   421
  return res;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   422
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   423
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   424
class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   425
  friend class CPUPerformanceInterface;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   426
 private:
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   427
  CPUPerfCounters _counters;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   428
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   429
  int cpu_load(int which_logical_cpu, double* cpu_load);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   430
  int context_switch_rate(double* rate);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   431
  int cpu_load_total_process(double* cpu_load);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   432
  int cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   433
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   434
 public:
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   435
  CPUPerformance();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   436
  bool initialize();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   437
  ~CPUPerformance();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   438
};
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   439
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   440
CPUPerformanceInterface::CPUPerformance::CPUPerformance() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   441
  _counters.nProcs = os::active_processor_count();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   442
  _counters.cpus = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   443
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   444
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   445
bool CPUPerformanceInterface::CPUPerformance::initialize() {
58083
9046db64ca39 8227168: Cleanup usage of NEW_C_HEAP_ARRAY
lkorinth
parents: 54499
diff changeset
   446
  size_t array_entry_count = _counters.nProcs + 1;
9046db64ca39 8227168: Cleanup usage of NEW_C_HEAP_ARRAY
lkorinth
parents: 54499
diff changeset
   447
  _counters.cpus = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
9046db64ca39 8227168: Cleanup usage of NEW_C_HEAP_ARRAY
lkorinth
parents: 54499
diff changeset
   448
  memset(_counters.cpus, 0, array_entry_count * sizeof(*_counters.cpus));
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   449
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   450
  // For the CPU load total
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   451
  get_total_ticks(-1, &_counters.cpus[_counters.nProcs]);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   452
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   453
  // For each CPU
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   454
  for (int i = 0; i < _counters.nProcs; i++) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   455
    get_total_ticks(i, &_counters.cpus[i]);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   456
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   457
  // For JVM load
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   458
  get_jvm_ticks(&_counters.jvmTicks);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   459
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   460
  // initialize context switch system
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   461
  // the double is only for init
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   462
  double init_ctx_switch_rate;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   463
  perf_context_switch_rate(&init_ctx_switch_rate);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   464
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   465
  return true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   466
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   467
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   468
CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   469
  if (_counters.cpus != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   470
    FREE_C_HEAP_ARRAY(char, _counters.cpus);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   471
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   472
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   473
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   474
int CPUPerformanceInterface::CPUPerformance::cpu_load(int which_logical_cpu, double* cpu_load) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   475
  double u, s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   476
  u = get_cpu_load(which_logical_cpu, &_counters, &s, CPU_LOAD_GLOBAL);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   477
  if (u < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   478
    *cpu_load = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   479
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   480
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   481
  // Cap total systemload to 1.0
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   482
  *cpu_load = MIN2<double>((u + s), 1.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   483
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   484
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   485
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   486
int CPUPerformanceInterface::CPUPerformance::cpu_load_total_process(double* cpu_load) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   487
  double u, s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   488
  u = get_cpu_load(-1, &_counters, &s, CPU_LOAD_VM_ONLY);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   489
  if (u < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   490
    *cpu_load = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   491
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   492
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   493
  *cpu_load = u + s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   494
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   495
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   496
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   497
int CPUPerformanceInterface::CPUPerformance::cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   498
  double u, s, t;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   499
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   500
  assert(pjvmUserLoad != NULL, "pjvmUserLoad not inited");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   501
  assert(pjvmKernelLoad != NULL, "pjvmKernelLoad not inited");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   502
  assert(psystemTotalLoad != NULL, "psystemTotalLoad not inited");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   503
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   504
  u = get_cpu_load(-1, &_counters, &s, CPU_LOAD_VM_ONLY);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   505
  if (u < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   506
    *pjvmUserLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   507
    *pjvmKernelLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   508
    *psystemTotalLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   509
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   510
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   511
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   512
  cpu_load(-1, &t);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   513
  // clamp at user+system and 1.0
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   514
  if (u + s > t) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   515
    t = MIN2<double>(u + s, 1.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   516
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   517
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   518
  *pjvmUserLoad = u;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   519
  *pjvmKernelLoad = s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   520
  *psystemTotalLoad = t;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   521
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   522
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   523
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   524
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   525
int CPUPerformanceInterface::CPUPerformance::context_switch_rate(double* rate) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   526
  return perf_context_switch_rate(rate);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   527
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   528
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   529
CPUPerformanceInterface::CPUPerformanceInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   530
  _impl = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   531
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   532
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   533
bool CPUPerformanceInterface::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   534
  _impl = new CPUPerformanceInterface::CPUPerformance();
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   535
  return _impl->initialize();
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   536
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   537
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   538
CPUPerformanceInterface::~CPUPerformanceInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   539
  if (_impl != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   540
    delete _impl;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   541
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   542
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   543
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   544
int CPUPerformanceInterface::cpu_load(int which_logical_cpu, double* cpu_load) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   545
  return _impl->cpu_load(which_logical_cpu, cpu_load);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   546
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   547
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   548
int CPUPerformanceInterface::cpu_load_total_process(double* cpu_load) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   549
  return _impl->cpu_load_total_process(cpu_load);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   550
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   551
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   552
int CPUPerformanceInterface::cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   553
  return _impl->cpu_loads_process(pjvmUserLoad, pjvmKernelLoad, psystemTotalLoad);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   554
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   555
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   556
int CPUPerformanceInterface::context_switch_rate(double* rate) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   557
  return _impl->context_switch_rate(rate);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   558
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   559
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   560
class SystemProcessInterface::SystemProcesses : public CHeapObj<mtInternal> {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   561
  friend class SystemProcessInterface;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   562
 private:
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   563
  class ProcessIterator : public CHeapObj<mtInternal> {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   564
    friend class SystemProcessInterface::SystemProcesses;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   565
   private:
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   566
    DIR*           _dir;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   567
    struct dirent* _entry;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   568
    bool           _valid;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   569
    char           _exeName[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   570
    char           _exePath[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   571
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   572
    ProcessIterator();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   573
    ~ProcessIterator();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   574
    bool initialize();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   575
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   576
    bool is_valid() const { return _valid; }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   577
    bool is_valid_entry(struct dirent* entry) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   578
    bool is_dir(const char* name) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   579
    int  fsize(const char* name, uint64_t& size) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   580
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   581
    char* allocate_string(const char* str) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   582
    void  get_exe_name();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   583
    char* get_exe_path();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   584
    char* get_cmdline();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   585
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   586
    int current(SystemProcess* process_info);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   587
    int next_process();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   588
  };
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   589
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   590
  ProcessIterator* _iterator;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   591
  SystemProcesses();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   592
  bool initialize();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   593
  ~SystemProcesses();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   594
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   595
  //information about system processes
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   596
  int system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   597
};
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   598
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   599
bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_dir(const char* name) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   600
  struct stat mystat;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   601
  int ret_val = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   602
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   603
  ret_val = stat(name, &mystat);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   604
  if (ret_val < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   605
    return false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   606
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   607
  ret_val = S_ISDIR(mystat.st_mode);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   608
  return ret_val > 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   609
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   610
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   611
int SystemProcessInterface::SystemProcesses::ProcessIterator::fsize(const char* name, uint64_t& size) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   612
  assert(name != NULL, "name pointer is NULL!");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   613
  size = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   614
  struct stat fbuf;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   615
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   616
  if (stat(name, &fbuf) < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   617
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   618
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   619
  size = fbuf.st_size;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   620
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   621
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   622
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   623
// if it has a numeric name, is a directory and has a 'stat' file in it
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   624
bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_valid_entry(struct dirent* entry) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   625
  char buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   626
  uint64_t size = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   627
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   628
  if (atoi(entry->d_name) != 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   629
    jio_snprintf(buffer, PATH_MAX, "/proc/%s", entry->d_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   630
    buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   631
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   632
    if (is_dir(buffer)) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   633
      jio_snprintf(buffer, PATH_MAX, "/proc/%s/stat", entry->d_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   634
      buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   635
      if (fsize(buffer, size) != OS_ERR) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   636
        return true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   637
      }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   638
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   639
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   640
  return false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   641
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   642
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   643
// get exe-name from /proc/<pid>/stat
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   644
void SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_name() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   645
  FILE* fp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   646
  char  buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   647
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   648
  jio_snprintf(buffer, PATH_MAX, "/proc/%s/stat", _entry->d_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   649
  buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   650
  if ((fp = fopen(buffer, "r")) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   651
    if (fgets(buffer, PATH_MAX, fp) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   652
      char* start, *end;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   653
      // exe-name is between the first pair of ( and )
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   654
      start = strchr(buffer, '(');
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   655
      if (start != NULL && start[1] != '\0') {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   656
        start++;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   657
        end = strrchr(start, ')');
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   658
        if (end != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   659
          size_t len;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   660
          len = MIN2<size_t>(end - start, sizeof(_exeName) - 1);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   661
          memcpy(_exeName, start, len);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   662
          _exeName[len] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   663
        }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   664
      }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   665
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   666
    fclose(fp);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   667
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   668
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   669
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   670
// get command line from /proc/<pid>/cmdline
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   671
char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   672
  FILE* fp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   673
  char  buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   674
  char* cmdline = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   675
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   676
  jio_snprintf(buffer, PATH_MAX, "/proc/%s/cmdline", _entry->d_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   677
  buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   678
  if ((fp = fopen(buffer, "r")) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   679
    size_t size = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   680
    char   dummy;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   681
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   682
    // find out how long the file is (stat always returns 0)
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   683
    while (fread(&dummy, 1, 1, fp) == 1) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   684
      size++;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   685
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   686
    if (size > 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   687
      cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   688
      cmdline[0] = '\0';
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   689
      if (fseek(fp, 0, SEEK_SET) == 0) {
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   690
        if (fread(cmdline, 1, size, fp) == size) {
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   691
          // the file has the arguments separated by '\0',
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   692
          // so we translate '\0' to ' '
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   693
          for (size_t i = 0; i < size; i++) {
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   694
            if (cmdline[i] == '\0') {
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   695
              cmdline[i] = ' ';
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   696
            }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   697
          }
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   698
          cmdline[size] = '\0';
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   699
        }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   700
      }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   701
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   702
    fclose(fp);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   703
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   704
  return cmdline;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   705
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   706
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   707
// get full path to exe from /proc/<pid>/exe symlink
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   708
char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   709
  char buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   710
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   711
  jio_snprintf(buffer, PATH_MAX, "/proc/%s/exe", _entry->d_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   712
  buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   713
  return realpath(buffer, _exePath);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   714
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   715
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   716
char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   717
  if (str != NULL) {
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 51106
diff changeset
   718
    return os::strdup_check_oom(str, mtInternal);
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   719
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   720
  return NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   721
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   722
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   723
int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProcess* process_info) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   724
  if (!is_valid()) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   725
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   726
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   727
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   728
  process_info->set_pid(atoi(_entry->d_name));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   729
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   730
  get_exe_name();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   731
  process_info->set_name(allocate_string(_exeName));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   732
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   733
  if (get_exe_path() != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   734
     process_info->set_path(allocate_string(_exePath));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   735
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   736
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   737
  char* cmdline = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   738
  cmdline = get_cmdline();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   739
  if (cmdline != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   740
    process_info->set_command_line(allocate_string(cmdline));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   741
    FREE_C_HEAP_ARRAY(char, cmdline);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   742
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   743
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   744
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   745
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   746
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   747
int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   748
  if (!is_valid()) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   749
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   750
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   751
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   752
  do {
51106
f605c91e5219 8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents: 50879
diff changeset
   753
    _entry = os::readdir(_dir);
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   754
    if (_entry == NULL) {
51106
f605c91e5219 8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents: 50879
diff changeset
   755
      // Error or reached end.  Could use errno to distinguish those cases.
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   756
      _valid = false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   757
      return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   758
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   759
  } while(!is_valid_entry(_entry));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   760
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   761
  _valid = true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   762
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   763
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   764
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   765
SystemProcessInterface::SystemProcesses::ProcessIterator::ProcessIterator() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   766
  _dir = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   767
  _entry = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   768
  _valid = false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   769
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   770
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   771
bool SystemProcessInterface::SystemProcesses::ProcessIterator::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   772
  // Not yet implemented.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   773
  return false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   774
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   775
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   776
SystemProcessInterface::SystemProcesses::ProcessIterator::~ProcessIterator() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   777
  if (_dir != NULL) {
51106
f605c91e5219 8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents: 50879
diff changeset
   778
    os::closedir(_dir);
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   779
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   780
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   781
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   782
SystemProcessInterface::SystemProcesses::SystemProcesses() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   783
  _iterator = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   784
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   785
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   786
bool SystemProcessInterface::SystemProcesses::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   787
  _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   788
  return _iterator->initialize();
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   789
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   790
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   791
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   792
  if (_iterator != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   793
    delete _iterator;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   794
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   795
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   796
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   797
int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   798
  assert(system_processes != NULL, "system_processes pointer is NULL!");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   799
  assert(no_of_sys_processes != NULL, "system_processes counter pointers is NULL!");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   800
  assert(_iterator != NULL, "iterator is NULL!");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   801
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   802
  // initialize pointers
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   803
  *no_of_sys_processes = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   804
  *system_processes = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   805
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   806
  while (_iterator->is_valid()) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   807
    SystemProcess* tmp = new SystemProcess();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   808
    _iterator->current(tmp);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   809
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   810
    //if already existing head
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   811
    if (*system_processes != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   812
      //move "first to second"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   813
      tmp->set_next(*system_processes);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   814
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   815
    // new head
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   816
    *system_processes = tmp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   817
    // increment
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   818
    (*no_of_sys_processes)++;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   819
    // step forward
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   820
    _iterator->next_process();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   821
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   822
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   823
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   824
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   825
int SystemProcessInterface::system_processes(SystemProcess** system_procs, int* no_of_sys_processes) const {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   826
  return _impl->system_processes(system_procs, no_of_sys_processes);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   827
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   828
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   829
SystemProcessInterface::SystemProcessInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   830
  _impl = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   831
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   832
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   833
bool SystemProcessInterface::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   834
  _impl = new SystemProcessInterface::SystemProcesses();
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   835
  return _impl->initialize();
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   836
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   837
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   838
SystemProcessInterface::~SystemProcessInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   839
  if (_impl != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   840
    delete _impl;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   841
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   842
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   843
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   844
CPUInformationInterface::CPUInformationInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   845
  _cpu_info = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   846
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   847
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   848
bool CPUInformationInterface::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   849
  _cpu_info = new CPUInformation();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   850
  _cpu_info->set_number_of_hardware_threads(VM_Version_Ext::number_of_threads());
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   851
  _cpu_info->set_number_of_cores(VM_Version_Ext::number_of_cores());
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   852
  _cpu_info->set_number_of_sockets(VM_Version_Ext::number_of_sockets());
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   853
  _cpu_info->set_cpu_name(VM_Version_Ext::cpu_name());
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   854
  _cpu_info->set_cpu_description(VM_Version_Ext::cpu_description());
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   855
  return true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   856
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   857
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   858
CPUInformationInterface::~CPUInformationInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   859
  if (_cpu_info != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   860
    if (_cpu_info->cpu_name() != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   861
      const char* cpu_name = _cpu_info->cpu_name();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   862
      FREE_C_HEAP_ARRAY(char, cpu_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   863
      _cpu_info->set_cpu_name(NULL);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   864
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   865
    if (_cpu_info->cpu_description() != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   866
       const char* cpu_desc = _cpu_info->cpu_description();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   867
       FREE_C_HEAP_ARRAY(char, cpu_desc);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   868
      _cpu_info->set_cpu_description(NULL);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   869
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   870
    delete _cpu_info;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   871
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   872
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   873
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   874
int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   875
  if (_cpu_info == NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   876
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   877
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   878
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   879
  cpu_info = *_cpu_info; // shallow copy assignment
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   880
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   881
}
50879
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   882
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   883
class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtInternal> {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   884
  friend class NetworkPerformanceInterface;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   885
 private:
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   886
  NetworkPerformance();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   887
  NetworkPerformance(const NetworkPerformance& rhs); // no impl
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   888
  NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   889
  bool initialize();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   890
  ~NetworkPerformance();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   891
  int network_utilization(NetworkInterface** network_interfaces) const;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   892
};
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   893
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   894
NetworkPerformanceInterface::NetworkPerformance::NetworkPerformance() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   895
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   896
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   897
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   898
bool NetworkPerformanceInterface::NetworkPerformance::initialize() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   899
  return true;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   900
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   901
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   902
NetworkPerformanceInterface::NetworkPerformance::~NetworkPerformance() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   903
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   904
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   905
int NetworkPerformanceInterface::NetworkPerformance::network_utilization(NetworkInterface** network_interfaces) const
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   906
{
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   907
  return FUNCTIONALITY_NOT_IMPLEMENTED;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   908
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   909
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   910
NetworkPerformanceInterface::NetworkPerformanceInterface() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   911
  _impl = NULL;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   912
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   913
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   914
NetworkPerformanceInterface::~NetworkPerformanceInterface() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   915
  if (_impl != NULL) {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   916
    delete _impl;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   917
  }
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   918
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   919
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   920
bool NetworkPerformanceInterface::initialize() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   921
  _impl = new NetworkPerformanceInterface::NetworkPerformance();
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58083
diff changeset
   922
  return _impl->initialize();
50879
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   923
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   924
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   925
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   926
  return _impl->network_utilization(network_interfaces);
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   927
}