All of lore.kernel.org
 help / color / mirror / Atom feed
* Jitdump format and jit injection behavior
@ 2017-05-14 21:44 Staffan Friberg
  0 siblings, 0 replies; only message in thread
From: Staffan Friberg @ 2017-05-14 21:44 UTC (permalink / raw)
  To: linux-perf-users@vger.kernel.org

Hi,

I have been writing a JVMTI agent to support the jitdump format, https://github.com/sfriberg/perf-jitdump-agent.

Reading the documentation for the jitdump format[1], it states the following.

IMPORTANT:
  The JIT_CODE_DEBUG for a given function must always be generated BEFORE the JIT_CODE_LOAD for the function. This facilitates greatly the parser for the jitdump file.

Reading this it seems like as long as the JIT_CODE_DEBUG event is written prior to the code load event the file should be parsed correctly. However reading through the source code for the jit inject command (and jitdump parser) it seems like it expects that the JIT_CODE_DEBUG event is directly before the associated JIT_CODE_DEBUG, if that is not the case multiple issues can happen.

1. The JIT_CODE_DEBUG information is applied to the wrong method. It is applied to the next found JIT_CODE_LOAD event without checking for a match.
2. Memory leak if two JIT_CODE_DEBUG events directly follow each other

Since HotSpot and other JVMs generally support methods to be compiled and optimized in parallel this is a case that can easily happen unless specifically ensuring the collocation of the two events stringently. I believe the example JVMTI agent in the kernel is susceptible to generate the wrong order of events as the order of the event is only guarded by locking the file and as such can write the events interleaved with events from other compilations.

The risk for a memory leak should probably be fixed no matter what, but it would be great to understand if the documentation perhaps should be clarified (perhaps "DIRECTLY BEFORE") or if jitdump parser should keep track of earlier JIT_CODE_DEBUG events and match them correctly.

Or it might just be me reading the code wrong.

Regards,
Staffan

[1] - linux/tools/perf/Documentation/jitdump-specification.txt 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-14 21:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-14 21:44 Jitdump format and jit injection behavior Staffan Friberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.