Skip to content

Commit 712161c

Browse files
authored
Merge branch 'openjdk:master' into goetz_backport_8327114
2 parents 3c4fee4 + 53635df commit 712161c

File tree

10 files changed

+202
-2992
lines changed

10 files changed

+202
-2992
lines changed

src/hotspot/cpu/ppc/ppc.ad

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13073,27 +13073,27 @@ instruct countTrailingZerosL_cnttzd(iRegIdst dst, iRegLsrc src) %{
1307313073
%}
1307413074

1307513075
// Expand nodes for byte_reverse_int.
13076-
instruct insrwi_a(iRegIdst dst, iRegIsrc src, immI16 pos, immI16 shift) %{
13077-
effect(DEF dst, USE src, USE pos, USE shift);
13076+
instruct insrwi_a(iRegIdst dst, iRegIsrc src, immI16 n, immI16 b) %{
13077+
effect(DEF dst, USE src, USE n, USE b);
1307813078
predicate(false);
1307913079

13080-
format %{ "INSRWI $dst, $src, $pos, $shift" %}
13080+
format %{ "INSRWI $dst, $src, $n, $b" %}
1308113081
size(4);
1308213082
ins_encode %{
13083-
__ insrwi($dst$$Register, $src$$Register, $shift$$constant, $pos$$constant);
13083+
__ insrwi($dst$$Register, $src$$Register, $n$$constant, $b$$constant);
1308413084
%}
1308513085
ins_pipe(pipe_class_default);
1308613086
%}
1308713087

1308813088
// As insrwi_a, but with USE_DEF.
13089-
instruct insrwi(iRegIdst dst, iRegIsrc src, immI16 pos, immI16 shift) %{
13090-
effect(USE_DEF dst, USE src, USE pos, USE shift);
13089+
instruct insrwi(iRegIdst dst, iRegIsrc src, immI16 n, immI16 b) %{
13090+
effect(USE_DEF dst, USE src, USE n, USE b);
1309113091
predicate(false);
1309213092

13093-
format %{ "INSRWI $dst, $src, $pos, $shift" %}
13093+
format %{ "INSRWI $dst, $src, $n, $b" %}
1309413094
size(4);
1309513095
ins_encode %{
13096-
__ insrwi($dst$$Register, $src$$Register, $shift$$constant, $pos$$constant);
13096+
__ insrwi($dst$$Register, $src$$Register, $n$$constant, $b$$constant);
1309713097
%}
1309813098
ins_pipe(pipe_class_default);
1309913099
%}
@@ -13115,12 +13115,12 @@ instruct bytes_reverse_int_Ex(iRegIdst dst, iRegIsrc src) %{
1311513115
iRegLdst tmpI3;
1311613116

1311713117
urShiftI_reg_imm(tmpI1, src, imm24);
13118-
insrwi_a(dst, tmpI1, imm24, imm8);
13118+
insrwi_a(dst, tmpI1, imm8, imm24);
1311913119
urShiftI_reg_imm(tmpI2, src, imm16);
13120-
insrwi(dst, tmpI2, imm8, imm16);
13120+
insrwi(dst, tmpI2, imm16, imm8);
1312113121
urShiftI_reg_imm(tmpI3, src, imm8);
1312213122
insrwi(dst, tmpI3, imm8, imm8);
13123-
insrwi(dst, src, imm0, imm8);
13123+
insrwi(dst, src, imm8, imm0);
1312413124
%}
1312513125
%}
1312613126

@@ -13238,7 +13238,7 @@ instruct bytes_reverse_ushort_Ex(iRegIdst dst, iRegIsrc src) %{
1323813238
immI16 imm8 %{ (int) 8 %}
1323913239

1324013240
urShiftI_reg_imm(dst, src, imm8);
13241-
insrwi(dst, src, imm16, imm8);
13241+
insrwi(dst, src, imm8, imm16);
1324213242
%}
1324313243
%}
1324413244

@@ -13267,7 +13267,7 @@ instruct bytes_reverse_short_Ex(iRegIdst dst, iRegIsrc src) %{
1326713267
iRegLdst tmpI1;
1326813268

1326913269
urShiftI_reg_imm(tmpI1, src, imm8);
13270-
insrwi(tmpI1, src, imm16, imm8);
13270+
insrwi(tmpI1, src, imm8, imm16);
1327113271
extsh(dst, tmpI1);
1327213272
%}
1327313273
%}

src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2015, 2020 SAP SE. All rights reserved.
2+
* Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2015, 2025 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -28,20 +28,111 @@
2828
/* Implement and update https://bugs.openjdk.org/browse/JDK-8030957 */
2929

3030
#include <jni.h>
31+
#include <libperfstat.h>
32+
#include <pthread.h>
33+
#include <stdlib.h>
34+
#include <time.h>
3135
#include "com_sun_management_internal_OperatingSystemImpl.h"
3236

