Skip to content

Commit

Permalink
JDK21u4 updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm3746 committed Oct 4, 2024
1 parent 8446791 commit e6fe945
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**********************************************************************************************************************
* krashpad *
* *
* Copyright (c) 2020-2024 Mike Millson *
* *
* This program and the accompanying materials are made available under the terms of the Eclipse Public License *
* v. 2.0 which is available at https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 which is *
* available at https://www.apache.org/licenses/LICENSE-2.0. *
* *
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 *
* *
* Contributors: *
* Mike Millson - initial API and implementation *
*********************************************************************************************************************/
package org.github.krashpad.domain.jdk;

import org.github.krashpad.domain.HeaderEvent;
import org.github.krashpad.domain.LogEvent;
import org.github.krashpad.util.jdk.JdkRegEx;
import org.github.krashpad.util.jdk.JdkUtil.LogEventType;

/**
* <p>
* MEMORY_PROTECTION_EVENT
* </p>
*
* <p>
* Memory protection information. Reported under generic <code>Event</code> prior to JDK21u4:
* <a href="https://bugs.openjdk.org/browse/JDK-8329605">JDK-8329605: hs errfile generic events - move memory
* protections and nmethod flushes to separate sections</a>.
* </p>
*
* <h2>Example Logging</h2>
*
* <pre>
* Memory protections (20 events):
* Event: 227.096 Protecting memory [0x00007f11466e8000,0x00007f11466ec000] with protection modes 0
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
public class MemoryProtectionEvent implements LogEvent, HeaderEvent {
/**
* Regular expression for the header.
*/
public static final String _REGEX_HEADER = "Memory protections \\(\\d{1,} events\\):";

/**
* Regular expression defining the logging.
*/
private static final String REGEX = "^(" + _REGEX_HEADER + "|Event: " + JdkRegEx.TIMESTAMP
+ " Protecting memory .+|No events)$";

/**
* Determine if the logLine matches the logging pattern(s) for this event.
*
* @param logLine
* The log line to test.
* @return true if the log line matches the event pattern, false otherwise.
*/
public static final boolean match(String logLine) {
return logLine.matches(REGEX);
}

/**
* The log entry for the event.
*/
private String logEntry;

/**
* Create event from log entry.
*
* @param logEntry
* The log entry for the event.
*/
public MemoryProtectionEvent(String logEntry) {
this.logEntry = logEntry;
}

@Override
public LogEventType getEventType() {
return LogEventType.MEMORY_PROTECTION_EVENT;
}

public String getLogEntry() {
return logEntry;
}

@Override
public boolean isHeader() {
boolean isHeader = false;
if (this.logEntry != null) {
isHeader = logEntry.matches(_REGEX_HEADER);
}
return isHeader;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**********************************************************************************************************************
* krashpad *
* *
* Copyright (c) 2020-2024 Mike Millson *
* *
* This program and the accompanying materials are made available under the terms of the Eclipse Public License *
* v. 2.0 which is available at https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 which is *
* available at https://www.apache.org/licenses/LICENSE-2.0. *
* *
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 *
* *
* Contributors: *
* Mike Millson - initial API and implementation *
*********************************************************************************************************************/
package org.github.krashpad.domain.jdk;

import org.github.krashpad.domain.HeaderEvent;
import org.github.krashpad.domain.LogEvent;
import org.github.krashpad.util.jdk.JdkRegEx;
import org.github.krashpad.util.jdk.JdkUtil.LogEventType;

/**
* <p>
* NMETHOD_FLUSHES_EVENT
* </p>
*
* <p>
* nmethod flushes information. Reported under generic <code>Event</code> prior to JDK21u4:
* <a href="https://bugs.openjdk.org/browse/JDK-8329605">JDK-8329605: hs errfile generic events - move memory
* protections and nmethod flushes to separate sections</a>.
* </p>
*
* <h2>Example Logging</h2>
*
* <pre>
* Nmethod flushes (20 events):
* Event: 39.992 Thread 0x00007f128cf57870 flushing nmethod 0x00007f1235b2ae90
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
public class NmethodFlushesEvent implements LogEvent, HeaderEvent {
/**
* Regular expression for the header.
*/
public static final String _REGEX_HEADER = "Nmethod flushes \\(\\d{1,} events\\):";

/**
* Regular expression defining the logging.
*/
private static final String REGEX = "^(" + _REGEX_HEADER + "|Event: " + JdkRegEx.TIMESTAMP + " Thread "
+ JdkRegEx.ADDRESS + " flushing .+|No events)$";

/**
* Determine if the logLine matches the logging pattern(s) for this event.
*
* @param logLine
* The log line to test.
* @return true if the log line matches the event pattern, false otherwise.
*/
public static final boolean match(String logLine) {
return logLine.matches(REGEX);
}

/**
* The log entry for the event.
*/
private String logEntry;

/**
* Create event from log entry.
*
* @param logEntry
* The log entry for the event.
*/
public NmethodFlushesEvent(String logEntry) {
this.logEntry = logEntry;
}

@Override
public LogEventType getEventType() {
return LogEventType.NMETHOD_FLUSHES_EVENT;
}

public String getLogEntry() {
return logEntry;
}

@Override
public boolean isHeader() {
boolean isHeader = false;
if (this.logEntry != null) {
isHeader = logEntry.matches(_REGEX_HEADER);
}
return isHeader;
}
}
82 changes: 82 additions & 0 deletions src/main/java/org/github/krashpad/domain/jdk/Swappiness.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**********************************************************************************************************************
* krashpad *
* *
* Copyright (c) 2020-2024 Mike Millson *
* *
* This program and the accompanying materials are made available under the terms of the Eclipse Public License *
* v. 2.0 which is available at https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 which is *
* available at https://www.apache.org/licenses/LICENSE-2.0. *
* *
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 *
* *
* Contributors: *
* Mike Millson - initial API and implementation *
*********************************************************************************************************************/
package org.github.krashpad.domain.jdk;

