Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755146AbbBLIWk (ORCPT ); Thu, 12 Feb 2015 03:22:40 -0500 Received: from lgeamrelo04.lge.com ([156.147.1.127]:60708 "EHLO lgeamrelo04.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754789AbbBLIWj (ORCPT ); Thu, 12 Feb 2015 03:22:39 -0500 X-Original-SENDERIP: 10.177.220.203 X-Original-MAILFROM: namhyung@kernel.org Date: Thu, 12 Feb 2015 17:21:09 +0900 From: Namhyung Kim To: Stephane Eranian Cc: linux-kernel@vger.kernel.org, acme@redhat.com, peterz@infradead.org, mingo@elte.hu, ak@linux.intel.com, jolsa@redhat.com, cel@us.ibm.com, sukadev@linux.vnet.ibm.com, sonnyrao@chromium.org, johnmccutchan@google.com Subject: Re: [PATCH 4/4] perf tools: add JVMTI agent library Message-ID: <20150212082109.GG30788@sejong> References: <1423611765-18200-1-git-send-email-eranian@google.com> <1423611765-18200-5-git-send-email-eranian@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1423611765-18200-5-git-send-email-eranian@google.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3836 Lines: 133 On Wed, Feb 11, 2015 at 12:42:45AM +0100, Stephane Eranian wrote: > This is a standalone JVMTI library to help profile Java jitted > code with perf record/perf report. The library is not installed > or compiled automatically by perf Makefile. It is not used > directly by perf. It is arch agnostic and has been tested on > X86 and ARM. It needs to be used with a Java runtime, such > as OpenJDK, as follows: > > $ java -agentpath:libjvmti.so ....... > > When used this way, java will generate a jitdump binary file in > $HOME/.debug/java/jit/java-jit-* > > This binary dump file contains information to help symbolize and > annotate jitted code. > > The next step is to inject the jitdump information into the > perf.data file: > $ perf inject -j $HOME/.debug/java/jit/java-jit-XXXX/jit-ZZZ.dump \ > -i perf.data -o perf.data.jitted > > This injects the MMAP records to cover the jitted code and also generates > one ELF image for each jitted function. The ELF images are created in the > same subdir as the jitdump file. The MMAP records point there too. > > Then to visualize the function or asm profile, simply use the regular > perf commands: > $ perf report -i perf.data.jitted > or > $ perf annotate -i perf.data.jitted > > JVMTI agent code adapted from OProfile's opagent code. > > Signed-off-by: Stephane Eranian > --- > tools/perf/jvmti/Makefile | 70 +++++++++ > tools/perf/jvmti/jvmti_agent.c | 349 +++++++++++++++++++++++++++++++++++++++++ > tools/perf/jvmti/jvmti_agent.h | 23 +++ > tools/perf/jvmti/libjvmti.c | 149 ++++++++++++++++++ > 4 files changed, 591 insertions(+) > create mode 100644 tools/perf/jvmti/Makefile > create mode 100644 tools/perf/jvmti/jvmti_agent.c > create mode 100644 tools/perf/jvmti/jvmti_agent.h > create mode 100644 tools/perf/jvmti/libjvmti.c > > diff --git a/tools/perf/jvmti/Makefile b/tools/perf/jvmti/Makefile > new file mode 100644 > index 0000000..9eda64b > --- /dev/null > +++ b/tools/perf/jvmti/Makefile > @@ -0,0 +1,70 @@ > +ARCH=$(shell uname -m) > + > +ifeq ($(ARCH), x86_64) > +JARCH=amd64 > +endif > +ifeq ($(ARCH), armv7l) > +JARCH=armhf > +endif > +ifeq ($(ARCH), armv6l) > +JARCH=armhf > +endif > +ifeq ($(ARCH), ppc64) > +JARCH=powerpc > +endif > +ifeq ($(ARCH), ppc64le) > +JARCH=powerpc > +endif > + > +DESTDIR=/usr/local > + > +VERSION=1 > +REVISION=0 > +AGE=0 > + > +LN=ln -sf > +RM=rm > + > +SJVMTI=libjvmti.so.$(VERSION).$(REVISION).$(AGE) > +VJVMTI=libjvmti.so.$(VERSION) > +SLDFLAGS=-shared -Wl,-soname -Wl,$(VLIBPFM) s/VLIBPFM/VLIBJVMTI/ ? Thanks, Namhyung > +SOLIBEXT=so > + > +JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | cut -d ' ' -f 3) > +# -lrt required in 32-bit mode for clock_gettime() > +LIBS=-lelf -lrt > +INCDIR=-I $(JDIR)/include -I $(JDIR)/include/linux > + > +TARGETS=$(SJVMTI) > + > +SRCS=libjvmti.c jvmti_agent.c > +OBJS=$(SRCS:.c=.o) > +SOBJS=$(OBJS:.o=.lo) > +OPT=-O2 -g -Werror -Wall > + > +CFLAGS=$(INCDIR) $(OPT) > + > +all: $(TARGETS) > + > +.c.o: > + $(CC) $(CFLAGS) -c $*.c > +.c.lo: > + $(CC) -fPIC -DPIC $(CFLAGS) -c $*.c -o $*.lo > + > +$(OBJS) $(SOBJS): Makefile jvmti_agent.h ../util/jitdump.h > + > +$(SJVMTI): $(SOBJS) > + $(CC) $(CFLAGS) $(SLDFLAGS) -o $@ $(SOBJS) $(LIBS) > + $(LN) $@ libjvmti.$(SOLIBEXT) > + > +clean: > + $(RM) -f *.o *.so.* *.so *.lo > + > +install: > + -mkdir -p $(DESTDIR)/lib > + install -m 755 $(SJVMTI) $(DESTDIR)/lib/ > + (cd $(DESTDIR)/lib; $(LN) $(SJVMTI) $(VJVMTI)) > + (cd $(DESTDIR)/lib; $(LN) $(SJVMTI) libjvmti.$(SOLIBEXT)) > + ldconfig > + > +.SUFFIXES: .c .S .o .lo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/