hotspot/src/os/aix/vm/libperfstat_aix.cpp
author attila
Mon, 08 Feb 2016 12:59:08 +0100
changeset 35725 c7a2c18529b1
parent 34647 fafb32d71489
child 35594 cc13089c6327
permissions -rw-r--r--
8149186: Don't use indy for optimistic arithmetic Reviewed-by: mhaupt, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     1
/*
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
     2
 * Copyright 2012, 2015 SAP AG. All rights reserved.
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     4
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     8
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    13
 * accompanied this code).
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    14
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    18
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    21
 * questions.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    22
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    23
 */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    24
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    25
#include "libperfstat_aix.hpp"
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    26
#include "misc_aix.hpp"
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    27
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    28
#include <dlfcn.h>
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    29
#include <sys/systemcfg.h>
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    30
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    31
// Handle to the libperfstat.
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    32
static void* g_libhandle = NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    33
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    34
typedef int (*fun_perfstat_cpu_total_t) (perfstat_id_t *name, PERFSTAT_CPU_TOTAL_T_LATEST* userbuff,
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    35
                                         int sizeof_userbuff, int desired_number);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    36
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    37
typedef int (*fun_perfstat_memory_total_t) (perfstat_id_t *name, perfstat_memory_total_t* userbuff,
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    38
                                            int sizeof_userbuff, int desired_number);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    39
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    40
typedef int (*fun_perfstat_partition_total_t) (perfstat_id_t *name,
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    41
    PERFSTAT_PARTITON_TOTAL_T_LATEST* userbuff, int sizeof_userbuff,
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    42
    int desired_number);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    43
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    44
typedef int (*fun_perfstat_wpar_total_t) (perfstat_id_wpar_t *name,
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    45
    PERFSTAT_WPAR_TOTAL_T_LATEST* userbuff, int sizeof_userbuff,
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    46
    int desired_number);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    47
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    48
typedef void (*fun_perfstat_reset_t) ();
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    49
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    50
typedef cid_t (*fun_wpar_getcid_t) ();
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    51
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    52
static fun_perfstat_cpu_total_t     g_fun_perfstat_cpu_total = NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    53
static fun_perfstat_memory_total_t  g_fun_perfstat_memory_total = NULL;
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    54
static fun_perfstat_partition_total_t g_fun_perfstat_partition_total = NULL;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    55
static fun_perfstat_wpar_total_t    g_fun_perfstat_wpar_total = NULL;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    56
static fun_perfstat_reset_t         g_fun_perfstat_reset = NULL;
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    57
static fun_wpar_getcid_t            g_fun_wpar_getcid = NULL;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    58
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    59
bool libperfstat::init() {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    60
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    61
  // Dynamically load the libperfstat porting library.
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    62
  g_libhandle = dlopen("/usr/lib/libperfstat.a(shr_64.o)", RTLD_MEMBER | RTLD_NOW);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    63
  if (!g_libhandle) {
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    64
    trcVerbose("Cannot load libperfstat.a (dlerror: %s)", dlerror());
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    65
    return false;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    66
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    67
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    68
  // Resolve function pointers
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    69
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    70
#define RESOLVE_FUN_NO_ERROR(name) \
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    71
  g_fun_##name = (fun_##name##_t) dlsym(g_libhandle, #name);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    72
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    73
#define RESOLVE_FUN(name) \
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    74
  RESOLVE_FUN_NO_ERROR(name) \
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    75
  if (!g_fun_##name) { \
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    76
    trcVerbose("Cannot resolve " #name "() from libperfstat.a\n" \
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    77
                      "   (dlerror: %s)", dlerror()); \
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    78
    return false; \
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    79
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    80
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    81
  // These functions may or may not be there depending on the OS release.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    82
  RESOLVE_FUN_NO_ERROR(perfstat_partition_total);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    83
  RESOLVE_FUN_NO_ERROR(perfstat_wpar_total);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    84
  RESOLVE_FUN_NO_ERROR(wpar_getcid);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    85
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    86
  // These functions are required for every release.
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    87
  RESOLVE_FUN(perfstat_cpu_total);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    88
  RESOLVE_FUN(perfstat_memory_total);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    89
  RESOLVE_FUN(perfstat_reset);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    90
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
    91
  trcVerbose("libperfstat loaded.");
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    92
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    93
  return true;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    94
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    95
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    96
void libperfstat::cleanup() {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    97
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    98
  if (g_libhandle) {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    99
    dlclose(g_libhandle);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   100
    g_libhandle = NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   101
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   102
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   103
  g_fun_perfstat_cpu_total = NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   104
  g_fun_perfstat_memory_total = NULL;
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   105
  g_fun_perfstat_partition_total = NULL;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   106
  g_fun_perfstat_wpar_total = NULL;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   107
  g_fun_perfstat_reset = NULL;
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   108
  g_fun_wpar_getcid = NULL;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   109
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   110
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   111
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   112
int libperfstat::perfstat_memory_total(perfstat_id_t *name,
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   113
                                       perfstat_memory_total_t* userbuff,
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   114
                                       int sizeof_userbuff, int desired_number) {
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   115
  if (g_fun_perfstat_memory_total == NULL) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   116
    return -1;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   117
  }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   118
  return g_fun_perfstat_memory_total(name, userbuff, sizeof_userbuff, desired_number);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   119
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   120
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   121
int libperfstat::perfstat_cpu_total(perfstat_id_t *name, PERFSTAT_CPU_TOTAL_T_LATEST* userbuff,
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   122
                                    int sizeof_userbuff, int desired_number) {
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   123
  if (g_fun_perfstat_cpu_total == NULL) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   124
    return -1;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   125
  }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   126
  return g_fun_perfstat_cpu_total(name, userbuff, sizeof_userbuff, desired_number);
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   127
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   128
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   129
int libperfstat::perfstat_partition_total(perfstat_id_t *name, PERFSTAT_PARTITON_TOTAL_T_LATEST* userbuff,
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   130
                                          int sizeof_userbuff, int desired_number) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   131
  if (g_fun_perfstat_partition_total == NULL) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   132
    return -1;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   133
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   134
  return g_fun_perfstat_partition_total(name, userbuff, sizeof_userbuff, desired_number);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   135
}
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   136
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   137
int libperfstat::perfstat_wpar_total(perfstat_id_wpar_t *name, PERFSTAT_WPAR_TOTAL_T_LATEST* userbuff,
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   138
                                     int sizeof_userbuff, int desired_number) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   139
  if (g_fun_perfstat_wpar_total == NULL) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   140
    return -1;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   141
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   142
  return g_fun_perfstat_wpar_total(name, userbuff, sizeof_userbuff, desired_number);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   143
}
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   144
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   145
void libperfstat::perfstat_reset() {
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   146
  if (g_fun_perfstat_reset != NULL) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   147
    g_fun_perfstat_reset();
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   148
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   149
}
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   150
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   151
cid_t libperfstat::wpar_getcid() {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   152
  if (g_fun_wpar_getcid == NULL) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   153
    return (cid_t) -1;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   154
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   155
  return g_fun_wpar_getcid();
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   156
}
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   157
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   158
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   159
//////////////////// convenience functions, release-independent /////////////////////////////
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   160
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   161
// Excerpts from systemcfg.h definitions newer than AIX 5.3 (our oldest build platform)
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   162
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   163
#define PV_6 0x100000          /* Power PC 6 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   164
#define PV_6_1 0x100001        /* Power PC 6 DD1.x */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   165
#define PV_7 0x200000          /* Power PC 7 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   166
#define PV_5_Compat 0x0F8000   /* Power PC 5 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   167
#define PV_6_Compat 0x108000   /* Power PC 6 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   168
#define PV_7_Compat 0x208000   /* Power PC 7 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   169
#define PV_8 0x300000          /* Power PC 8 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   170
#define PV_8_Compat 0x308000   /* Power PC 8 */
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   171
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   172
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   173
// Retrieve global cpu information.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   174
bool libperfstat::get_cpuinfo(cpuinfo_t* pci) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   175
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   176
  assert(pci, "get_cpuinfo: invalid parameter");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   177
  memset(pci, 0, sizeof(cpuinfo_t));
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   178
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   179
  PERFSTAT_CPU_TOTAL_T_LATEST psct;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   180
  memset (&psct, '\0', sizeof(psct));
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   181
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   182
  if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(PERFSTAT_CPU_TOTAL_T_LATEST), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   183
    if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_61), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   184
      if (-1 == libperfstat::perfstat_cpu_total(NULL, &psct, sizeof(perfstat_cpu_total_t_53), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   185
          trcVerbose("perfstat_cpu_total() failed (errno=%d)", errno);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   186
          return false;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   187
      }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   188
    }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   189
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   190
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   191
  // Global cpu information.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   192
  strcpy (pci->description, psct.description);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   193
  pci->processorHZ = psct.processorHZ;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   194
  pci->ncpus = psct.ncpus;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   195
  for (int i = 0; i < 3; i++) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   196
    pci->loadavg[i] = (double) psct.loadavg[i] / (1 << SBITS);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   197
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   198
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   199
  pci->user_clock_ticks = psct.user;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   200
  pci->sys_clock_ticks  = psct.sys;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   201
  pci->idle_clock_ticks = psct.idle;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   202
  pci->wait_clock_ticks = psct.wait;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   203
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   204
  // Get the processor version from _system_configuration.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   205
  switch (_system_configuration.version) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   206
  case PV_8:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   207
    strcpy(pci->version, "Power PC 8");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   208
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   209
  case PV_7:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   210
    strcpy(pci->version, "Power PC 7");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   211
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   212
  case PV_6_1:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   213
    strcpy(pci->version, "Power PC 6 DD1.x");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   214
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   215
  case PV_6:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   216
    strcpy(pci->version, "Power PC 6");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   217
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   218
  case PV_5:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   219
    strcpy(pci->version, "Power PC 5");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   220
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   221
  case PV_5_2:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   222
    strcpy(pci->version, "Power PC 5_2");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   223
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   224
  case PV_5_3:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   225
    strcpy(pci->version, "Power PC 5_3");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   226
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   227
  case PV_5_Compat:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   228
    strcpy(pci->version, "PV_5_Compat");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   229
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   230
  case PV_6_Compat:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   231
    strcpy(pci->version, "PV_6_Compat");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   232
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   233
  case PV_7_Compat:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   234
    strcpy(pci->version, "PV_7_Compat");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   235
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   236
  case PV_8_Compat:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   237
    strcpy(pci->version, "PV_8_Compat");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   238
    break;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   239
  default:
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   240
    strcpy(pci->version, "unknown");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   241
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   242
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   243
  return true;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   244
}
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   245
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   246
// Retrieve partition information.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   247
bool libperfstat::get_partitioninfo(partitioninfo_t* ppi) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   248
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   249
  assert(ppi, "get_partitioninfo: invalid parameter");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   250
  memset(ppi, 0, sizeof(partitioninfo_t));
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   251
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   252
  PERFSTAT_PARTITON_TOTAL_T_LATEST pspt;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   253
  memset(&pspt, '\0', sizeof(pspt));
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   254
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   255
  bool ame_details = true;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   256
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   257
  if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(PERFSTAT_PARTITON_TOTAL_T_LATEST), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   258
    if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_71), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   259
      ame_details = false;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   260
      if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_61), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   261
        if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_53), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   262
          if (-1 == libperfstat::perfstat_partition_total(NULL, &pspt, sizeof(perfstat_partition_total_t_53_5), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   263
            trcVerbose("perfstat_partition_total() failed (errno=%d)", errno);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   264
            return false;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   265
          }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   266
        }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   267
      }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   268
    }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   269
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   270
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   271
  // partition type info
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   272
  ppi->shared_enabled = pspt.type.b.shared_enabled;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   273
  ppi->smt_capable = pspt.type.b.smt_capable;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   274
  ppi->smt_enabled = pspt.type.b.smt_enabled;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   275
  ppi->lpar_capable = pspt.type.b.lpar_capable;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   276
  ppi->lpar_enabled = pspt.type.b.lpar_enabled;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   277
  ppi->dlpar_capable = pspt.type.b.dlpar_capable;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   278
  ppi->capped = pspt.type.b.capped;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   279
  ppi->kernel_is_64 = pspt.type.b.kernel_is_64;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   280
  ppi->pool_util_authority = pspt.type.b.pool_util_authority;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   281
  ppi->donate_capable = pspt.type.b.donate_capable;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   282
  ppi->donate_enabled = pspt.type.b.donate_enabled;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   283
  ppi->ams_capable = pspt.type.b.ams_capable;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   284
  ppi->ams_enabled = pspt.type.b.ams_enabled;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   285
  ppi->power_save = pspt.type.b.power_save;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   286
  ppi->ame_enabled = pspt.type.b.ame_enabled;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   287
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   288
  // partition total info
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   289
  ppi->online_cpus = pspt.online_cpus;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   290
  ppi->entitled_proc_capacity = pspt.entitled_proc_capacity;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   291
  ppi->var_proc_capacity_weight = pspt.var_proc_capacity_weight;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   292
  ppi->phys_cpus_pool = pspt.phys_cpus_pool;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   293
  ppi->pool_id = pspt.pool_id;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   294
  ppi->entitled_pool_capacity = pspt.entitled_pool_capacity;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   295
  strcpy(ppi->name, pspt.name);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   296
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   297
  // Added values to ppi that we need for later computation of cpu utilization
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   298
  // ( pool authorization needed for pool_idle_time ??? )
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   299
  ppi->timebase_last   = pspt.timebase_last;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   300
  ppi->pool_idle_time  = pspt.pool_idle_time;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   301
  ppi->pcpu_tics_user  = pspt.puser;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   302
  ppi->pcpu_tics_sys   = pspt.psys;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   303
  ppi->pcpu_tics_idle  = pspt.pidle;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   304
  ppi->pcpu_tics_wait  = pspt.pwait;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   305
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   306
  // Additional AME information.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   307
  if (ame_details) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   308
    ppi->true_memory = pspt.true_memory * 4096;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   309
    ppi->expanded_memory = pspt.expanded_memory * 4096;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   310
    ppi->target_memexp_factr = pspt.target_memexp_factr;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   311
    ppi->current_memexp_factr = pspt.current_memexp_factr;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   312
    ppi->cmcs_total_time = pspt.cmcs_total_time;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   313
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   314
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   315
  return true;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   316
}
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   317
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   318
// Retrieve wpar information.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   319
bool libperfstat::get_wparinfo(wparinfo_t* pwi) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   320
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   321
  assert(pwi, "get_wparinfo: invalid parameter");
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   322
  memset(pwi, 0, sizeof(wparinfo_t));
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   323
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   324
  if (libperfstat::wpar_getcid() <= 0) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   325
    return false;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   326
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   327
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   328
  PERFSTAT_WPAR_TOTAL_T_LATEST pswt;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   329
  memset (&pswt, '\0', sizeof(pswt));
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   330
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   331
  if (-1 == libperfstat::perfstat_wpar_total(NULL, &pswt, sizeof(PERFSTAT_WPAR_TOTAL_T_LATEST), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   332
    if (-1 == libperfstat::perfstat_wpar_total(NULL, &pswt, sizeof(perfstat_wpar_total_t_61), 1)) {
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   333
      trcVerbose("perfstat_wpar_total() failed (errno=%d)", errno);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   334
      return false;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   335
    }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   336
  }
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   337
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   338
  // WPAR type info.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   339
  pwi->app_wpar = pswt.type.b.app_wpar;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   340
  pwi->cpu_rset = pswt.type.b.cpu_rset;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   341
  pwi->cpu_xrset = pswt.type.b.cpu_xrset;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   342
  pwi->cpu_limits = pswt.type.b.cpu_limits;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   343
  pwi->mem_limits = pswt.type.b.mem_limits;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   344
  // WPAR total info.
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   345
  strcpy(pwi->name, pswt.name);
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   346
  pwi->wpar_id = pswt.wpar_id;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   347
  pwi->cpu_limit = pswt.cpu_limit;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   348
  pwi->mem_limit = pswt.mem_limit;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   349
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   350
  return true;
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 22831
diff changeset
   351
}