Skip to content

Commit

Permalink
8329605: hs errfile generic events - move memory protections and nmet…
Browse files Browse the repository at this point in the history
…hod flushes to separate sections

Reviewed-by: lucy, stefank, stuefe
  • Loading branch information
MBaesken committed Apr 12, 2024
1 parent f706949 commit 397d948
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) {
//
// See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm

Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
bool rc = ::mprotect(addr, size, prot) == 0 ? true : false;

if (!rc) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
#if defined(__OpenBSD__)
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
if (::mprotect(addr, size, prot) == 0) {
return true;
} else {
Expand Down Expand Up @@ -1711,7 +1711,7 @@ bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, siz
bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) {
#if defined(__OpenBSD__)
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
if (::mprotect(addr, size, PROT_NONE) == 0) {
return true;
} else {
Expand Down Expand Up @@ -1829,7 +1829,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) {
assert(addr == bottom, "sanity check");

size = align_up(pointer_delta(addr, bottom, 1) + size, os::vm_page_size());
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
return ::mprotect(bottom, size, prot) == 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3786,7 +3786,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (addr != g_assert_poison)
#endif
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
return ::mprotect(bottom, size, prot) == 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ void nmethod::purge(bool free_code_cache_data, bool unregister_nmethod) {
MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag);

// completely deallocate this method
Events::log(Thread::current(), "flushing nmethod " INTPTR_FORMAT, p2i(this));
Events::log_nmethod_flush(Thread::current(), "flushing %s nmethod " INTPTR_FORMAT, is_osr_method() ? "osr" : "", p2i(this));
log_debug(codecache)("*flushing %s nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT
"/Free CodeCache:" SIZE_FORMAT "Kb",
is_osr_method() ? "osr" : "",_compile_id, p2i(this), CodeCache::blob_count(),
Expand Down
6 changes: 5 additions & 1 deletion src/hotspot/share/utilities/events.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,6 +37,8 @@

EventLog* Events::_logs = nullptr;
StringEventLog* Events::_messages = nullptr;
StringEventLog* Events::_memprotect_messages = nullptr;
StringEventLog* Events::_nmethod_flush_messages = nullptr;
StringEventLog* Events::_vm_operations = nullptr;
StringEventLog* Events::_zgc_phase_switch = nullptr;
ExceptionsEventLog* Events::_exceptions = nullptr;
Expand Down Expand Up @@ -97,6 +99,8 @@ void Events::print() {
void Events::init() {
if (LogEvents) {
_messages = new StringEventLog("Events", "events");
_nmethod_flush_messages = new StringEventLog("Nmethod flushes", "nmethodflushes");
_memprotect_messages = new StringEventLog("Memory protections", "memprotects");
_vm_operations = new StringEventLog("VM Operations", "vmops");
if (UseZGC) {
_zgc_phase_switch = new StringEventLog("ZGC Phase Switch", "zgcps");
Expand Down
30 changes: 29 additions & 1 deletion src/hotspot/share/utilities/events.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -220,6 +220,12 @@ class Events : AllStatic {
// A log for generic messages that aren't well categorized.
static StringEventLog* _messages;

// A log for memory protection related messages
static StringEventLog* _memprotect_messages;

// A log for nmethod flush operations
static StringEventLog* _nmethod_flush_messages;

// A log for VM Operations
static StringEventLog* _vm_operations;

Expand Down Expand Up @@ -259,6 +265,10 @@ class Events : AllStatic {
// Logs a generic message with timestamp and format as printf.
static void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);

static void log_memprotect(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);

static void log_nmethod_flush(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);

static void log_vm_operation(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);

static void log_zgc_phase_switch(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
Expand Down Expand Up @@ -290,6 +300,24 @@ inline void Events::log(Thread* thread, const char* format, ...) {
}
}

inline void Events::log_memprotect(Thread* thread, const char* format, ...) {
if (LogEvents && _memprotect_messages != nullptr) {
va_list ap;
va_start(ap, format);
_memprotect_messages->logv(thread, format, ap);
va_end(ap);
}
}

inline void Events::log_nmethod_flush(Thread* thread, const char* format, ...) {
if (LogEvents && _nmethod_flush_messages != nullptr) {
va_list ap;
va_start(ap, format);
_nmethod_flush_messages->logv(thread, format, ap);
va_end(ap);
}
}

inline void Events::log_vm_operation(Thread* thread, const char* format, ...) {
if (LogEvents && _vm_operations != nullptr) {
va_list ap;
Expand Down

9 comments on commit 397d948

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 397d948 May 6, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 397d9483 to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/hotspot/os/bsd/os_bsd.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-397d9483

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 397d94831033e91c7a849774bf4e80d8f1c8ec66

# Backport the commit
$ git cherry-pick --no-commit 397d94831033e91c7a849774bf4e80d8f1c8ec66
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 397d9483 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 12 Apr 2024 and was reviewed by Lutz Schmidt, Stefan Karlsson and Thomas Stuefe.

Thanks!

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on 397d948 May 7, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 397d9483 to openjdk/jdk22u due to conflicts in the following files:

  • src/hotspot/os/bsd/os_bsd.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk22u. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk22u.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-397d9483

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 397d94831033e91c7a849774bf4e80d8f1c8ec66

# Backport the commit
$ git cherry-pick --no-commit 397d94831033e91c7a849774bf4e80d8f1c8ec66
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk22u with the title Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 397d9483 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 12 Apr 2024 and was reviewed by Lutz Schmidt, Stefan Karlsson and Thomas Stuefe.

Thanks!

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on 397d948 May 15, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 397d9483 to openjdk/jdk22u due to conflicts in the following files:

  • src/hotspot/os/bsd/os_bsd.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk22u. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk22u.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-397d9483

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 397d94831033e91c7a849774bf4e80d8f1c8ec66

# Backport the commit
$ git cherry-pick --no-commit 397d94831033e91c7a849774bf4e80d8f1c8ec66
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk22u with the title Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 397d9483 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 12 Apr 2024 and was reviewed by Lutz Schmidt, Stefan Karlsson and Thomas Stuefe.

Thanks!

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 397d948 Jun 25, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 397d9483 to openjdk/jdk17u-dev due to conflicts in the following files:

  • src/hotspot/os/aix/os_aix.cpp
  • src/hotspot/os/bsd/os_bsd.cpp
  • src/hotspot/os/linux/os_linux.cpp
  • src/hotspot/share/code/nmethod.cpp
  • src/hotspot/share/utilities/events.cpp
  • src/hotspot/share/utilities/events.hpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-397d9483-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 397d94831033e91c7a849774bf4e80d8f1c8ec66

# Backport the commit
$ git cherry-pick --no-commit 397d94831033e91c7a849774bf4e80d8f1c8ec66
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport 397d94831033e91c7a849774bf4e80d8f1c8ec66.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 397d9483 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 12 Apr 2024 and was reviewed by Lutz Schmidt, Stefan Karlsson and Thomas Stuefe.

Thanks!

Please sign in to comment.