RFR: 8253064: monitor list simplifications and getting rid of TSM [v4]
Coleen Phillimore
coleenp at openjdk.java.net
Tue Nov 10 23:18:59 UTC 2020
On Tue, 10 Nov 2020 22:53:10 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:
>> But contentions is used for more than informing JVMTI, it's used to test whether the monitor is_busy on the slow path. That's why I wanted the comment to say something like your last sentence, since I spent time trying to understand why the various calls to add_to_contentions(-1) in deflate_monitor earlier.
>
> Ahhh... I think I understand your confusion. This line:
>
> L550: // Deferred decrement for the JT EnterI() that cancelled the async deflation.
> L551: add_to_contentions(-1);
>
> doesn't match up with this line:
>
> L361: add_to_contentions(1);
>
> It matches up with one of these:
> if (try_set_owner_from(DEFLATER_MARKER, Self) == DEFLATER_MARKER) {
> // Cancelled the in-progress async deflation by changing owner from
> // DEFLATER_MARKER to Self. As part of the contended enter protocol,
> // contentions was incremented to a positive value before EnterI()
> // was called and that prevents the deflater thread from winning the
> // last part of the 2-part async deflation protocol. After EnterI()
> // returns to enter(), contentions is decremented because the caller
> // now owns the monitor. We bump contentions an extra time here to
> // prevent the deflater thread from winning the last part of the
> // 2-part async deflation protocol after the regular decrement
> // occurs in enter(). The deflater thread will decrement contentions
> // after it recognizes that the async deflation was cancelled.
> add_to_contentions(1);
>
> The long comments are in the two places where we temporarily
> increment contentions to stop the race with the deflater thread
> and the shorter comment, e.g., L550, are for where we undo the
> temporary increment.
>
> The primary purpose of the contentions field is for JVM/TI and
> M&M queries. We just (temporarily) steal it for async deflation
> purposes...
Well since it controls async deflation, it should probably get a mention since this comment on its own is not true:
// Keep track of contention for JVM/TI and M&M queries and control async deflation.
The field _contentions has a good comment.
-------------
PR: https://git.openjdk.java.net/jdk/pull/642
More information about the serviceability-dev
mailing list