[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Re: RFR(xs): 8213834: JVMTI ResourceExhausted should not be posted in CompilerThread
From:       JC Beyler <jcbeyler () google ! com>
Date:       2018-11-27 5:50:19
Message-ID: CAF9BGBwUTXVzPjW2hHgYjAw9oewxD1Zk2u+Mw4-3AuEmr0QoCg () mail ! gmail ! com
[Download RAW message or body]

Hi Thomas,

Looks good to me too!
Jc

On Mon, Nov 26, 2018 at 3:10 PM David Holmes <david.holmes@oracle.com>
wrote:

> +1 more
> 
> Thanks,
> David
> 
> On 27/11/2018 3:57 am, serguei.spitsyn@oracle.com wrote:
> > Hi Thomas,
> > 
> > +1
> > 
> > Thanks,
> > Serguei
> > 
> > 
> > On 11/26/18 06:53, Daniel D. Daugherty wrote:
> > > On 11/26/18 8:07 AM, Thomas Stüfe wrote:
> > > > Hi guys,
> > > > 
> > > > latest webrev:
> > > > 
> http://cr.openjdk.java.net/~stuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.02/webrev/
> 
> > > > 
> > > 
> > > src/hotspot/share/prims/jvmtiExport.cpp
> > > No comments.
> > > 
> > > Thumbs up.
> > > 
> > > Dan
> > > 
> > > > 
> > > > Back to can_call_java(), since this seems to be the consensus, with a
> > > > comment added.
> > > > 
> > > > As for the Thread::can_send_jvmti_events() property idea, I created a
> > > > RFE to track discussions around this:
> > > > https://bugs.openjdk.java.net/browse/JDK-8214294 but decided to
> > > > postpone this for later. I would like to close that particular issue,
> > > > if possible with a minimal fix which can be easily downported to older
> > > > released.
> > > > 
> > > > Thanks, Thomas
> > > > 
> > > > 
> > > > 
> > > > 
> > > > On Mon, Nov 19, 2018 at 1:00 PM Thomas Stüfe
> > > > <thomas.stuefe@gmail.com> wrote:
> > > > > Hi all,
> > > > > 
> > > > > David and JC already outlined the options we have nicely.
> > > > > 
> > > > > I'd like to add that I do not favor the ServiceThread delayed
> > > > > deliverance since a common reaction to ResourceExhausted would to
> > > > > print call stack of the thread running into it or to print a heap
> > > > > histogram, as jvmkill does. For the former only a synchronous event
> > > > > delivery makes sense, for the latter at least it helps analyzing.
> > > > > 
> > > > > In cloud foundry, the heap histogram produced by the JVMTI agent can
> > > > > be helpful, and since in the majority of cases do not entail the
> > > > > compiler thread running out of metaspace, I'd rather preserve this
> > > > > ability. So to me, masking this event for this one case is the most
> > > > > pragmatic approach.
> > > > > 
> > > > > The other option would be not to change the code but to add, in the
> > > > > JVMTI documentation for ResourceExhausted, the same disclaimer as for
> > > > > ObjectFree, GCStarted etc: "The event handler must not use JNI
> > > > > functions and must not use JVM TI functions except those which
> > > > > specifically allow such use". Then, writers of JVMTI agents like
> > > > > jvmkill would have to update their agents accordingly.
> > > > > 
> > > > > FWIW, I think JCs idea of exposing the can_call_java attribute somehow
> > > > > to the outside would also work. But unfortunately not retroactively,
> > > > > for older releases. Whereas a simple internal patch like "mask
> > > > > ResourceExhausted" could be backported easily to older releases.
> > > > > 
> > > > > Best Regards, Thomas
> > > > > 
> > > > > 
> > > > > On Thu, Nov 15, 2018 at 5:32 AM JC Beyler <jcbeyler@google.com>
> wrote:
> > > > > > For what it's worth I wonder if skipping the event is the best; it
> > > > > > is the easiest to ensure non breaking the agent; it does not really
> > > > > > go against what the spec is saying and another thread that CAN call
> > > > > > java will most likely hit the issue and then all will be good in
> > > > > > the world.
> > > > > > 
> > > > > > However, also for what it's worth I wonder if deferring is not that
> > > > > > hard to accomplish either. There already is the infrastructure for
> > > > > > this and we should be relatively able to do it. Only question I
> > > > > > would have is can the service thread create a JNIEnv for the event
> > > > > > but I don't think that's an issue, is it?
> > > > > > 
> > > > > > It might however conflict with the description of the JNIEnv in the
> > > > > > spec which says the jni_env is "The JNI environment of the event
> > > > > > (current) thread" though it doesn't say current of what or the
> > > > > > event thread of what really.
> > > > > > 
> > > > > > However, skipping it also kind of goes against the spec since it
> > > > > > says: "Sent when a VM resource needed by a running application has
> > > > > > been exhausted".Though someone could argue it doesn' t say it is
> > > > > > sent when the resource was first noticed to be exhausted.
> > > > > > 
> > > > > > So, if I over-read the spec and look at options, it seems that:
> > > > > > - Sending the event via the compiler thread will risk breaking
> > > > > > things if the agent calls Java    -> not really an option
> > > > > > - Using the service thread breaks what David calls the synchronous
> > > > > > assumption of the event
> > > > > > - Skipping the event kind of breaks the sentence that the event is
> > > > > > sent when a VM resource has been exhausted
> > > > > > 
> > > > > > So we come back to probably skipping is the best solution since at
> > > > > > least the event remains "synchronous" when you get it.
> > > > > > 
> > > > > > (A side note would be perhaps to augment ThreadInfo* with the
> > > > > > "can_call_java" bit and then put in the right spots of the spec
> > > > > > that only threads marked as "can_call_java" can safely call Java).
> > > > > > 
> > > > > > Thanks,
> > > > > > Jc
> > > 
> > 
> 


-- 

Thanks,
Jc


[Attachment #3 (text/html)]

<div dir="ltr">Hi Thomas,<div><br></div><div>Looks good to me \
too!</div><div>Jc</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Nov \
26, 2018 at 3:10 PM David Holmes &lt;<a \
href="mailto:david.holmes@oracle.com">david.holmes@oracle.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">+1 more<br> <br>
Thanks,<br>
David<br>
<br>
On 27/11/2018 3:57 am, <a href="mailto:serguei.spitsyn@oracle.com" \
target="_blank">serguei.spitsyn@oracle.com</a> wrote:<br> &gt; Hi Thomas,<br>
&gt; <br>
&gt; +1<br>
&gt; <br>
&gt; Thanks,<br>
&gt; Serguei<br>
&gt; <br>
&gt; <br>
&gt; On 11/26/18 06:53, Daniel D. Daugherty wrote:<br>
&gt;&gt; On 11/26/18 8:07 AM, Thomas Stüfe wrote:<br>
&gt;&gt;&gt; Hi guys,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; latest webrev: <br>
&gt;&gt;&gt; <a href="http://cr.openjdk.java.net/~stuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.02/webrev/" \
rel="noreferrer" target="_blank">http://cr.openjdk.java.net/~stuefe/webrevs/8213834-jv \
mti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.02/webrev/</a> \
<br> &gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; src/hotspot/share/prims/jvmtiExport.cpp<br>
&gt;&gt;        No comments.<br>
&gt;&gt;<br>
&gt;&gt; Thumbs up.<br>
&gt;&gt;<br>
&gt;&gt; Dan<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Back to can_call_java(), since this seems to be the consensus, with \
a<br> &gt;&gt;&gt; comment added.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; As for the Thread::can_send_jvmti_events() property idea, I created \
a<br> &gt;&gt;&gt; RFE to track discussions around this:<br>
&gt;&gt;&gt; <a href="https://bugs.openjdk.java.net/browse/JDK-8214294" \
rel="noreferrer" target="_blank">https://bugs.openjdk.java.net/browse/JDK-8214294</a> \
but decided to<br> &gt;&gt;&gt; postpone this for later. I would like to close that \
particular issue,<br> &gt;&gt;&gt; if possible with a minimal fix which can be easily \
downported to older<br> &gt;&gt;&gt; released.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks, Thomas<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, Nov 19, 2018 at 1:00 PM Thomas Stüfe <br>
&gt;&gt;&gt; &lt;<a href="mailto:thomas.stuefe@gmail.com" \
target="_blank">thomas.stuefe@gmail.com</a>&gt; wrote:<br> &gt;&gt;&gt;&gt; Hi \
all,<br> &gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; David and JC already outlined the options we have nicely.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I&#39;d like to add that I do not favor the ServiceThread \
delayed<br> &gt;&gt;&gt;&gt; deliverance since a common reaction to ResourceExhausted \
would to<br> &gt;&gt;&gt;&gt; print call stack of the thread running into it or to \
print a heap<br> &gt;&gt;&gt;&gt; histogram, as jvmkill does. For the former only a \
synchronous event<br> &gt;&gt;&gt;&gt; delivery makes sense, for the latter at least \
it helps analyzing.<br> &gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; In cloud foundry, the heap histogram produced by the JVMTI agent \
can<br> &gt;&gt;&gt;&gt; be helpful, and since in the majority of cases do not entail \
the<br> &gt;&gt;&gt;&gt; compiler thread running out of metaspace, I&#39;d rather \
preserve this<br> &gt;&gt;&gt;&gt; ability. So to me, masking this event for this one \
case is the most<br> &gt;&gt;&gt;&gt; pragmatic approach.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The other option would be not to change the code but to add, in \
the<br> &gt;&gt;&gt;&gt; JVMTI documentation for ResourceExhausted, the same \
disclaimer as for<br> &gt;&gt;&gt;&gt; ObjectFree, GCStarted etc: &quot;The event \
handler must not use JNI<br> &gt;&gt;&gt;&gt; functions and must not use JVM TI \
functions except those which<br> &gt;&gt;&gt;&gt; specifically allow such use&quot;. \
Then, writers of JVMTI agents like<br> &gt;&gt;&gt;&gt; jvmkill would have to update \
their agents accordingly.<br> &gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; FWIW, I think JCs idea of exposing the can_call_java attribute \
somehow<br> &gt;&gt;&gt;&gt; to the outside would also work. But unfortunately not \
retroactively,<br> &gt;&gt;&gt;&gt; for older releases. Whereas a simple internal \
patch like &quot;mask<br> &gt;&gt;&gt;&gt; ResourceExhausted&quot; could be \
backported easily to older releases.<br> &gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Best Regards, Thomas<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Thu, Nov 15, 2018 at 5:32 AM JC Beyler &lt;<a \
href="mailto:jcbeyler@google.com" target="_blank">jcbeyler@google.com</a>&gt; \
wrote:<br> &gt;&gt;&gt;&gt;&gt; For what it&#39;s worth I wonder if skipping the \
event is the best; it <br> &gt;&gt;&gt;&gt;&gt; is the easiest to ensure non breaking \
the agent; it does not really <br> &gt;&gt;&gt;&gt;&gt; go against what the spec is \
saying and another thread that CAN call <br> &gt;&gt;&gt;&gt;&gt; java will most \
likely hit the issue and then all will be good in <br> &gt;&gt;&gt;&gt;&gt; the \
world.<br> &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; However, also for what it&#39;s worth I wonder if deferring is \
not that <br> &gt;&gt;&gt;&gt;&gt; hard to accomplish either. There already is the \
infrastructure for <br> &gt;&gt;&gt;&gt;&gt; this and we should be relatively able to \
do it. Only question I <br> &gt;&gt;&gt;&gt;&gt; would have is can the service thread \
create a JNIEnv for the event <br> &gt;&gt;&gt;&gt;&gt; but I don&#39;t think \
that&#39;s an issue, is it?<br> &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; It might however conflict with the description of the JNIEnv in \
the <br> &gt;&gt;&gt;&gt;&gt; spec which says the jni_env is &quot;The JNI \
environment of the event <br> &gt;&gt;&gt;&gt;&gt; (current) thread&quot; though it \
doesn&#39;t say current of what or the <br> &gt;&gt;&gt;&gt;&gt; event thread of what \
really.<br> &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; However, skipping it also kind of goes against the spec since it \
<br> &gt;&gt;&gt;&gt;&gt; says: &quot;Sent when a VM resource needed by a running \
application has <br> &gt;&gt;&gt;&gt;&gt; been exhausted&quot;.Though someone could \
argue it doesn&#39; t say it is <br> &gt;&gt;&gt;&gt;&gt; sent when the resource was \
first noticed to be exhausted.<br> &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; So, if I over-read the spec and look at options, it seems \
that:<br> &gt;&gt;&gt;&gt;&gt; - Sending the event via the compiler thread will risk \
breaking <br> &gt;&gt;&gt;&gt;&gt; things if the agent calls Java       -&gt; not \
really an option<br> &gt;&gt;&gt;&gt;&gt; - Using the service thread breaks what \
David calls the synchronous <br> &gt;&gt;&gt;&gt;&gt; assumption of the event<br>
&gt;&gt;&gt;&gt;&gt; - Skipping the event kind of breaks the sentence that the event \
is <br> &gt;&gt;&gt;&gt;&gt; sent when a VM resource has been exhausted<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; So we come back to probably skipping is the best solution since \
at <br> &gt;&gt;&gt;&gt;&gt; least the event remains &quot;synchronous&quot; when you \
get it.<br> &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; (A side note would be perhaps to augment ThreadInfo* with the \
<br> &gt;&gt;&gt;&gt;&gt; &quot;can_call_java&quot; bit and then put in the right \
spots of the spec <br> &gt;&gt;&gt;&gt;&gt; that only threads marked as \
&quot;can_call_java&quot; can safely call Java).<br> &gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt;&gt;&gt; Jc<br>
&gt;&gt;<br>
&gt; <br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" \
class="gmail_signature" data-smartmail="gmail_signature"><div \
dir="ltr"><div><br></div>Thanks,<div>Jc</div></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic