Skip to content

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Oct 2, 2025

Currently issues with perfMemory like problems with the secure tmp subdirectory creation are not very transparent in release JVMs.

There exists some warnings traces but they are behind develop flags like Verbose so only available in debug JVMs.
We could (in case of issues) store some information and write it later into hsinfo/hserr files ; or make the existing warnings available too in release JVMs.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8368781: PerfMemory - make issues more transparent (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27602/head:pull/27602
$ git checkout pull/27602

Update a local copy of the PR:
$ git checkout pull/27602
$ git pull https://git.openjdk.org/jdk.git pull/27602/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27602

View PR using the GUI difftool:
$ git pr show -t 27602

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27602.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 2, 2025

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 2, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title JDK-8368781: PerfMemory - make issues more transparent 8368781: PerfMemory - make issues more transparent Oct 2, 2025
@openjdk
Copy link

openjdk bot commented Oct 2, 2025

@MBaesken The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 2, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 2, 2025

Webrevs

@RealCLanger
Copy link
Contributor

RealCLanger commented Oct 10, 2025

I think adding a new diagnostic flag named EnhanceErrorWarningLogging in addition to PrintMiscellaneousand Verbose unnecessarily convolutes things and the name of the new option is not really obvious. I would rather add a flag like TracePerfMemory and replace usage of (PrintMiscellaneous && Verbose) with the new flag or change PrintMiscellaneous and Verbose to diagnostic flags such that they are available in product VMs.

@MBaesken
Copy link
Member Author

or change PrintMiscellaneous and Verbose to diagnostic flags such that they are available in product VMs.

Might be an option ; PrintMiscellaneous is used besides perfMemory also at some more places , e.g. C2 JIT.
See below

cpu/x86/vm_version_x86.cpp:1392:    if (supports_avx() && PrintMiscellaneous && Verbose && TraceNewVectors) {
os/posix/perfMemory_posix.cpp:74:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:300:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:374:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:414:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:421:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:450:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:683:  if (PrintMiscellaneous && Verbose && result == OS_ERR) {
os/posix/perfMemory_posix.cpp:825:        if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:835:      if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:875:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:927:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:936:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:1060:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:1138:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:1215:    if (PrintMiscellaneous && Verbose) {
os/posix/perfMemory_posix.cpp:1251:      if (PrintMiscellaneous && Verbose) {
os/windows/os_windows.cpp:3350:    if (Verbose && PrintMiscellaneous) reserveTimer.start();
os/windows/os_windows.cpp:3357:    if (Verbose && PrintMiscellaneous) {
os/windows/perfMemory_windows.cpp:65:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:99:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:108:        if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:120:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:223:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:237:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:256:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:495:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:518:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:529:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:548:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:556:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:579:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:589:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:598:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:707:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:720:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:786:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:798:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:811:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:824:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:869:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:889:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:917:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:930:        if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:957:          if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:972:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:988:        if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:996:        if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1008:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1028:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1060:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1117:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1135:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1239:        if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1252:        if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1259:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1328:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1356:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1372:      if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1405:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1488:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1554:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1562:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1640:    if (PrintMiscellaneous && Verbose) {
os/windows/perfMemory_windows.cpp:1711:      if (PrintMiscellaneous && Verbose) {
share/compiler/disassembler.cpp:861:                    : ((WizardMode || PrintMiscellaneous)
share/opto/graphKit.cpp:856:        if (PrintMiscellaneous && (Verbose || WizardMode)) {
share/opto/gcm.cpp:739:       (PrintMiscellaneous && (WizardMode || Verbose)))) {
share/opto/library_call.cpp:787:    if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
share/opto/library_call.cpp:825:    if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
share/opto/matcher.cpp:1001:    if (PrintOpto || (PrintMiscellaneous && (WizardMode || Verbose))) {
share/runtime/globals.hpp:521:  develop(bool, PrintMiscellaneous, false,                                  \
share/runtime/perfData.cpp:227:  if (PrintMiscellaneous && Verbose) {
share/runtime/perfMemory.cpp:117:    if (PrintMiscellaneous && Verbose) {
share/runtime/perfMemory.cpp:177:    if (PrintMiscellaneous && Verbose) {
share/runtime/perfMemory.cpp:253:      if (PrintMiscellaneous && Verbose) {

Would it be okay to offer this in product JVMs ? (Verbose is even harder to say, because it is used more)

@dholmes-ora
Copy link
Member

PerfMemory should be converted to Unified Logging (UL). We don't want any new flags for ad-hoc logging.

@MBaesken
Copy link
Member Author

PerfMemory should be converted to Unified Logging (UL). We don't want any new flags for ad-hoc logging.

Guess this makes sense, do you have some special UL category in mind? Maybe 'os' ? Or a new one ?

@dholmes-ora
Copy link
Member

dholmes-ora commented Oct 14, 2025

We already have some UL in PerfMemory:

8168122: Update logging in perfMemory to Unified Logging
Summary: -XX:+PerfTraceMemOps replaced with -Xlog:perf+memops=debug, -XX:+PerfTraceDataCreation replaced with -Xlog:perf+datacreation=debug

but for some reason that effort completely ignored the PrintMiscellaneous/Verbose "warnings". To keep things simple I suggest the following pattern:

diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp
index ed83487265c..968f3cea249 100644
--- a/src/hotspot/os/posix/perfMemory_posix.cpp
+++ b/src/hotspot/os/posix/perfMemory_posix.cpp
@@ -447,10 +447,11 @@ static char* get_user_name(uid_t uid) {
   int result = getpwuid_r(uid, &pwent, pwbuf, (size_t)bufsize, &p);
 
   if (result != 0 || p == nullptr || p->pw_name == nullptr || *(p->pw_name) == '\0') {
-    if (PrintMiscellaneous && Verbose) {
+    if (log_is_enabled(Debug, perf)) {
+      LogStreamHandle(Debug, perf) log;
       if (result != 0) {
-        warning("Could not retrieve passwd entry: %s\n",
-                os::strerror(result));
+        log.print_cr("Could not retrieve passwd entry: %s",
+                     os::strerror(result));
       }
       else if (p == nullptr) {
         // this check is added to protect against an observed problem
@@ -463,13 +464,13 @@ static char* get_user_name(uid_t uid) {
         // message may result in an erroneous message.
         // Bug Id 89052 was opened with RedHat.
         //
-        warning("Could not retrieve passwd entry: %s\n",
-                os::strerror(errno));
+        log.print_cr("Could not retrieve passwd entry: %s",
+                      os::strerror(errno));
       }
       else {
-        warning("Could not determine user name: %s\n",
-                 p->pw_name == nullptr ? "pw_name = null" :
-                                      "pw_name zero length");
+        log.print_cr("Could not determine user name: %s",
+                      p->pw_name == nullptr ? "pw_name = null" :
+                                              "pw_name zero length");
       }
     }
     FREE_C_HEAP_ARRAY(char, pwbuf);

Of course you proposed changes as a potential consumer of this information, so how would you like to procure it?

@MBaesken
Copy link
Member Author

Of course you proposed changes as a potential consumer of this information, so how would you like to procure it?

I think my support colleague would set the needed UL flags in case her wants to find out more about perfmem issues.

@MBaesken
Copy link
Member Author

@dholmes-ora while looking into the Windows perfmem code, I noticed we are using SetSecurityDescriptorControl

// if running on windows 2000 or later, set the automatic inheritance

but we use still handling for ancient Windows versions (we use dynamic handling of the function at runtime), should we remove this ?
Looking at the description
https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-setsecuritydescriptorcontrol
it is available at least since Win2003/XP so the function can be called directly (would do this in a separate JBS issue).
What do you think ?

@MBaesken
Copy link
Member Author

Do we need to include more? It seems not to work in e.g. the zero of minimal builds ?

@dholmes-ora
Copy link
Member

would do this in a separate JBS issue

Yes please file a separate JBS issue for that

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to include:

#include "logging/logStream.hpp"

to get LogStream. But note that simple cases don't need to use LogStream. I gave that example for the more complex cases.

Thanks

Comment on lines +75 to +76
LogStreamHandle(Debug, perf) log;
log.print_cr("Could not commit PerfData memory\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simple usages like this you can simplify.

Suggested change
LogStreamHandle(Debug, perf) log;
log.print_cr("Could not commit PerfData memory\n");
log_debug(perf)("Could not commit PerfData memory");

also note to get rid of the explicit \n in the strings.

@MBaesken
Copy link
Member Author

would do this in a separate JBS issue

Yes please file a separate JBS issue for that

I created
https://bugs.openjdk.org/browse/JDK-8370065
8370065: Windows perfmemory coding - use SetSecurityDescriptorControl directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants