Skip to contentSkip to conversation

perf/java: Add s390 support for jitted JAVA

PATCH Applied Thomas Richter 2 participants 5 messages Sep 9, 2019 – Sep 24, 2019 perf events

lore
Share & tools
lore
#0 lore raw

cover perf/java: Add s390 support for jitted JAVA

This patch set adds support for jitted JAVA and requires the following packages (The java-8 version is not sufficient for s390):

- java-11-openjdk-11.0.2.7-7.fc30.s390x
- java-11-openjdk-headless-11.0.2.7-7.fc30.s390x
- java-11-openjdk-devel-11.0.2.7-7.fc30.s390x

and this patch series:
Patch 1 (perf jvmti): Compile jvmti/* and generate a loadable
libperf-jvmti.so
Patch 2 (perf): Include JVMTI into the s390 build
Patch 3 (perf/java): Add detection of java-11-openjdk-devel package

Thomas Richter (3):
perf jvmti: Link against tools/lib/string.h to have weak strlcpy()
perf: Include JVMTI support for s390
perf/java: Add detection of java-11-openjdk-devel package

 tools/perf/Makefile.config    |  2 +-
 tools/perf/arch/s390/Makefile |  1 +
 tools/perf/jvmti/Build        | 13 +++++++++++++
 tools/perf/util/genelf.h      |  3 +++
 4 files changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/3 perf jvmti: Link against tools/lib/string.h to have weak strlcpy()

That is needed in systems such some S/390 distros.

[root@m35lp76 perf]# readelf -s jvmti/jvmti-in.o | fgrep strlcpy
408: 0000000000002bc8 216 FUNC WEAK DEFAULT 116 strlcpy
[root@m35lp76 perf]#

---
 tools/perf/jvmti/Build | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/perf/jvmti/Build +13 -0
index eaeb8cb5379b..202cadaaf097 100644
@@ -1,8 +1,21 @@
 jvmti-y += libjvmti.o
 jvmti-y += jvmti_agent.o
 
+# For strlcpy
+jvmti-y += libstring.o libctype.o
+
 CFLAGS_jvmti         = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
 CFLAGS_REMOVE_jvmti  = -Wmissing-declarations
 CFLAGS_REMOVE_jvmti += -Wstrict-prototypes
 CFLAGS_REMOVE_jvmti += -Wextra
 CFLAGS_REMOVE_jvmti += -Wwrite-strings
+
+CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
+
+$(OUTPUT)jvmti/libstring.o: ../lib/string.c FORCE
+	$(call rule_mkdir)
+	$(call if_changed_dep,cc_o_c)
+
+$(OUTPUT)jvmti/libctype.o: ../lib/ctype.c FORCE
+	$(call rule_mkdir)
+	$(call if_changed_dep,cc_o_c)
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/3 perf: Include JVMTI support for s390

In reply to Thomas Richter

Enable JTI support for s390 perf tool chain

---
 tools/perf/arch/s390/Makefile | 1 +
 tools/perf/util/genelf.h      | 3 +++
 2 files changed, 4 insertions(+)
tools/perf/arch/s390/Makefile +1 -0
index cb198787570a..6ac8887be7c9 100644
@@ -4,6 +4,7 @@ PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
 PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
+PERF_HAVE_JITDUMP := 1
 
 #
 # Syscall table generation for perf
tools/perf/util/genelf.h +3 -0
index b72440bf9a79..d4137559be05 100644
@@ -35,6 +35,9 @@ int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_ent
 #elif defined(__sparc__)
 #define GEN_ELF_ARCH	EM_SPARC
 #define GEN_ELF_CLASS	ELFCLASS32
+#elif defined(__s390x__)
+#define GEN_ELF_ARCH	EM_S390
+#define GEN_ELF_CLASS	ELFCLASS64
 #else
 #error "unsupported architecture"
 #endif
Signature · 1 line
2.21.0
#3 lore raw

PATCH 3/3 perf/java: Add detection of java-11-openjdk-devel package

In reply to Thomas Richter

With Java 11 there is no seperate JRE anymore.
Details: https://coderanch.com/t/701603/java/JRE-JDK
Therefore the detection of the JRE needs to be adapted.

This change works for s390 and x86.
I have not tested other platforms.

---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
index 89ac5a1f1550..3da374911852 100644
@@ -908,7 +908,7 @@ ifndef NO_JVMTI
     JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
   else
     ifneq (,$(wildcard /usr/sbin/alternatives))
-      JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
+      JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g')
     endif
   endif
   ifndef JDIR
Signature · 1 line
2.21.0
#4 lore raw

Re: [PATCH 3/3] perf/java: Add detection of java-11-openjdk-devel package

Em Mon, Sep 09, 2019 at 01:41:16PM +0200, Thomas Richter escreveu:

Quoted 6 lines

With Java 11 there is no seperate JRE anymore.
Details: https://coderanch.com/t/701603/java/JRE-JDK
Therefore the detection of the JRE needs to be adapted.

This change works for s390 and x86.
I have not tested other platforms.

Committer testing:

Continues to work with the OpenJDK 8:

$ rm -f ~acme/lib64/libperf-jvmti.so
$ rpm -qa | grep jdk-devel
java-1.8.0-openjdk-devel-1.8.0.222.b10-0.fc30.x86_64
$ git log --oneline -1
a51937170f33 (HEAD -> perf/core) perf build: Add detection of java-11-openjdk-devel package
$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make -C tools/perf O=/tmp/build/perf install > /dev/null 2>1 $ ls -la ~acme/lib64/libperf-jvmti.so
-rwxr-xr-x. 1 acme acme 230744 Sep 24 16:46 /home/acme/lib64/libperf-jvmti.so
$

Thanks, applied.

- Arnaldo

Quoted 21 lines
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
index 89ac5a1f1550..3da374911852 100644
@@ -908,7 +908,7 @@ ifndef NO_JVMTI
     JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
   else
     ifneq (,$(wildcard /usr/sbin/alternatives))
-      JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
+      JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g')
     endif
   endif
   ifndef JDIR
Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo