RFR: 8328866: Add raw monitor rank support to the debug agent. [v4]
Chris Plummer
cjplummer at openjdk.org
Wed May 8 22:43:53 UTC 2024
On Wed, 8 May 2024 20:10:15 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:
>> I think you are suggesting that all monitors be created up front during util_intialize(). The debug agent in the past has always created them lazily (and sometimes some of them end up never being created because they are not needed). I don't really see a big advantage in creating them all up front.
>>
>> Alex's suggestion was a very different one, and was just a suggestion to initialize all the DebugRawMonitor ranks up front rather than when the jMonitorID is created, and the reason for the suggestion was to avoid having to grab the dbgRawMonitor when setting the rank, but I wasn't convinced that it actually allowed you to not grab the dbgRawMonitor.
>
> I just wanted to say that Alex's suggestion is in a similar direction.
> I do not see a big advantage to save just on creation of a few monitors. It is not a scalability problem as their number is constant. Creation of the monitors at initialization time is a simplification as we do not care about synchronization at this phase. Also, it is easier to understand because there is no interaction with other threads.
The init code would have to know the name of each monitor since it is no longer being passed in. Something like the following might work:
static DebugRawMonitor dbg_monitors[] = {
{ NULL, "JDWP VM_DEATH Lock", vmDeathLockForDebugLoop_Rank, NULL, 0 },
{ NULL, "JDWP Callback Block", callbackBlock_Rank, NULL, 0 },
{ NULL, "JDWP Callback Lock", callbackLock_Rank, NULL, 0 },
...
};
And then the init() function can iterate over the array and allocate the monitor for each entry. Note that this array needs to be kept in sync with the DebugRawMonitorRank enum (same entries and in the same order). I can assert during the initialization that the rank field for each entry is equal to its array index and that the array size is NUM_DEBUG_RAW_MONITORS.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19044#discussion_r1594777084
More information about the serviceability-dev
mailing list