Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

Commit 4541823

Browse files
committed
8329605: hs errfile generic events - move memory protections and nmethod flushes to separate sections
Backport-of: 397d94831033e91c7a849774bf4e80d8f1c8ec66
1 parent f539469 commit 4541823

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed

src/hotspot/os/aix/os_aix.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) {
20042004
//
20052005
// See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm
20062006

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

20102010
if (!rc) {

src/hotspot/os/bsd/os_bsd.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
15721572
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
15731573
#if defined(__OpenBSD__)
15741574
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
1575-
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
1575+
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
15761576
if (::mprotect(addr, size, prot) == 0) {
15771577
return true;
15781578
}
@@ -1669,7 +1669,7 @@ bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, siz
16691669
bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) {
16701670
#if defined(__OpenBSD__)
16711671
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
1672-
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
1672+
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
16731673
return ::mprotect(addr, size, PROT_NONE) == 0;
16741674
#elif defined(__APPLE__)
16751675
if (exec) {
@@ -1739,7 +1739,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) {
17391739
assert(addr == bottom, "sanity check");
17401740

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

src/hotspot/os/linux/os_linux.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3639,7 +3639,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) {
36393639
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
36403640
if (addr != g_assert_poison)
36413641
#endif
3642-
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
3642+
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
36433643
return ::mprotect(bottom, size, prot) == 0;
36443644
}
36453645

src/hotspot/share/code/nmethod.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ void nmethod::purge(bool free_code_cache_data) {
14481448
MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag);
14491449

14501450
// completely deallocate this method
1451-
Events::log(Thread::current(), "flushing nmethod " INTPTR_FORMAT, p2i(this));
1451+
Events::log_nmethod_flush(Thread::current(), "flushing %s nmethod " INTPTR_FORMAT, is_osr_method() ? "osr" : "", p2i(this));
14521452
log_debug(codecache)("*flushing %s nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT
14531453
"/Free CodeCache:" SIZE_FORMAT "Kb",
14541454
is_osr_method() ? "osr" : "",_compile_id, p2i(this), CodeCache::blob_count(),

src/hotspot/share/utilities/events.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,8 @@
3636

3737
EventLog* Events::_logs = nullptr;
3838
StringEventLog* Events::_messages = nullptr;
39+
StringEventLog* Events::_memprotect_messages = nullptr;
40+
StringEventLog* Events::_nmethod_flush_messages = nullptr;
3941
StringEventLog* Events::_vm_operations = nullptr;
4042
StringEventLog* Events::_zgc_phase_switch = nullptr;
4143
ExceptionsEventLog* Events::_exceptions = nullptr;
@@ -96,6 +98,8 @@ void Events::print() {
9698
void Events::init() {
9799
if (LogEvents) {
98100
_messages = new StringEventLog("Events", "events");
101+
_nmethod_flush_messages = new StringEventLog("Nmethod flushes", "nmethodflushes");
102+
_memprotect_messages = new StringEventLog("Memory protections", "memprotects");
99103
_vm_operations = new StringEventLog("VM Operations", "vmops");
100104
_zgc_phase_switch = new StringEventLog("ZGC Phase Switch", "zgcps");
101105
_exceptions = new ExceptionsEventLog("Internal exceptions", "exc");

src/hotspot/share/utilities/events.hpp

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -220,6 +220,12 @@ class Events : AllStatic {
220220
// A log for generic messages that aren't well categorized.
221221
static StringEventLog* _messages;
222222

223+
// A log for memory protection related messages
224+
static StringEventLog* _memprotect_messages;
225+
226+
// A log for nmethod flush operations
227+
static StringEventLog* _nmethod_flush_messages;
228+
223229
// A log for VM Operations
224230
static StringEventLog* _vm_operations;
225231

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

268+
static void log_memprotect(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
269+
270+
static void log_nmethod_flush(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
271+
262272
static void log_vm_operation(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
263273

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

303+
inline void Events::log_memprotect(Thread* thread, const char* format, ...) {
304+
if (LogEvents && _memprotect_messages != nullptr) {
305+
va_list ap;
306+
va_start(ap, format);
307+
_memprotect_messages->logv(thread, format, ap);
308+
va_end(ap);
309+
}
310+
}
311+
312+
inline void Events::log_nmethod_flush(Thread* thread, const char* format, ...) {
313+
if (LogEvents && _nmethod_flush_messages != nullptr) {
314+
va_list ap;
315+
va_start(ap, format);
316+
_nmethod_flush_messages->logv(thread, format, ap);
317+
va_end(ap);
318+
}
319+
}
320+
293321
inline void Events::log_vm_operation(Thread* thread, const char* format, ...) {
294322
if (LogEvents && _vm_operations != nullptr) {
295323
va_list ap;

0 commit comments

Comments
 (0)