Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTTng hotspot and hotspot private tracepoints #14

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dev-tracing/lttng_examples/test/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class Main {

public static void main(String[] args) {
System.out.println("Hello world");
}
}
21 changes: 21 additions & 0 deletions dev-tracing/lttng_examples/test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
jdkPath="../../../build/linux-x86_64-server-release/images/jdk/bin"

$jdkPath/javac Main.java


lttng create test-session --output=./here
lttng enable-event -u 'hotspot:*' --channel=channel1
lttng enable-event -u 'hs_private:*' --channel=channel2
# lttng enable-event -k --userspace-probe=sdt:$jdkPath/../lib/server/libjvm.so:hotspot:method__entry --channel=channel1 entry
lttng start

$jdkPath/java -XX:+DTraceMethodProbes Main


lttng stop
lttng view

lttng destroy test-session



1 change: 1 addition & 0 deletions make/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ JDKOPT_SETUP_ADDRESS_SANITIZER

# Need toolchain to setup dtrace
HOTSPOT_SETUP_DTRACE
HOTSPOT_SETUP_LTTNG
HOTSPOT_ENABLE_DISABLE_AOT
HOTSPOT_ENABLE_DISABLE_CDS
HOTSPOT_ENABLE_DISABLE_GTEST
Expand Down
29 changes: 27 additions & 2 deletions make/autoconf/hotspot.m4
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#

# All valid JVM features, regardless of platform
VALID_JVM_FEATURES="compiler1 compiler2 zero minimal dtrace jvmti jvmci \
VALID_JVM_FEATURES="compiler1 compiler2 zero minimal dtrace lttng jvmti jvmci \
graal vm-structs jni-check services management cmsgc epsilongc g1gc parallelgc serialgc shenandoahgc zgc nmt cds \
static-build link-time-opt aot jfr"

Expand Down Expand Up @@ -199,6 +199,23 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_DTRACE],
fi
])

###############################################################################
# Check if lttng should be enabled.
#
AC_DEFUN_ONCE([HOTSPOT_SETUP_LTTNG],
[

AC_ARG_ENABLE([lttng], [AS_HELP_STRING([--enable-lttng],
[enable lttng hotspot tracepoints.])], [lttng_enabled=yes])

INCLUDE_LTTNG=true
if test "x$INCLUDE_DTRACE" = "xtrue" && test "$INCLUDE_LTTNG" = "xtrue"; then
AC_MSG_ERROR([dtrace and lttng can not be included at the same time])
fi
])



################################################################################
# Check if AOT should be enabled
#
Expand Down Expand Up @@ -363,14 +380,22 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
DISABLED_JVM_FEATURES="$DISABLED_JVM_FEATURES epsilongc g1gc zgc shenandoahgc"
fi

# Turn on additional features based on other parts of configure
Copy link
Member

Choose a reason for hiding this comment

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

Это похоже на ошибку

Turn on additional features based on other parts of configure
if test "x$INCLUDE_DTRACE" = "xtrue"; then
JVM_FEATURES="$JVM_FEATURES dtrace"
else
if HOTSPOT_CHECK_JVM_FEATURE(dtrace); then
AC_MSG_ERROR([To enable dtrace, you must use --enable-dtrace])
fi
fi

if test "x$INCLUDE_LTTNG" = "xtrue"; then
JVM_FEATURES="$JVM_FEATURES lttng"
else
if HOTSPOT_CHECK_JVM_FEATURE(lttng); then
AC_MSG_ERROR([To enable lttng, you must use --enable-lttng])
fi
fi

if test "x$STATIC_BUILD" = "xtrue"; then
JVM_FEATURES="$JVM_FEATURES static-build"
Expand Down
4 changes: 4 additions & 0 deletions make/autoconf/libraries.m4
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lthread"
fi

if test "x$INCLUDE_LTTNG" = xtrue; then
BASIC_JVM_LIBS="$BASIC_JVM_LIBS -ldl -llttng-ust"
fi

