From: Adrian Hunter <adrian.hunter@intel.com>
To: Stephane Eranian <eranian@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
"mingo@elte.hu" <mingo@elte.hu>,
"ak@linux.intel.com" <ak@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Rose Belcher <cel@us.ibm.com>,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
Sonny Rao <sonnyrao@chromium.org>,
John Mccutchan <johnmccutchan@google.com>
Subject: Re: [PATCH 4/4] perf tools: add JVMTI agent library
Date: Wed, 18 Feb 2015 10:43:32 +0200 [thread overview]
Message-ID: <54E450B4.6060100@intel.com> (raw)
In-Reply-To: <CABPqkBRLXGTF_RfsJLEWLUQMrutnuNV1HPrKaHPuUxwj=6kiYw@mail.gmail.com>
On 16/02/15 22:22, Stephane Eranian wrote:
> On Mon, Feb 16, 2015 at 2:01 AM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> On 11/02/15 01:42, 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>
>>> ---
[snip]
>>> +
>>> +int jvmti_write_code(void *agent, char const *sym,
>>> + uint64_t vma, void const *code, unsigned int const size)
>>> +{
>>> + static int code_generation = 1;
>>> + struct jr_code_load rec;
>>> + size_t sym_len;
>>> + size_t padding_count;
>>> + FILE *fp = agent;
>>> + int ret = -1;
>>> +
>>> + /* don't care about 0 length function, no samples */
>>> + if (size == 0)
>>> + return 0;
>>> +
>>> + if (!fp) {
>>> + warnx("jvmti: invalid fd in write_native_code");
>>> + return -1;
>>> + }
>>> +
>>> + sym_len = strlen(sym) + 1;
>>> +
>>> + rec.p.id = JIT_CODE_LOAD;
>>> + rec.p.total_size = sizeof(rec) + sym_len;
>>> + padding_count = PADDING_8ALIGNED(rec.p.total_size);
>>> + rec.p. total_size += padding_count;
>>> + rec.p.timestamp = perf_get_timestamp(perf_fd);
>>
>> Do you know whether the JVM is guaranteed not to start executing the
>> generated code before the return of compiled_method_load_cb(), otherwise the
>> timestamp will be too late?
>>
> I don't know that. I did not check.
> But are you saying the callback may be asynchronous with the JIT compiler?
Possibly, although it seems unlikely. But perhaps there are other threads
waiting for the code and it lets them go at the same time. I guess we can
assume that doesn't happen. When we use it with Intel PT it will show up if
the timestamp isn't before the first execution, because there will be
decoder errors.
next prev parent reply other threads:[~2015-02-18 8:45 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
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 [this message]
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=54E450B4.6060100@intel.com \
--to=adrian.hunter@intel.com \
--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=namhyung@kernel.org \
--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