RFR: 8334904: Add some perf counters to monitor the usage of VM locks [v2]

David Holmes dholmes at openjdk.org
Tue Jul 16 04:54:53 UTC 2024


On Fri, 12 Jul 2024 00:34:37 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

>> src/hotspot/share/runtime/mutexLocker.cpp line 410:
>> 
>>> 408:       NEWPERFEVENTCOUNTER(_perf_lock_hold_time[i + 1], SUN_RT, PerfDataManager::counter_name(counter_name, "AfterTime"));
>>> 409:     }
>>> 410:     if (HAS_PENDING_EXCEPTION) {
>> 
>> What code above could raise a Java exception??? I'm not sure the VM is initialized enough to throw an exception when this is called.
>
> `NEWPERFEVENTCOUNTER` calls into the following which may throw an exception
> 
> 
> PerfLongCounter* PerfDataManager::create_long_counter(CounterNS ns,
>                                                       const char* name,
>                                                       PerfData::Units u,
>                                                       jlong ival, TRAPS) {
> 
>   PerfLongCounter* p = new PerfLongCounter(ns, name, u, ival);
> 
>   if (!p->is_valid()) {
>     // allocation of native resources failed.
>     delete p;
>     THROW_0(vmSymbols::java_lang_OutOfMemoryError());
>   }

But the macro is defined as:

#define NEWPERFEVENTCOUNTER(counter, counter_ns, counter_name)  \
  {counter = PerfDataManager::create_counter(counter_ns, counter_name, \
                                             PerfData::U_Events,CHECK);}

and so any exception will cause a return due to the CHECK macro

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19954#discussion_r1678748042


More information about the hotspot-runtime-dev mailing list