# perfstat lib
if test "x$OPENJDK_TARGET_OS" = xaix; then
BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat"
Expand Down
4 changes: 4 additions & 0 deletions make/hotspot/lib/JvmFeatures.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ ifeq ($(call check-jvm-feature, dtrace), true)
JVM_CFLAGS_FEATURES += -DDTRACE_ENABLED
endif

ifeq ($(call check-jvm-feature, lttng), true)
JVM_CFLAGS_FEATURES += -DLTTNG_ENABLED
endif

ifeq ($(call check-jvm-feature, static-build), true)
JVM_CFLAGS_FEATURES += -DSTATIC_BUILD=1
endif
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/utilities/dtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
#include "dtracefiles/hotspot_jni.h"
#include "dtracefiles/hs_private.h"

#elif defined(LTTNG_ENABLED)

#include "utilities/lttng.hpp"
#define DTRACE_ONLY(x) x
#define NOT_DTRACE(x)

#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()

#else /* defined(DTRACE_ENABLED) */

#define DTRACE_ONLY(x)
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/dtrace_disabled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
#define HS_PRIVATE_CMS_REMARK_BEGIN_ENABLED() 0
#define HS_PRIVATE_CMS_REMARK_END()
#define HS_PRIVATE_CMS_REMARK_END_ENABLED() 0
#define HS_PRIVATE_HASHTABLE_NEW_ENTRY(arg0, arg1, arg2, arg3)
#define HS_PRIVATE_HASHTABLE_NEW_ENTRY(arg0, arg1, arg2, arg3) // does not exist
#define HS_PRIVATE_HASHTABLE_NEW_ENTRY_ENABLED() 0
#define HS_PRIVATE_SAFEPOINT_BEGIN()
#define HS_PRIVATE_SAFEPOINT_BEGIN_ENABLED() 0
Expand Down
1,031 changes: 1,031 additions & 0 deletions src/hotspot/share/utilities/lttng.hpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/hotspot/share/utilities/lttngHSPrivate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE

#include <utilities/lttngHSPrivate.hpp>
64 changes: 64 additions & 0 deletions src/hotspot/share/utilities/lttngHSPrivate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#if !defined(TRACEPOINT_HEADER_MULTI_READ)
#define TRACEPOINT_HEADER_MULTI_READ
#endif

#undef TRACEPOINT_PROVIDER
#define TRACEPOINT_PROVIDER hs_private

#undef TRACEPOINT_INCLUDE
#define TRACEPOINT_INCLUDE "./utilities/lttngHSPrivate.hpp"

#if !defined(_VM_METHODS_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
Copy link
Member

Choose a reason for hiding this comment

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

_VM_METHODS_TP_H -- это guard macro, чтобы файл не инклюдился несколько раз?

  1. Идентификатор используется здесь и в lttngTracepoints.hpp, ошибка. Лучше начинать по имени, вроде LTTNG_HS_PRIVATE_H_
  2. начинать с _ не стоит -- такие имена зарезервированны за ОС/компилятором

#define _VM_METHODS_TP_H

#include <lttng/tracepoint.h>


/* hotspot private events */

TRACEPOINT_EVENT(
hs_private,
safepoint__begin,
TP_ARGS(),
TP_FIELDS()
)

TRACEPOINT_EVENT(
hs_private,
safepoint__end,
TP_ARGS(),
TP_FIELDS()
)

TRACEPOINT_EVENT(
hs_private,
cms__initmark__begin,
TP_ARGS(),
TP_FIELDS()
)

TRACEPOINT_EVENT(
hs_private,
cms__initmark__end,
TP_ARGS(),
TP_FIELDS()
)

TRACEPOINT_EVENT(
hs_private,
cms__remark__begin,
TP_ARGS(),
TP_FIELDS()
)

TRACEPOINT_EVENT(
hs_private,
cms__remark__end,
TP_ARGS(),
TP_FIELDS()
)


#endif

#include <lttng/tracepoint-event.h>
4 changes: 4 additions & 0 deletions src/hotspot/share/utilities/lttngTracepoints.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE

#include <utilities/lttngTracepoints.hpp>
Loading