import org.github.krashpad.domain.LogEvent;
import org.github.krashpad.util.jdk.JdkUtil.LogEventType;

/**
* <p>
* SWAPPINESS
* </p>
*
* <p>
* swappiness information (a higher value means more swappy). Added in JDK17u12 and JDK21u4:
* <a href="https://bugs.openjdk.org/browse/JDK-8327059">JDK-8327059: os::Linux::print_proc_sys_info add swappiness
* information</a>.
* </p>
*
* <h2>Example Logging</h2>
*
* <pre>
* /proc/sys/vm/swappiness (control to define how aggressively the kernel swaps out anonymous memory): 10
* </pre>
*
* @author <a href="mailto:mmillson@redhat.com">Mike Millson</a>
*
*/
public class Swappiness implements LogEvent {

/**
* Regular expression defining the logging.
*/
private static final String REGEX = "^/proc/sys/vm/swappiness \\(control to define how aggressively the kernel "
+ "swaps out anonymous memory\\): \\d{1,3}$";

/**
* Determine if the logLine matches the logging pattern(s) for this event.
*
* @param logLine
* The log line to test.
* @return true if the log line matches the event pattern, false otherwise.
*/
public static final boolean match(String logLine) {
return logLine.matches(REGEX);
}

/**
* The log entry for the event.
*/
private String logEntry;

/**
* Create event from log entry.
*
* @param logEntry
* The log entry for the event.
*/
public Swappiness(String logEntry) {
this.logEntry = logEntry;
}

@Override
public LogEventType getEventType() {
return LogEventType.SWAPPINESS;
}

public String getLogEntry() {
return logEntry;
}
}
32 changes: 27 additions & 5 deletions src/main/java/org/github/krashpad/util/jdk/JdkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@
import org.github.krashpad.domain.jdk.MaxMapCount;
import org.github.krashpad.domain.jdk.Meminfo;
import org.github.krashpad.domain.jdk.Memory;
import org.github.krashpad.domain.jdk.MemoryProtectionEvent;
import org.github.krashpad.domain.jdk.Metaspace;
import org.github.krashpad.domain.jdk.NarrowKlass;
import org.github.krashpad.domain.jdk.NativeDecoderState;
import org.github.krashpad.domain.jdk.NativeMemoryTracking;
import org.github.krashpad.domain.jdk.NmethodFlushesEvent;
import org.github.krashpad.domain.jdk.OsInfo;
import org.github.krashpad.domain.jdk.OsUptime;
import org.github.krashpad.domain.jdk.PeriodicNativeTrim;
Expand All @@ -92,6 +94,7 @@
import org.github.krashpad.domain.jdk.SignalHandlers;
import org.github.krashpad.domain.jdk.Stack;
import org.github.krashpad.domain.jdk.StackSlotToMemoryMapping;
import org.github.krashpad.domain.jdk.Swappiness;
import org.github.krashpad.domain.jdk.Thread;
import org.github.krashpad.domain.jdk.ThreadsActiveCompile;
import org.github.krashpad.domain.jdk.ThreadsClassSmrInfo;
Expand Down Expand Up @@ -239,15 +242,17 @@ public enum LogEventType {
//
HEAP_REGIONS, HOST, INSTRUCTIONS, INTEGER, INTERNAL_EXCEPTION_EVENT, INTERNAL_STATISTIC,
//
LD_PRELOAD_FILE, LIBC, LOAD_AVERAGE, LOGGING, MACH_CODE, MAX_MAP_COUNT, MEMINFO, MEMORY, METASPACE,
LD_PRELOAD_FILE, LIBC, LOAD_AVERAGE, LOGGING, MACH_CODE, MAX_MAP_COUNT, MEMINFO, MEMORY,
//
NARROW_KLASS, NATIVE_DECODER_STATE, NATIVE_MEMORY_TRACKING, OS_INFO, OS_UPTIME, PERIODIC_NATIVE_TRIM, PID,
MEMORY_PROTECTION_EVENT, METASPACE, NARROW_KLASS, NATIVE_DECODER_STATE, NATIVE_MEMORY_TRACKING,
//
PID_MAX, POLLING_PAGE, PROCESS_MEMORY, REGISTER, REGISTER_TO_MEMORY_MAPPING, RLIMIT, SIGINFO, SIGNAL_HANDLERS,
NMETHOD_FLUSHES_EVENT, OS_INFO, OS_UPTIME, PERIODIC_NATIVE_TRIM, PID, PID_MAX, POLLING_PAGE, PROCESS_MEMORY,
//
STACK, STACK_SLOT_TO_MEMORY_MAPPING, THREAD, THREADS_ACTIVE_COMPILE, THREADS_CLASS_SMR_INFO, THREADS_MAX, TIME,
REGISTER, REGISTER_TO_MEMORY_MAPPING, RLIMIT, SIGINFO, SIGNAL_HANDLERS, STACK, STACK_SLOT_TO_MEMORY_MAPPING,
//
TIME_ELAPSED_TIME, TIMEOUT, TIMEZONE, TOP_OF_STACK, TRANSPARENT_HUGEPAGE_DEFRAG, TRANSPARENT_HUGEPAGE_ENABLED,
SWAPPINESS, THREAD, THREADS_ACTIVE_COMPILE, THREADS_CLASS_SMR_INFO, THREADS_MAX, TIME, TIME_ELAPSED_TIME,
//
TIMEOUT, TIMEZONE, TOP_OF_STACK, TRANSPARENT_HUGEPAGE_DEFRAG, TRANSPARENT_HUGEPAGE_ENABLED,
//
TRANSPARENT_HUGEPAGE_HPAGE_PMD_SIZE, UID, UMASK, UNAME, UNKNOWN, VIRTUALIZATION_INFO, VM_ARGUMENTS, VM_INFO,
//
Expand Down Expand Up @@ -818,6 +823,9 @@ public static final LogEventType identifyEventType(String logLine, LogEvent prio
} else if (logLine.matches(Memory._REGEX_HEADER)
|| (priorEvent instanceof Memory && Memory.match(logLine))) {
logEventType = LogEventType.MEMORY;
} else if (logLine.matches(MemoryProtectionEvent._REGEX_HEADER)
|| (priorEvent instanceof MemoryProtectionEvent && MemoryProtectionEvent.match(logLine))) {
logEventType = LogEventType.MEMORY_PROTECTION_EVENT;
} else if (Metaspace.match(logLine)) {
logEventType = LogEventType.METASPACE;
} else if (NarrowKlass.match(logLine)) {
Expand All @@ -827,6 +835,9 @@ public static final LogEventType identifyEventType(String logLine, LogEvent prio
} else if (logLine.matches(NativeMemoryTracking._REGEX_HEADER)
|| (priorEvent instanceof NativeMemoryTracking && NativeMemoryTracking.match(logLine))) {
logEventType = LogEventType.NATIVE_MEMORY_TRACKING;
} else if (logLine.matches(NmethodFlushesEvent._REGEX_HEADER)
|| (priorEvent instanceof NmethodFlushesEvent && NmethodFlushesEvent.match(logLine))) {
logEventType = LogEventType.NMETHOD_FLUSHES_EVENT;
} else if (OsInfo.match(logLine)) {
logEventType = LogEventType.OS_INFO;
} else if (OsUptime.match(logLine)) {
Expand Down Expand Up @@ -858,6 +869,8 @@ public static final LogEventType identifyEventType(String logLine, LogEvent prio
} else if (logLine.matches(StackSlotToMemoryMapping._REGEX_HEADER)
|| (priorEvent instanceof StackSlotToMemoryMapping && StackSlotToMemoryMapping.match(logLine))) {
logEventType = LogEventType.STACK_SLOT_TO_MEMORY_MAPPING;
} else if (Swappiness.match(logLine)) {
logEventType = LogEventType.SWAPPINESS;
} else if (Thread.match(logLine)) {
logEventType = LogEventType.THREAD;
} else if (ThreadsActiveCompile.match(logLine)) {
Expand Down Expand Up @@ -1154,6 +1167,9 @@ public static final LogEvent parseLogLine(String logLine, LogEvent priorEvent) {
case MEMORY:
event = new Memory(logLine);
break;
case MEMORY_PROTECTION_EVENT:
event = new MemoryProtectionEvent(logLine);
break;
case METASPACE:
event = new Metaspace(logLine);
break;
Expand All @@ -1166,6 +1182,9 @@ public static final LogEvent parseLogLine(String logLine, LogEvent priorEvent) {
case NATIVE_MEMORY_TRACKING:
event = new NativeMemoryTracking(logLine);
break;
case NMETHOD_FLUSHES_EVENT:
event = new NmethodFlushesEvent(logLine);
break;
case OS_INFO:
event = new OsInfo(logLine);
break;
Expand Down Expand Up @@ -1208,6 +1227,9 @@ public static final LogEvent parseLogLine(String logLine, LogEvent priorEvent) {
case STACK_SLOT_TO_MEMORY_MAPPING:
event = new StackSlotToMemoryMapping(logLine);
break;
case SWAPPINESS:
event = new Swappiness(logLine);
break;
case THREAD:
event = new Thread(logLine);
break;
Expand Down
Loading

0 comments on commit e6fe945

Please sign in to comment.