37+
static struct perfMetrics{
38+
unsigned long long timebase;
39+
perfstat_process_t stats;
40+
perfstat_cpu_total_t cpu_total;
41+
} counters;
42+
43+
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
44+
45+
int perfInit() {
46+
static int initialized = 0;
47+
if (!initialized) {
48+
49+
perfstat_id_t id;
50+
counters.stats = (perfstat_process_t){0};
51+
counters.timebase = 0;
52+
int rc = perfstat_cpu_total(NULL, &counters.cpu_total, sizeof(perfstat_cpu_total_t), 1);
53+
if (rc < 0) {
54+
return -1;
55+
}
56+
rc = perfstat_process(&id, &counters.stats, sizeof(perfstat_process_t), 1);
57+
if (rc < 0) {
58+
return -1;
59+
}
60+
counters.timebase = counters.stats.last_timebase;
61+
initialized = 1;
62+
}
63+
return initialized ? 0 : -1;
64+
}
65+
3366
JNIEXPORT jdouble JNICALL
3467
Java_com_sun_management_internal_OperatingSystemImpl_getCpuLoad0
3568
(JNIEnv *env, jobject dummy)
3669
{
37-
return -1.0;
70+
double load = -1.0;
71+
pthread_mutex_lock(&lock);
72+
if (perfInit() == 0) {
73+
int ret;
74+
perfstat_cpu_total_t cpu_total;
75+
ret = perfstat_cpu_total(NULL, &cpu_total, sizeof(perfstat_cpu_total_t), 1);
76+
if (ret < 0) {
77+
return -1.0;
78+
}
79+
long long user_diff = cpu_total.user - counters.cpu_total.user;
80+
long long sys_diff = cpu_total.sys - counters.cpu_total.sys;
81+
long long idle_diff = cpu_total.idle - counters.cpu_total.idle;
82+
long long wait_diff = cpu_total.wait - counters.cpu_total.wait;
83+
long long total = user_diff + sys_diff + idle_diff + wait_diff;
84+
if (total < (user_diff + sys_diff)) {
85+
total = user_diff + sys_diff;
86+
}
87+
if (total == 0) {
88+
load = 0.0;
89+
} else {
90+
load = (double)(user_diff + sys_diff) / total;
91+
load = MAX(load, 0.0);
92+
load = MIN(load, 1.0);
93+
}
94+
counters.cpu_total = cpu_total;
95+
}
96+
pthread_mutex_unlock(&lock);
97+
return load;
3898
}
3999

40100
JNIEXPORT jdouble JNICALL
41101
Java_com_sun_management_internal_OperatingSystemImpl_getProcessCpuLoad0
42102
(JNIEnv *env, jobject dummy)
43103
{
44-
return -1.0;
104+
perfstat_process_t curr_stats;
105+
perfstat_id_t id;
106+
unsigned long long curr_timebase, timebase_diff;
107+
double user_diff, sys_diff, delta_time;
108+
double cpu_load = -1.0;
109+
pthread_mutex_lock(&lock);
110+
if (perfInit() == 0) {
111+
int ret;
112+
ret = perfstat_process(&id, &curr_stats, sizeof(perfstat_process_t), 1);
113+
if (ret < 0) {
114+
return -1.0;
115+
}
116+
curr_timebase = curr_stats.last_timebase;
117+
timebase_diff = curr_timebase - counters.timebase;
118+
if ((long long)timebase_diff < 0 || XINTFRAC == 0) {
119+
return -1.0;
120+
}
121+
delta_time = HTIC2NANOSEC(timebase_diff) / 1000000000.0;
122+
user_diff = (double)(curr_stats.ucpu_time - counters.stats.ucpu_time);
123+
sys_diff = (double)(curr_stats.scpu_time - counters.stats.scpu_time);
124+
counters.stats = curr_stats;
125+
counters.timebase = curr_timebase;
126+
if (delta_time == 0) {
127+
cpu_load = 0.0;
128+
} else {
129+
cpu_load = (user_diff + sys_diff) / delta_time;
130+
cpu_load = MAX(cpu_load, 0.0);
131+
cpu_load = MIN(cpu_load, 1.0);
132+
}
133+
}
134+
pthread_mutex_unlock(&lock);
135+
return (jdouble)cpu_load;
45136
}
46137

47138
JNIEXPORT jdouble JNICALL

test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public static void testWith(int delay, boolean shouldPass) throws Exception {
6868
"-XX:+AbortVMOnVMOperationTimeout",
6969
"-XX:AbortVMOnVMOperationTimeoutDelay=" + delay,
7070
"-Xmx256m",
71+
"-XX:NewSize=64m",
7172
"-XX:+UseSerialGC",
7273
"-XX:-CreateCoredumpOnCrash",
7374
"-Xlog:gc*=info",

test/jdk/ProblemList.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,6 @@ java/io/pathNames/GeneralWin32.java 8180264 windows-
546546

547547
# jdk_management
548548

549-
com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all
550-
com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all
551549

552550
java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all
553551
java/lang/management/MemoryMXBean/PendingAllGC.sh 8158837 generic-all
@@ -562,7 +560,6 @@ sun/management/jdp/JdpOffTest.java 8308807 aix-ppc6
562560

563561
# jdk_jmx
564562

565-
javax/management/MBeanServer/OldMBeanServerTest.java 8030957 aix-all
566563

567564
javax/management/remote/mandatory/connection/RMIConnector_NPETest.java 8267887 generic-all
568565

test/jdk/java/awt/Multiscreen/MultiScreenInsetsTest/MultiScreenInsetsTest.java

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)