RFR: 8181859: Monitor deflation is not checked in cleanup path

Robbin Ehn robbin.ehn at oracle.com
Wed Jun 14 13:22:53 UTC 2017


Hi,

On 06/14/2017 01:01 PM, Carsten Varming wrote:
> The last version looks good to me.

Thanks, but unfortunately there is an error in my calculation.
If the is_cleanup check is run very early gMonitorPopulation is zero resulting in a division by zero.

Incremental:

  static bool monitors_used_above_threshold() {
+  if (gMonitorPopulation == 0) {
+    return false;
+  }


Full: http://cr.openjdk.java.net/~rehn/8181859/5/webrev/

Thanks for bearing with me!

Note:
monitors_used could be wrong since we don't read the values holding gListLock.
So in a very unlikely scenario it could cost a safepoint.

/Robbin

> 
> Carsten
> 
> On Wed, Jun 14, 2017 at 5:40 AM, Robbin Ehn <robbin.ehn at oracle.com <mailto:robbin.ehn at oracle.com>> wrote:
> 
>     Hi Aleksey,
> 
>     On 06/14/2017 11:14 AM, Aleksey Shipilev wrote:
> 
>         On 06/14/2017 11:07 AM, Robbin Ehn wrote:
> 
>             Full:
>             http://cr.openjdk.java.net/~rehn/8181859/2/webrev/ <http://cr.openjdk.java.net/~rehn/8181859/2/webrev/>
> 
> 
>         Looks good to me.
> 
> 
>     Thanks!
> 
> 
>         I would paranoidally add parentheses in this expression, but your choice.
> 
>         return MonitorUsedDeflationThreshold > 0 && (monitors_used * 100LL) /
>         gMonitorPopulation > MonitorUsedDeflationThreshold;
> 
> 
>     Discussed locally and this was suggested (looks good to me):
> 
>     static bool monitors_used_above_threshold() {
>        int monitors_used = gMonitorPopulation - gMonitorFreeCount;
>        int monitor_useage = (monitors_used * 100LL) / gMonitorPopulation;
>        return monitor_useage > MonitorUsedDeflationThreshold;
>     }
> 
>     bool ObjectSynchronizer::is_cleanup_needed() {
>        if (MonitorUsedDeflationThreshold > 0) {
>          return monitors_used_above_threshold();
>        }
>        return false;
>     }
> 
>     Carsten, Aleksey, are you good with this?
> 
>     Full: http://cr.openjdk.java.net/~rehn/8181859/3/webrev/ <http://cr.openjdk.java.net/~rehn/8181859/3/webrev/>
> 
>     Thanks, Robbin
> 
> 
> 
>         Thanks,
>         -Aleksey
> 
> 
> 


More information about the hotspot-runtime-dev mailing list