Skip to content

Commit 397d948

Browse files
committed
8329605: hs errfile generic events - move memory protections and nmethod flushes to separate sections
Reviewed-by: lucy, stefank, stuefe
1 parent f706949 commit 397d948

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
@@ -1934,7 +1934,7 @@ static bool checked_mprotect(char* addr, size_t size, int prot) {
19341934
//
19351935
// See http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/mprotect.htm
19361936

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

19401940
if (!rc) {

src/hotspot/os/bsd/os_bsd.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
15901590
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
15911591
#if defined(__OpenBSD__)
15921592
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
1593-
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
1593+
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
15941594
if (::mprotect(addr, size, prot) == 0) {
15951595
return true;
15961596
} else {
@@ -1711,7 +1711,7 @@ bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, siz
17111711
bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) {
17121712
#if defined(__OpenBSD__)
17131713
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
1714-
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
1714+
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
17151715
if (::mprotect(addr, size, PROT_NONE) == 0) {
17161716
return true;
17171717
} else {
@@ -1829,7 +1829,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) {
18291829
assert(addr == bottom, "sanity check");
18301830

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

src/hotspot/os/linux/os_linux.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3786,7 +3786,7 @@ static bool linux_mprotect(char* addr, size_t size, int prot) {
37863786
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
37873787
if (addr != g_assert_poison)
37883788
#endif
3789-
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
3789+
Events::log_memprotect(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
37903790
return ::mprotect(bottom, size, prot) == 0;
37913791
}
37923792

src/hotspot/share/code/nmethod.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ void nmethod::purge(bool free_code_cache_data, bool unregister_nmethod) {
20372037
MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag);
20382038

20392039
// completely deallocate this method
2040-
Events::log(Thread::current(), "flushing nmethod " INTPTR_FORMAT, p2i(this));
2040+
Events::log_nmethod_flush(Thread::current(), "flushing %s nmethod " INTPTR_FORMAT, is_osr_method() ? "osr" : "", p2i(this));
20412041
log_debug(codecache)("*flushing %s nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT
20422042
"/Free CodeCache:" SIZE_FORMAT "Kb",
20432043
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
@@ -37,6 +37,8 @@
3737

3838
EventLog* Events::_logs = nullptr;
3939
StringEventLog* Events::_messages = nullptr;
40+
StringEventLog* Events::_memprotect_messages = nullptr;
41+
StringEventLog* Events::_nmethod_flush_messages = nullptr;
4042
StringEventLog* Events::_vm_operations = nullptr;
4143
StringEventLog* Events::_zgc_phase_switch = nullptr;
4244
ExceptionsEventLog* Events::_exceptions = nullptr;
@@ -97,6 +99,8 @@ void Events::print() {
9799
void Events::init() {
98100
if (LogEvents) {
99101
_messages = new StringEventLog("Events", "events");
102+
_nmethod_flush_messages = new StringEventLog("Nmethod flushes", "nmethodflushes");
103+
_memprotect_messages = new StringEventLog("Memory protections", "memprotects");
100104
_vm_operations = new StringEventLog("VM Operations", "vmops");
101105
if (UseZGC) {
102106
_zgc_phase_switch = new StringEventLog("ZGC Phase Switch", "zgcps");

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)