author | mgronlun |
Wed, 30 Oct 2019 19:43:52 +0100 | |
changeset 58863 | c16ac7a2eba4 |
parent 57699 | 4aea554692aa |
permissions | -rw-r--r-- |
50113 | 1 |
/* |
53255
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
50113 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "jfr/jfrEvents.hpp" |
|
27 |
#include "jfr/recorder/jfrRecorder.hpp" |
|
28 |
#include "jfr/periodic/sampling/jfrCallTrace.hpp" |
|
29 |
#include "jfr/periodic/sampling/jfrThreadSampler.hpp" |
|
30 |
#include "jfr/recorder/service/jfrOptionSet.hpp" |
|
31 |
#include "jfr/recorder/stacktrace/jfrStackTraceRepository.hpp" |
|
32 |
#include "jfr/support/jfrThreadId.hpp" |
|
58863 | 33 |
#include "jfr/support/jfrThreadLocal.hpp" |
50113 | 34 |
#include "jfr/utilities/jfrTime.hpp" |
35 |
#include "logging/log.hpp" |
|
36 |
#include "runtime/frame.inline.hpp" |
|
37 |
#include "runtime/os.hpp" |
|
38 |
#include "runtime/semaphore.hpp" |
|
39 |
#include "runtime/thread.inline.hpp" |
|
40 |
#include "runtime/threadSMR.hpp" |
|
41 |
||
42 |
enum JfrSampleType { |
|
43 |
NO_SAMPLE = 0, |
|
44 |
JAVA_SAMPLE = 1, |
|
45 |
NATIVE_SAMPLE = 2 |
|
46 |
}; |
|
47 |
||
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
48 |
static bool thread_state_in_java(JavaThread* thread) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
49 |
assert(thread != NULL, "invariant"); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
50 |
switch(thread->thread_state()) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
51 |
case _thread_new: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
52 |
case _thread_uninitialized: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
53 |
case _thread_new_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
54 |
case _thread_in_vm_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
55 |
case _thread_blocked_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
56 |
case _thread_in_native_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
57 |
case _thread_blocked: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
58 |
case _thread_in_vm: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
59 |
case _thread_in_native: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
60 |
case _thread_in_Java_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
61 |
break; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
62 |
case _thread_in_Java: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
63 |
return true; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
64 |
default: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
65 |
ShouldNotReachHere(); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
66 |
break; |
50113 | 67 |
} |
68 |
return false; |
|
69 |
} |
|
70 |
||
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
71 |
static bool thread_state_in_native(JavaThread* thread) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
72 |
assert(thread != NULL, "invariant"); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
73 |
switch(thread->thread_state()) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
74 |
case _thread_new: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
75 |
case _thread_uninitialized: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
76 |
case _thread_new_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
77 |
case _thread_blocked_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
78 |
case _thread_blocked: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
79 |
case _thread_in_vm: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
80 |
case _thread_in_vm_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
81 |
case _thread_in_Java_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
82 |
case _thread_in_Java: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
83 |
case _thread_in_native_trans: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
84 |
break; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
85 |
case _thread_in_native: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
86 |
return true; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
87 |
default: |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
88 |
ShouldNotReachHere(); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
89 |
break; |
50113 | 90 |
} |
91 |
return false; |
|
92 |
} |
|
93 |
||
94 |
class JfrThreadSampleClosure { |
|
95 |
public: |
|
96 |
JfrThreadSampleClosure(EventExecutionSample* events, EventNativeMethodSample* events_native); |
|
97 |
~JfrThreadSampleClosure() {} |
|
98 |
EventExecutionSample* next_event() { return &_events[_added_java++]; } |
|
99 |
EventNativeMethodSample* next_event_native() { return &_events_native[_added_native++]; } |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
100 |
void commit_events(JfrSampleType type); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
101 |
bool do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, JfrSampleType type); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
102 |
uint java_entries() { return _added_java; } |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
103 |
uint native_entries() { return _added_native; } |
50113 | 104 |
|
105 |
private: |
|
106 |
bool sample_thread_in_java(JavaThread* thread, JfrStackFrame* frames, u4 max_frames); |
|
107 |
bool sample_thread_in_native(JavaThread* thread, JfrStackFrame* frames, u4 max_frames); |
|
108 |
EventExecutionSample* _events; |
|
109 |
EventNativeMethodSample* _events_native; |
|
110 |
Thread* _self; |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
111 |
uint _added_java; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
112 |
uint _added_native; |
50113 | 113 |
}; |
114 |
||
115 |
class OSThreadSampler : public os::SuspendedThreadTask { |
|
116 |
public: |
|
117 |
OSThreadSampler(JavaThread* thread, |
|
118 |
JfrThreadSampleClosure& closure, |
|
119 |
JfrStackFrame *frames, |
|
120 |
u4 max_frames) : os::SuspendedThreadTask((Thread*)thread), |
|
121 |
_success(false), |
|
122 |
_stacktrace(frames, max_frames), |
|
123 |
_closure(closure), |
|
124 |
_suspend_time() {} |
|
125 |
||
126 |
void take_sample(); |
|
127 |
void do_task(const os::SuspendedThreadTaskContext& context); |
|
128 |
void protected_task(const os::SuspendedThreadTaskContext& context); |
|
129 |
bool success() const { return _success; } |
|
130 |
const JfrStackTrace& stacktrace() const { return _stacktrace; } |
|
131 |
||
132 |
private: |
|
133 |
bool _success; |
|
134 |
JfrStackTrace _stacktrace; |
|
135 |
JfrThreadSampleClosure& _closure; |
|
136 |
JfrTicks _suspend_time; |
|
137 |
}; |
|
138 |
||
139 |
class OSThreadSamplerCallback : public os::CrashProtectionCallback { |
|
140 |
public: |
|
141 |
OSThreadSamplerCallback(OSThreadSampler& sampler, const os::SuspendedThreadTaskContext &context) : |
|
142 |
_sampler(sampler), _context(context) { |
|
143 |
} |
|
144 |
virtual void call() { |
|
145 |
_sampler.protected_task(_context); |
|
146 |
} |
|
147 |
private: |
|
148 |
OSThreadSampler& _sampler; |
|
149 |
const os::SuspendedThreadTaskContext& _context; |
|
150 |
}; |
|
151 |
||
152 |
void OSThreadSampler::do_task(const os::SuspendedThreadTaskContext& context) { |
|
153 |
#ifndef ASSERT |
|
154 |
guarantee(JfrOptionSet::sample_protection(), "Sample Protection should be on in product builds"); |
|
155 |
#endif |
|
156 |
assert(_suspend_time.value() == 0, "already timestamped!"); |
|
157 |
_suspend_time = JfrTicks::now(); |
|
158 |
||
159 |
if (JfrOptionSet::sample_protection()) { |
|
160 |
OSThreadSamplerCallback cb(*this, context); |
|
161 |
os::ThreadCrashProtection crash_protection; |
|
162 |
if (!crash_protection.call(cb)) { |
|
163 |
log_error(jfr)("Thread method sampler crashed"); |
|
164 |
} |
|
165 |
} else { |
|
166 |
protected_task(context); |
|
167 |
} |
|
168 |
} |
|
169 |
||
170 |
/* |
|
171 |
* From this method and down the call tree we attempt to protect against crashes |
|
172 |
* using a signal handler / __try block. Don't take locks, rely on destructors or |
|
173 |
* leave memory (in case of signal / exception) in an inconsistent state. */ |
|
174 |
void OSThreadSampler::protected_task(const os::SuspendedThreadTaskContext& context) { |
|
175 |
JavaThread* jth = (JavaThread*)context.thread(); |
|
176 |
// Skip sample if we signaled a thread that moved to other state |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
177 |
if (!thread_state_in_java(jth)) { |
50113 | 178 |
return; |
179 |
} |
|
180 |
JfrGetCallTrace trace(true, jth); |
|
181 |
frame topframe; |
|
182 |
if (trace.get_topframe(context.ucontext(), topframe)) { |
|
183 |
if (_stacktrace.record_thread(*jth, topframe)) { |
|
184 |
/* If we managed to get a topframe and a stacktrace, create an event |
|
185 |
* and put it into our array. We can't call Jfr::_stacktraces.add() |
|
186 |
* here since it would allocate memory using malloc. Doing so while |
|
187 |
* the stopped thread is inside malloc would deadlock. */ |
|
188 |
_success = true; |
|
189 |
EventExecutionSample *ev = _closure.next_event(); |
|
190 |
ev->set_starttime(_suspend_time); |
|
191 |
ev->set_endtime(_suspend_time); // fake to not take an end time |
|
192 |
ev->set_sampledThread(JFR_THREAD_ID(jth)); |
|
193 |
ev->set_state(java_lang_Thread::get_thread_status(jth->threadObj())); |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
void OSThreadSampler::take_sample() { |
|
199 |
run(); |
|
200 |
} |
|
201 |
||
202 |
class JfrNativeSamplerCallback : public os::CrashProtectionCallback { |
|
203 |
public: |
|
204 |
JfrNativeSamplerCallback(JfrThreadSampleClosure& closure, JavaThread* jt, JfrStackFrame* frames, u4 max_frames) : |
|
205 |
_closure(closure), _jt(jt), _stacktrace(frames, max_frames), _success(false) { |
|
206 |
} |
|
207 |
virtual void call(); |
|
208 |
bool success() { return _success; } |
|
209 |
JfrStackTrace& stacktrace() { return _stacktrace; } |
|
210 |
||
211 |
private: |
|
212 |
JfrThreadSampleClosure& _closure; |
|
213 |
JavaThread* _jt; |
|
214 |
JfrStackTrace _stacktrace; |
|
215 |
bool _success; |
|
216 |
}; |
|
217 |
||
218 |
static void write_native_event(JfrThreadSampleClosure& closure, JavaThread* jt) { |
|
219 |
EventNativeMethodSample *ev = closure.next_event_native(); |
|
220 |
ev->set_starttime(JfrTicks::now()); |
|
221 |
ev->set_sampledThread(JFR_THREAD_ID(jt)); |
|
222 |
ev->set_state(java_lang_Thread::get_thread_status(jt->threadObj())); |
|
223 |
} |
|
224 |
||
225 |
void JfrNativeSamplerCallback::call() { |
|
226 |
// When a thread is only attach it will be native without a last java frame |
|
227 |
if (!_jt->has_last_Java_frame()) { |
|
228 |
return; |
|
229 |
} |
|
230 |
||
231 |
frame topframe = _jt->last_frame(); |
|
232 |
frame first_java_frame; |
|
233 |
Method* method = NULL; |
|
234 |
JfrGetCallTrace gct(false, _jt); |
|
235 |
if (!gct.find_top_frame(topframe, &method, first_java_frame)) { |
|
236 |
return; |
|
237 |
} |
|
238 |
if (method == NULL) { |
|
239 |
return; |
|
240 |
} |
|
241 |
topframe = first_java_frame; |
|
242 |
_success = _stacktrace.record_thread(*_jt, topframe); |
|
243 |
if (_success) { |
|
244 |
write_native_event(_closure, _jt); |
|
245 |
} |
|
246 |
} |
|
247 |
||
248 |
bool JfrThreadSampleClosure::sample_thread_in_java(JavaThread* thread, JfrStackFrame* frames, u4 max_frames) { |
|
249 |
OSThreadSampler sampler(thread, *this, frames, max_frames); |
|
250 |
sampler.take_sample(); |
|
251 |
/* We don't want to allocate any memory using malloc/etc while the thread |
|
252 |
* is stopped, so everything is stored in stack allocated memory until this |
|
253 |
* point where the thread has been resumed again, if the sampling was a success |
|
254 |
* we need to store the stacktrace in the stacktrace repository and update |
|
255 |
* the event with the id that was returned. */ |
|
256 |
if (!sampler.success()) { |
|
257 |
return false; |
|
258 |
} |
|
259 |
EventExecutionSample *event = &_events[_added_java - 1]; |
|
260 |
traceid id = JfrStackTraceRepository::add(sampler.stacktrace()); |
|
261 |
assert(id != 0, "Stacktrace id should not be 0"); |
|
262 |
event->set_stackTrace(id); |
|
263 |
return true; |
|
264 |
} |
|
265 |
||
266 |
bool JfrThreadSampleClosure::sample_thread_in_native(JavaThread* thread, JfrStackFrame* frames, u4 max_frames) { |
|
267 |
JfrNativeSamplerCallback cb(*this, thread, frames, max_frames); |
|
268 |
if (JfrOptionSet::sample_protection()) { |
|
269 |
os::ThreadCrashProtection crash_protection; |
|
270 |
if (!crash_protection.call(cb)) { |
|
271 |
log_error(jfr)("Thread method sampler crashed for native"); |
|
272 |
} |
|
273 |
} else { |
|
274 |
cb.call(); |
|
275 |
} |
|
276 |
if (!cb.success()) { |
|
277 |
return false; |
|
278 |
} |
|
279 |
EventNativeMethodSample *event = &_events_native[_added_native - 1]; |
|
280 |
traceid id = JfrStackTraceRepository::add(cb.stacktrace()); |
|
281 |
assert(id != 0, "Stacktrace id should not be 0"); |
|
282 |
event->set_stackTrace(id); |
|
283 |
return true; |
|
284 |
} |
|
285 |
||
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
286 |
static const uint MAX_NR_OF_JAVA_SAMPLES = 5; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
287 |
static const uint MAX_NR_OF_NATIVE_SAMPLES = 1; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
288 |
|
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
289 |
void JfrThreadSampleClosure::commit_events(JfrSampleType type) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
290 |
if (JAVA_SAMPLE == type) { |
53096
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
291 |
assert(_added_java > 0 && _added_java <= MAX_NR_OF_JAVA_SAMPLES, "invariant"); |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
292 |
for (uint i = 0; i < _added_java; ++i) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
293 |
_events[i].commit(); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
294 |
} |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
295 |
} else { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
296 |
assert(NATIVE_SAMPLE == type, "invariant"); |
53096
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
297 |
assert(_added_native > 0 && _added_native <= MAX_NR_OF_NATIVE_SAMPLES, "invariant"); |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
298 |
for (uint i = 0; i < _added_native; ++i) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
299 |
_events_native[i].commit(); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
300 |
} |
50113 | 301 |
} |
302 |
} |
|
303 |
||
304 |
JfrThreadSampleClosure::JfrThreadSampleClosure(EventExecutionSample* events, EventNativeMethodSample* events_native) : |
|
305 |
_events(events), |
|
306 |
_events_native(events_native), |
|
307 |
_self(Thread::current()), |
|
308 |
_added_java(0), |
|
309 |
_added_native(0) { |
|
310 |
} |
|
311 |
||
51548 | 312 |
class JfrThreadSampler : public NonJavaThread { |
50113 | 313 |
friend class JfrThreadSampling; |
314 |
private: |
|
315 |
Semaphore _sample; |
|
316 |
Thread* _sampler_thread; |
|
317 |
JfrStackFrame* const _frames; |
|
318 |
JavaThread* _last_thread_java; |
|
319 |
JavaThread* _last_thread_native; |
|
320 |
size_t _interval_java; |
|
321 |
size_t _interval_native; |
|
322 |
int _cur_index; |
|
323 |
const u4 _max_frames; |
|
324 |
volatile bool _disenrolled; |
|
325 |
||
326 |
JavaThread* next_thread(ThreadsList* t_list, JavaThread* first_sampled, JavaThread* current); |
|
327 |
void task_stacktrace(JfrSampleType type, JavaThread** last_thread); |
|
328 |
JfrThreadSampler(size_t interval_java, size_t interval_native, u4 max_frames); |
|
329 |
~JfrThreadSampler(); |
|
330 |
||
331 |
void start_thread(); |
|
332 |
||
333 |
void enroll(); |
|
334 |
void disenroll(); |
|
335 |
void set_java_interval(size_t interval) { _interval_java = interval; }; |
|
336 |
void set_native_interval(size_t interval) { _interval_native = interval; }; |
|
337 |
size_t get_java_interval() { return _interval_java; }; |
|
338 |
size_t get_native_interval() { return _interval_native; }; |
|
53103
67e3a8b3449c
8214097: Rework thread initialization and teardown logic
dholmes
parents:
53096
diff
changeset
|
339 |
protected: |
67e3a8b3449c
8214097: Rework thread initialization and teardown logic
dholmes
parents:
53096
diff
changeset
|
340 |
virtual void post_run(); |
50113 | 341 |
public: |
342 |
void run(); |
|
52448
bc5c7f63dbae
8213137: Remove static initialization of monitor/mutex instances
dholmes
parents:
52302
diff
changeset
|
343 |
static Monitor* transition_block() { return JfrThreadSampler_lock; } |
50113 | 344 |
static void on_javathread_suspend(JavaThread* thread); |
345 |
}; |
|
346 |
||
347 |
static void clear_transition_block(JavaThread* jt) { |
|
348 |
jt->clear_trace_flag(); |
|
349 |
JfrThreadLocal* const tl = jt->jfr_thread_local(); |
|
350 |
if (tl->is_trace_block()) { |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54562
diff
changeset
|
351 |
MutexLocker ml(JfrThreadSampler::transition_block(), Mutex::_no_safepoint_check_flag); |
50113 | 352 |
JfrThreadSampler::transition_block()->notify_all(); |
353 |
} |
|
354 |
} |
|
355 |
||
58863 | 356 |
static bool is_excluded(JavaThread* thread) { |
357 |
assert(thread != NULL, "invariant"); |
|
358 |
return thread->is_hidden_from_external_view() || thread->in_deopt_handler() || thread->jfr_thread_local()->is_excluded(); |
|
359 |
} |
|
360 |
||
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
361 |
bool JfrThreadSampleClosure::do_sample_thread(JavaThread* thread, JfrStackFrame* frames, u4 max_frames, JfrSampleType type) { |
50113 | 362 |
assert(Threads_lock->owned_by_self(), "Holding the thread table lock."); |
58863 | 363 |
if (is_excluded(thread)) { |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
364 |
return false; |
50113 | 365 |
} |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
366 |
|
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
367 |
bool ret = false; |
54562 | 368 |
thread->set_trace_flag(); // Provides StoreLoad, needed to keep read of thread state from floating up. |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
369 |
if (JAVA_SAMPLE == type) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
370 |
if (thread_state_in_java(thread)) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
371 |
ret = sample_thread_in_java(thread, frames, max_frames); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
372 |
} |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
373 |
} else { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
374 |
assert(NATIVE_SAMPLE == type, "invariant"); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
375 |
if (thread_state_in_native(thread)) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
376 |
ret = sample_thread_in_native(thread, frames, max_frames); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
377 |
} |
50113 | 378 |
} |
379 |
clear_transition_block(thread); |
|
380 |
return ret; |
|
381 |
} |
|
382 |
||
383 |
JfrThreadSampler::JfrThreadSampler(size_t interval_java, size_t interval_native, u4 max_frames) : |
|
384 |
_sample(), |
|
385 |
_sampler_thread(NULL), |
|
386 |
_frames(JfrCHeapObj::new_array<JfrStackFrame>(max_frames)), |
|
387 |
_last_thread_java(NULL), |
|
388 |
_last_thread_native(NULL), |
|
389 |
_interval_java(interval_java), |
|
390 |
_interval_native(interval_native), |
|
391 |
_cur_index(-1), |
|
392 |
_max_frames(max_frames), |
|
393 |
_disenrolled(true) { |
|
394 |
} |
|
395 |
||
396 |
JfrThreadSampler::~JfrThreadSampler() { |
|
397 |
JfrCHeapObj::free(_frames, sizeof(JfrStackFrame) * _max_frames); |
|
398 |
} |
|
399 |
||
400 |
void JfrThreadSampler::on_javathread_suspend(JavaThread* thread) { |
|
401 |
JfrThreadLocal* const tl = thread->jfr_thread_local(); |
|
402 |
tl->set_trace_block(); |
|
403 |
{ |
|
54645
05aaccf7d558
8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents:
54623
diff
changeset
|
404 |
MonitorLocker ml(transition_block(), Mutex::_no_safepoint_check_flag); |
50113 | 405 |
while (thread->is_trace_suspend()) { |
54645
05aaccf7d558
8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents:
54623
diff
changeset
|
406 |
ml.wait(); |
50113 | 407 |
} |
408 |
tl->clear_trace_block(); |
|
409 |
} |
|
410 |
} |
|
411 |
||
412 |
JavaThread* JfrThreadSampler::next_thread(ThreadsList* t_list, JavaThread* first_sampled, JavaThread* current) { |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
413 |
assert(t_list != NULL, "invariant"); |
50113 | 414 |
assert(Threads_lock->owned_by_self(), "Holding the thread table lock."); |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
415 |
assert(_cur_index >= -1 && (uint)_cur_index + 1 <= t_list->length(), "invariant"); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
416 |
assert((current == NULL && -1 == _cur_index) || (t_list->find_index_of_JavaThread(current) == _cur_index), "invariant"); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
417 |
if ((uint)_cur_index + 1 == t_list->length()) { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
418 |
// wrap |
50113 | 419 |
_cur_index = 0; |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
420 |
} else { |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
421 |
_cur_index++; |
50113 | 422 |
} |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
423 |
assert(_cur_index >= 0 && (uint)_cur_index < t_list->length(), "invariant"); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
424 |
JavaThread* const next = t_list->thread_at(_cur_index); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
425 |
return next != first_sampled ? next : NULL; |
50113 | 426 |
} |
427 |
||
428 |
void JfrThreadSampler::start_thread() { |
|
429 |
if (os::create_thread(this, os::os_thread)) { |
|
430 |
os::start_thread(this); |
|
431 |
} else { |
|
432 |
log_error(jfr)("Failed to create thread for thread sampling"); |
|
433 |
} |
|
434 |
} |
|
435 |
||
436 |
void JfrThreadSampler::enroll() { |
|
437 |
if (_disenrolled) { |
|
438 |
log_info(jfr)("Enrolling thread sampler"); |
|
439 |
_sample.signal(); |
|
440 |
_disenrolled = false; |
|
441 |
} |
|
442 |
} |
|
443 |
||
444 |
void JfrThreadSampler::disenroll() { |
|
445 |
if (!_disenrolled) { |
|
446 |
_sample.wait(); |
|
447 |
_disenrolled = true; |
|
448 |
log_info(jfr)("Disenrolling thread sampler"); |
|
449 |
} |
|
450 |
} |
|
451 |
||
452 |
static jlong get_monotonic_ms() { |
|
453 |
return os::javaTimeNanos() / 1000000; |
|
454 |
} |
|
455 |
||
456 |
void JfrThreadSampler::run() { |
|
457 |
assert(_sampler_thread == NULL, "invariant"); |
|
50222
911b913022ef
8203635: JFR sampler thread does not record stack info
zgu
parents:
50113
diff
changeset
|
458 |
|
50113 | 459 |
_sampler_thread = this; |
460 |
||
461 |
jlong last_java_ms = get_monotonic_ms(); |
|
462 |
jlong last_native_ms = last_java_ms; |
|
463 |
while (true) { |
|
464 |
if (!_sample.trywait()) { |
|
465 |
// disenrolled |
|
466 |
_sample.wait(); |
|
467 |
last_java_ms = get_monotonic_ms(); |
|
468 |
last_native_ms = last_java_ms; |
|
469 |
} |
|
470 |
_sample.signal(); |
|
55267
eabe64456156
8216283: Allow shorter method sampling interval than 10 ms
egahlin
parents:
54645
diff
changeset
|
471 |
jlong java_interval = _interval_java == 0 ? max_jlong : MAX2<jlong>(_interval_java, 1); |
eabe64456156
8216283: Allow shorter method sampling interval than 10 ms
egahlin
parents:
54645
diff
changeset
|
472 |
jlong native_interval = _interval_native == 0 ? max_jlong : MAX2<jlong>(_interval_native, 1); |
50113 | 473 |
|
474 |
jlong now_ms = get_monotonic_ms(); |
|
475 |
||
53255
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
476 |
/* |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
477 |
* Let I be java_interval or native_interval. |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
478 |
* Let L be last_java_ms or last_native_ms. |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
479 |
* Let N be now_ms. |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
480 |
* |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
481 |
* Interval, I, might be max_jlong so the addition |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
482 |
* could potentially overflow without parenthesis (UB). Also note that |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
483 |
* L - N < 0. Avoid UB, by adding parenthesis. |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
484 |
*/ |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
485 |
jlong next_j = java_interval + (last_java_ms - now_ms); |
61a385765c9b
8216486: Possibility of integer overflow in JfrThreadSampler::run()
ysuenaga
parents:
53103
diff
changeset
|
486 |
jlong next_n = native_interval + (last_native_ms - now_ms); |
50113 | 487 |
|
488 |
jlong sleep_to_next = MIN2<jlong>(next_j, next_n); |
|
489 |
||
490 |
if (sleep_to_next > 0) { |
|
491 |
os::naked_short_sleep(sleep_to_next); |
|
492 |
} |
|
493 |
||
494 |
if ((next_j - sleep_to_next) <= 0) { |
|
495 |
task_stacktrace(JAVA_SAMPLE, &_last_thread_java); |
|
496 |
last_java_ms = get_monotonic_ms(); |
|
497 |
} |
|
498 |
if ((next_n - sleep_to_next) <= 0) { |
|
499 |
task_stacktrace(NATIVE_SAMPLE, &_last_thread_native); |
|
500 |
last_native_ms = get_monotonic_ms(); |
|
501 |
} |
|
502 |
} |
|
53103
67e3a8b3449c
8214097: Rework thread initialization and teardown logic
dholmes
parents:
53096
diff
changeset
|
503 |
} |
67e3a8b3449c
8214097: Rework thread initialization and teardown logic
dholmes
parents:
53096
diff
changeset
|
504 |
|
67e3a8b3449c
8214097: Rework thread initialization and teardown logic
dholmes
parents:
53096
diff
changeset
|
505 |
void JfrThreadSampler::post_run() { |
67e3a8b3449c
8214097: Rework thread initialization and teardown logic
dholmes
parents:
53096
diff
changeset
|
506 |
this->NonJavaThread::post_run(); |
50113 | 507 |
delete this; |
508 |
} |
|
509 |
||
510 |
||
511 |
void JfrThreadSampler::task_stacktrace(JfrSampleType type, JavaThread** last_thread) { |
|
512 |
ResourceMark rm; |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
513 |
EventExecutionSample samples[MAX_NR_OF_JAVA_SAMPLES]; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
514 |
EventNativeMethodSample samples_native[MAX_NR_OF_NATIVE_SAMPLES]; |
50113 | 515 |
JfrThreadSampleClosure sample_task(samples, samples_native); |
516 |
||
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
517 |
const uint sample_limit = JAVA_SAMPLE == type ? MAX_NR_OF_JAVA_SAMPLES : MAX_NR_OF_NATIVE_SAMPLES; |
53096
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
518 |
uint num_samples = 0; |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
519 |
JavaThread* start = NULL; |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
520 |
|
50113 | 521 |
{ |
522 |
elapsedTimer sample_time; |
|
523 |
sample_time.start(); |
|
524 |
{ |
|
57699
4aea554692aa
8226228: Make Threads_lock an always safepoint checked lock.
rehn
parents:
55267
diff
changeset
|
525 |
MutexLocker tlock(Threads_lock); |
50113 | 526 |
ThreadsListHandle tlh; |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
527 |
// Resolve a sample session relative start position index into the thread list array. |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
528 |
// In cases where the last sampled thread is NULL or not-NULL but stale, find_index() returns -1. |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
529 |
_cur_index = tlh.list()->find_index_of_JavaThread(*last_thread); |
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
530 |
JavaThread* current = _cur_index != -1 ? *last_thread : NULL; |
50113 | 531 |
|
53096
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
532 |
while (num_samples < sample_limit) { |
50113 | 533 |
current = next_thread(tlh.list(), start, current); |
534 |
if (current == NULL) { |
|
535 |
break; |
|
536 |
} |
|
537 |
if (start == NULL) { |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
538 |
start = current; // remember the thread where we started to attempt sampling |
50113 | 539 |
} |
540 |
if (current->is_Compiler_thread()) { |
|
541 |
continue; |
|
542 |
} |
|
53096
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
543 |
if (sample_task.do_sample_thread(current, _frames, _max_frames, type)) { |
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
544 |
num_samples++; |
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
545 |
} |
50113 | 546 |
} |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
547 |
*last_thread = current; // remember the thread we last attempted to sample |
50113 | 548 |
} |
549 |
sample_time.stop(); |
|
550 |
log_trace(jfr)("JFR thread sampling done in %3.7f secs with %d java %d native samples", |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
551 |
sample_time.seconds(), sample_task.java_entries(), sample_task.native_entries()); |
50113 | 552 |
} |
53096
58154bf80f90
8215727: Restore JFR thread sampler loop to old / previous behavior
mgronlun
parents:
52569
diff
changeset
|
553 |
if (num_samples > 0) { |
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
554 |
sample_task.commit_events(type); |
50113 | 555 |
} |
556 |
} |
|
557 |
||
558 |
static JfrThreadSampling* _instance = NULL; |
|
559 |
||
560 |
JfrThreadSampling& JfrThreadSampling::instance() { |
|
561 |
return *_instance; |
|
562 |
} |
|
563 |
||
564 |
JfrThreadSampling* JfrThreadSampling::create() { |
|
565 |
assert(_instance == NULL, "invariant"); |
|
566 |
_instance = new JfrThreadSampling(); |
|
567 |
return _instance; |
|
568 |
} |
|
569 |
||
570 |
void JfrThreadSampling::destroy() { |
|
571 |
if (_instance != NULL) { |
|
572 |
delete _instance; |
|
573 |
_instance = NULL; |
|
574 |
} |
|
575 |
} |
|
576 |
||
577 |
JfrThreadSampling::JfrThreadSampling() : _sampler(NULL) {} |
|
578 |
||
579 |
JfrThreadSampling::~JfrThreadSampling() { |
|
580 |
if (_sampler != NULL) { |
|
581 |
_sampler->disenroll(); |
|
582 |
} |
|
583 |
} |
|
584 |
||
585 |
static void log(size_t interval_java, size_t interval_native) { |
|
50373
22f611c395b3
8203921: JFR thread sampling is missing fixes from JDK-8194552
mgronlun
parents:
50222
diff
changeset
|
586 |
log_info(jfr)("Updated thread sampler for java: " SIZE_FORMAT " ms, native " SIZE_FORMAT " ms", interval_java, interval_native); |
50113 | 587 |
} |
588 |
||
589 |
void JfrThreadSampling::start_sampler(size_t interval_java, size_t interval_native) { |
|
590 |
assert(_sampler == NULL, "invariant"); |
|
591 |
log_info(jfr)("Enrolling thread sampler"); |
|
592 |
_sampler = new JfrThreadSampler(interval_java, interval_native, JfrOptionSet::stackdepth()); |
|
593 |
_sampler->start_thread(); |
|
594 |
_sampler->enroll(); |
|
595 |
} |
|
596 |
||
597 |
void JfrThreadSampling::set_sampling_interval(bool java_interval, size_t period) { |
|
598 |
size_t interval_java = 0; |
|
599 |
size_t interval_native = 0; |
|
600 |
if (_sampler != NULL) { |
|
601 |
interval_java = _sampler->get_java_interval(); |
|
602 |
interval_native = _sampler->get_native_interval(); |
|
603 |
} |
|
604 |
if (java_interval) { |
|
605 |
interval_java = period; |
|
606 |
} else { |
|
607 |
interval_native = period; |
|
608 |
} |
|
609 |
if (interval_java > 0 || interval_native > 0) { |
|
610 |
if (_sampler == NULL) { |
|
611 |
log_info(jfr)("Creating thread sampler for java:%zu ms, native %zu ms", interval_java, interval_native); |
|
612 |
start_sampler(interval_java, interval_native); |
|
613 |
} else { |
|
614 |
_sampler->set_java_interval(interval_java); |
|
615 |
_sampler->set_native_interval(interval_native); |
|
616 |
_sampler->enroll(); |
|
617 |
} |
|
618 |
assert(_sampler != NULL, "invariant"); |
|
619 |
log(interval_java, interval_native); |
|
620 |
} else if (_sampler != NULL) { |
|
621 |
_sampler->disenroll(); |
|
622 |
} |
|
623 |
} |
|
624 |
||
625 |
void JfrThreadSampling::set_java_sample_interval(size_t period) { |
|
626 |
if (_instance == NULL && 0 == period) { |
|
627 |
return; |
|
628 |
} |
|
629 |
instance().set_sampling_interval(true, period); |
|
630 |
} |
|
631 |
||
632 |
void JfrThreadSampling::set_native_sample_interval(size_t period) { |
|
633 |
if (_instance == NULL && 0 == period) { |
|
634 |
return; |
|
635 |
} |
|
636 |
instance().set_sampling_interval(false, period); |
|
637 |
} |
|
638 |
||
639 |
void JfrThreadSampling::on_javathread_suspend(JavaThread* thread) { |
|
640 |
JfrThreadSampler::on_javathread_suspend(thread); |
|
641 |
} |