src/hotspot/os/aix/os_perf_aix.cpp
author mbaesken
Wed, 10 Apr 2019 09:33:32 +0200
changeset 54499 3ea8b5858874
parent 54470 14986fb09d9a
child 58083 9046db64ca39
child 58678 9cf78a70fa4f
permissions -rw-r--r--
8221915: cleanup ticks related coding in os_perf_aix.cpp [aix] Reviewed-by: mdoerr
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() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   446
  size_t tick_array_size = (_counters.nProcs +1) * sizeof(CPUPerfTicks);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   447
  _counters.cpus = (CPUPerfTicks*)NEW_C_HEAP_ARRAY(char, tick_array_size, mtInternal);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   448
  if (NULL == _counters.cpus) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   449
    return false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   450
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   451
  memset(_counters.cpus, 0, tick_array_size);
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 the CPU load total
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   454
  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
   455
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   456
  // For each CPU
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   457
  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
   458
    get_total_ticks(i, &_counters.cpus[i]);
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
  // For JVM load
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   461
  get_jvm_ticks(&_counters.jvmTicks);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   462
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   463
  // initialize context switch system
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   464
  // the double is only for init
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   465
  double init_ctx_switch_rate;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   466
  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
   467
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   468
  return true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   469
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   470
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   471
CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   472
  if (_counters.cpus != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   473
    FREE_C_HEAP_ARRAY(char, _counters.cpus);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   474
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   475
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   476
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   477
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
   478
  double u, s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   479
  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
   480
  if (u < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   481
    *cpu_load = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   482
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   483
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   484
  // Cap total systemload to 1.0
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   485
  *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
   486
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   487
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   488
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   489
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
   490
  double u, s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   491
  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
   492
  if (u < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   493
    *cpu_load = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   494
    return OS_ERR;
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
  *cpu_load = u + s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   497
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   498
}
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
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
   501
  double u, s, t;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   502
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   503
  assert(pjvmUserLoad != NULL, "pjvmUserLoad not inited");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   504
  assert(pjvmKernelLoad != NULL, "pjvmKernelLoad not inited");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   505
  assert(psystemTotalLoad != NULL, "psystemTotalLoad not inited");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   506
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   507
  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
   508
  if (u < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   509
    *pjvmUserLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   510
    *pjvmKernelLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   511
    *psystemTotalLoad = 0.0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   512
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   513
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   514
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   515
  cpu_load(-1, &t);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   516
  // clamp at user+system and 1.0
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   517
  if (u + s > t) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   518
    t = MIN2<double>(u + s, 1.0);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   519
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   520
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   521
  *pjvmUserLoad = u;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   522
  *pjvmKernelLoad = s;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   523
  *psystemTotalLoad = t;
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
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   526
}
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
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
   529
  return perf_context_switch_rate(rate);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   530
}
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
CPUPerformanceInterface::CPUPerformanceInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   533
  _impl = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   534
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   535
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   536
bool CPUPerformanceInterface::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   537
  _impl = new CPUPerformanceInterface::CPUPerformance();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   538
  return NULL == _impl ? false : _impl->initialize();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   539
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   540
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   541
CPUPerformanceInterface::~CPUPerformanceInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   542
  if (_impl != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   543
    delete _impl;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   544
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   545
}
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
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
   548
  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
   549
}
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
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
   552
  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
   553
}
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
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
   556
  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
   557
}
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
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
   560
  return _impl->context_switch_rate(rate);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   561
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   562
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   563
class SystemProcessInterface::SystemProcesses : public CHeapObj<mtInternal> {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   564
  friend class SystemProcessInterface;
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
  class ProcessIterator : public CHeapObj<mtInternal> {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   567
    friend class SystemProcessInterface::SystemProcesses;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   568
   private:
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   569
    DIR*           _dir;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   570
    struct dirent* _entry;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   571
    bool           _valid;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   572
    char           _exeName[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   573
    char           _exePath[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   574
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   575
    ProcessIterator();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   576
    ~ProcessIterator();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   577
    bool initialize();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   578
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   579
    bool is_valid() const { return _valid; }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   580
    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
   581
    bool is_dir(const char* name) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   582
    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
   583
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   584
    char* allocate_string(const char* str) const;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   585
    void  get_exe_name();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   586
    char* get_exe_path();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   587
    char* get_cmdline();
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
    int current(SystemProcess* process_info);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   590
    int next_process();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   591
  };
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   592
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   593
  ProcessIterator* _iterator;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   594
  SystemProcesses();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   595
  bool initialize();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   596
  ~SystemProcesses();
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
  //information about system processes
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   599
  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
   600
};
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   601
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   602
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
   603
  struct stat mystat;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   604
  int ret_val = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   605
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   606
  ret_val = stat(name, &mystat);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   607
  if (ret_val < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   608
    return false;
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
  ret_val = S_ISDIR(mystat.st_mode);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   611
  return ret_val > 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   612
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   613
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   614
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
   615
  assert(name != NULL, "name pointer is NULL!");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   616
  size = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   617
  struct stat fbuf;
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
  if (stat(name, &fbuf) < 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   620
    return OS_ERR;
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
  size = fbuf.st_size;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   623
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   624
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   625
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   626
// 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
   627
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
   628
  char buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   629
  uint64_t size = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   630
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   631
  if (atoi(entry->d_name) != 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   632
    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
   633
    buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   634
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   635
    if (is_dir(buffer)) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   636
      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
   637
      buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   638
      if (fsize(buffer, size) != OS_ERR) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   639
        return true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   640
      }
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
  return false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   644
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   645
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   646
// get exe-name from /proc/<pid>/stat
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   647
void SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_name() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   648
  FILE* fp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   649
  char  buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   650
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   651
  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
   652
  buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   653
  if ((fp = fopen(buffer, "r")) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   654
    if (fgets(buffer, PATH_MAX, fp) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   655
      char* start, *end;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   656
      // 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
   657
      start = strchr(buffer, '(');
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   658
      if (start != NULL && start[1] != '\0') {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   659
        start++;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   660
        end = strrchr(start, ')');
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   661
        if (end != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   662
          size_t len;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   663
          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
   664
          memcpy(_exeName, start, len);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   665
          _exeName[len] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   666
        }
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
    fclose(fp);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   670
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   671
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   672
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   673
// get command line from /proc/<pid>/cmdline
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   674
char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   675
  FILE* fp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   676
  char  buffer[PATH_MAX];
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   677
  char* cmdline = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   678
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   679
  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
   680
  buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   681
  if ((fp = fopen(buffer, "r")) != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   682
    size_t size = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   683
    char   dummy;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   684
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   685
    // 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
   686
    while (fread(&dummy, 1, 1, fp) == 1) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   687
      size++;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   688
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   689
    if (size > 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   690
      cmdline = NEW_C_HEAP_ARRAY(char, size + 1, mtInternal);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   691
      if (cmdline != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   692
        cmdline[0] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   693
        if (fseek(fp, 0, SEEK_SET) == 0) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   694
          if (fread(cmdline, 1, size, fp) == size) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   695
            // the file has the arguments separated by '\0',
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   696
            // so we translate '\0' to ' '
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   697
            for (size_t i = 0; i < size; i++) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   698
              if (cmdline[i] == '\0') {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   699
                cmdline[i] = ' ';
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
            cmdline[size] = '\0';
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
        }
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
    fclose(fp);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   708
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   709
  return cmdline;
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
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   712
// 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
   713
char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   714
  char buffer[PATH_MAX];
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
  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
   717
  buffer[PATH_MAX - 1] = '\0';
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   718
  return realpath(buffer, _exePath);
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
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   721
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
   722
  if (str != NULL) {
53882
ca682d9d8db5 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot
mikael
parents: 51106
diff changeset
   723
    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
   724
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   725
  return NULL;
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
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
   729
  if (!is_valid()) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   730
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   731
  }
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
  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
   734
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   735
  get_exe_name();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   736
  process_info->set_name(allocate_string(_exeName));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   737
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   738
  if (get_exe_path() != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   739
     process_info->set_path(allocate_string(_exePath));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   740
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   741
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   742
  char* cmdline = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   743
  cmdline = get_cmdline();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   744
  if (cmdline != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   745
    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
   746
    FREE_C_HEAP_ARRAY(char, cmdline);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   747
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   748
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   749
  return OS_OK;
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
int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   753
  if (!is_valid()) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   754
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   755
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   756
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   757
  do {
51106
f605c91e5219 8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents: 50879
diff changeset
   758
    _entry = os::readdir(_dir);
50160
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   759
    if (_entry == NULL) {
51106
f605c91e5219 8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents: 50879
diff changeset
   760
      // 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
   761
      _valid = false;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   762
      return OS_ERR;
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
  } while(!is_valid_entry(_entry));
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   765
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   766
  _valid = true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   767
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   768
}
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
SystemProcessInterface::SystemProcesses::ProcessIterator::ProcessIterator() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   771
  _dir = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   772
  _entry = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   773
  _valid = 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
bool SystemProcessInterface::SystemProcesses::ProcessIterator::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   777
  // Not yet implemented.
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   778
  return false;
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
SystemProcessInterface::SystemProcesses::ProcessIterator::~ProcessIterator() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   782
  if (_dir != NULL) {
51106
f605c91e5219 8202353: os::readdir should use readdir instead of readdir_r
kbarrett
parents: 50879
diff changeset
   783
    os::closedir(_dir);
50160
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
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   787
SystemProcessInterface::SystemProcesses::SystemProcesses() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   788
  _iterator = NULL;
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
bool SystemProcessInterface::SystemProcesses::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   792
  _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   793
  return NULL == _iterator ? false : _iterator->initialize();
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
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   797
  if (_iterator != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   798
    delete _iterator;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   799
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   800
}
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
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
   803
  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
   804
  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
   805
  assert(_iterator != NULL, "iterator is NULL!");
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   806
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   807
  // initialize pointers
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   808
  *no_of_sys_processes = 0;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   809
  *system_processes = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   810
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   811
  while (_iterator->is_valid()) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   812
    SystemProcess* tmp = new SystemProcess();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   813
    _iterator->current(tmp);
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
    //if already existing head
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   816
    if (*system_processes != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   817
      //move "first to second"
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   818
      tmp->set_next(*system_processes);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   819
    }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   820
    // new head
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   821
    *system_processes = tmp;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   822
    // increment
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   823
    (*no_of_sys_processes)++;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   824
    // step forward
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   825
    _iterator->next_process();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   826
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   827
  return OS_OK;
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
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   830
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
   831
  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
   832
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   833
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   834
SystemProcessInterface::SystemProcessInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   835
  _impl = NULL;
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
bool SystemProcessInterface::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   839
  _impl = new SystemProcessInterface::SystemProcesses();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   840
  return NULL == _impl ? false : _impl->initialize();
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
SystemProcessInterface::~SystemProcessInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   844
  if (_impl != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   845
    delete _impl;
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
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   849
CPUInformationInterface::CPUInformationInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   850
  _cpu_info = NULL;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   851
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   852
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   853
bool CPUInformationInterface::initialize() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   854
  _cpu_info = new CPUInformation();
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   855
  if (NULL == _cpu_info) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   856
    return false;
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
  _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
   859
  _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
   860
  _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
   861
  _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
   862
  _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
   863
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   864
  return true;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   865
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   866
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   867
CPUInformationInterface::~CPUInformationInterface() {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   868
  if (_cpu_info != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   869
    if (_cpu_info->cpu_name() != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   870
      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
   871
      FREE_C_HEAP_ARRAY(char, cpu_name);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   872
      _cpu_info->set_cpu_name(NULL);
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
    if (_cpu_info->cpu_description() != NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   875
       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
   876
       FREE_C_HEAP_ARRAY(char, cpu_desc);
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   877
      _cpu_info->set_cpu_description(NULL);
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
    delete _cpu_info;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   880
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   881
}
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   882
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   883
int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   884
  if (_cpu_info == NULL) {
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   885
    return OS_ERR;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   886
  }
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   887
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   888
  cpu_info = *_cpu_info; // shallow copy assignment
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   889
  return OS_OK;
dc18db671651 8203288: PPC64 and s390 fail to build after JDK-8199712 (Flight Recorder)
mdoerr
parents:
diff changeset
   890
}
50879
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   891
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   892
class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtInternal> {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   893
  friend class NetworkPerformanceInterface;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   894
 private:
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   895
  NetworkPerformance();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   896
  NetworkPerformance(const NetworkPerformance& rhs); // no impl
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   897
  NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   898
  bool initialize();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   899
  ~NetworkPerformance();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   900
  int network_utilization(NetworkInterface** network_interfaces) const;
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
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   903
NetworkPerformanceInterface::NetworkPerformance::NetworkPerformance() {
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
}
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
bool NetworkPerformanceInterface::NetworkPerformance::initialize() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   908
  return true;
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
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   911
NetworkPerformanceInterface::NetworkPerformance::~NetworkPerformance() {
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
int NetworkPerformanceInterface::NetworkPerformance::network_utilization(NetworkInterface** network_interfaces) const
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   915
{
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   916
  return FUNCTIONALITY_NOT_IMPLEMENTED;
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
NetworkPerformanceInterface::NetworkPerformanceInterface() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   920
  _impl = NULL;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   921
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   922
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   923
NetworkPerformanceInterface::~NetworkPerformanceInterface() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   924
  if (_impl != NULL) {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   925
    delete _impl;
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   926
  }
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   927
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   928
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   929
bool NetworkPerformanceInterface::initialize() {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   930
  _impl = new NetworkPerformanceInterface::NetworkPerformance();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   931
  return _impl != NULL && _impl->initialize();
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   932
}
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   933
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   934
int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   935
  return _impl->network_utilization(network_interfaces);
d90c3cbf13df 8003209: JFR events for network utilization
rwestberg
parents: 50160
diff changeset
   936
}