public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Stephane Eranian <eranian@google.com>
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
Date: Thu, 12 Feb 2015 17:21:09 +0900	[thread overview]
Message-ID: <20150212082109.GG30788@sejong> (raw)
In-Reply-To: <1423611765-18200-5-git-send-email-eranian@google.com>

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 <eranian@google.com>
> ---
>  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

  reply	other threads:[~2015-02-12  8:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 23:42 [PATCH 0/4] perf: add support for profiling jitted code Stephane Eranian
2015-02-10 23:42 ` [PATCH 1/4] perf tools: add Java demangling support Stephane Eranian
2015-02-12  8:12   ` Namhyung Kim
2015-02-12 11:27   ` Jiri Olsa
2015-02-10 23:42 ` [PATCH 2/4] perf tools: pass timestamp to map_init Stephane Eranian
2015-02-16  6:55   ` Adrian Hunter
2015-02-10 23:42 ` [PATCH 3/4] perf inject: add jitdump mmap injection support Stephane Eranian
2015-02-11 11:59   ` Peter Zijlstra
2015-02-11 13:13     ` Stephane Eranian
2015-02-11 15:27   ` David Ahern
2015-02-12  8:19     ` Namhyung Kim
2015-02-10 23:42 ` [PATCH 4/4] perf tools: add JVMTI agent library Stephane Eranian
2015-02-12  8:21   ` Namhyung Kim [this message]
2015-02-12 13:25   ` Jiri Olsa
2015-02-12 16:09     ` Stephane Eranian
2015-02-12 16:58   ` Andi Kleen
2015-02-12 17:11     ` Stephane Eranian
2015-02-16  7:01   ` Adrian Hunter
2015-02-16 20:22     ` Stephane Eranian
2015-02-18  8:43       ` Adrian Hunter
2015-02-11 11:39 ` [PATCH 0/4] perf: add support for profiling jitted code Peter Zijlstra
2015-02-11 13:18   ` Stephane Eranian
2015-02-11 16:15     ` Peter Zijlstra
2015-02-11 16:25       ` David Ahern
2015-02-12 13:42 ` Jiri Olsa
2015-02-12 17:27   ` Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150212082109.GG30788@sejong \
    --to=namhyung@kernel.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=cel@us.ibm.com \
    --cc=eranian@google.com \
    --cc=johnmccutchan@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=sonnyrao@chromium.org \
    --cc=sukadev@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox