Hi Dan,
I have taken a look with your suggested patch – I think your suggestion looks
very good.
I guess the original hang happened because the PeriodicTask_lock was attempted
to be acquired by a JavaThread, but the PeriodicTask_lock was still held by
someone else. Since the PeriodicTask_lock was taken with
“Mutex::_no_safepoint_checks” it meant the JavaThread bypassed the callback for
a potentially pending safepoint and instead called parked upon the
PeriodicTask_lock straight away...
I think this lock should definitely be taken the way you have done in the patch.
I also think the placement of OrderAccess::fence() might have been due to some
of the constructs being racy, take this for instance:
void WatcherThread::start() {
assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required");
if (watcher_thread() == NULL && _startable) { _startable is visible since its
the same thread
_should_terminate = false; <<----------------------------- this is set but
will not be visible to the WatcherThread being launched (it’s a 0 in the
static initializer however, so it is still “safe”)
// Create the single instance of WatcherThread
new WatcherThread();
// above the constructor for WatcherThread will start the thread, and the
WatcherThread::run() might check _should_terminate before the launching thread
releases the PeriodicTask_lock. Not that it will be an issue here, since
_should_terminate is set to 0 in its static initializer. But thanks Dan for
moving this _should_terminate lower in the loop, at least the WatcherThread
will need now need a call to sleep() before reaching it (and sleep needs the
PeriodicTask_lock)
But for the construct in WatcherThread::stop(), there is no need (any more?)
for the OrderAccess::fence(), I think it can be safely removed.
Can you also remove the comment in thread.hpp : 704 that says:
volatile static bool _should_terminate; // updated without holding lock
As this is not the case any longer.
Otherwise it looks good!
Thanks for fixing this
Cheers
Markus
From: Daniel D. Daugherty
Sent: den 17 februari 2015 23:42
To: Carsten Varming
Cc: Alexander Garthwaite; Rickard Bäckman; David Holmes; Markus Grönlund;
Coleen Phillimore; [email protected];
[email protected]
Subject: Re: RFR(XS) for PeriodicTask_lock cleanup (8072439)
On 2/17/15 3:22 PM, Carsten Varming wrote:
Dear Daniel,
Looks good to me.
Thanks for the fast review.
The line: "OrderAccess::fence(); // ensure WatcherThread sees update in main
loop" seems unnecessary as the lock acts as a memory barrier.
Yes, I keep looking at that line from the original work on
JDK-7127792 and wonder why it's there... I'll chase that down
with the original folks...
Dan
Carsten
On Tue, Feb 17, 2015 at 4:44 PM, Daniel D. Daugherty <HYPERLINK
"mailto:[email protected]" \[email protected]> wrote:
Greetings,
My fix for the following bug:
JDK-8047720 Xprof hangs on Solaris
that was pushed to JDK9 last June needs to be cleaned up.
Thanks to Alex Garthwaite (HYPERLINK "mailto:[email protected]"
\[email protected]) and Carsten
Varming (HYPERLINK "mailto:[email protected]" \[email protected]) for
reporting the mess that I made
in WatcherThread::stop() and for suggesting fixes.
This code review is for a general cleanup pass on PeriodicTask_lock
and some of the surrounding code. This is a targeted review in that
I would like to hear from three groups of people:
1) The author and reviewers for:
JDK-7127792 Add the ability to change an existing PeriodicTask's
execution interval
Rickard, David H, and Markus G.
2) The reviewers for:
JDK-8047720 Xprof hangs on Solaris
Markus G and Coleen
3) Alex and Carsten
Here's the webrev URL:
HYPERLINK
"http://cr.openjdk.java.net/%7Edcubed/8072439-webrev/0-for_jdk9_hs_rt/"
\nhttp://cr.openjdk.java.net/~dcubed/8072439-webrev/0-for_jdk9_hs_rt/
I've attached the original RFR for JDK-8047720 that explains
the original deadlock that was being fixed. Similar testing
will be done with this fix.
Dan