RFR - 6526682: JConsole shows negative CPU Usage

Nils Loodin nils.loodin at oracle.com
Wed Jun 5 05:51:17 PDT 2013


On 06/01/2013 10:06 AM, Erik Gahlin wrote:
> Nils, do you know why you get a negative number?

Not sure, no. In the screenshot and according to the but it's apparent
that the value is not consistently -1, as it would if it was an error
due to the fact that this is not supported on this platform. The case is
instead that the value sometime drops below zero. I think this is the
same kind of error causing most cpu utlization code I've seen to clamp
it's values between 0 and 100. Since JConsole already does the "not
above 100% check", I think it's fair to introduce the check for the
other case as well.

Regards,
Nisse

>
> As I remember it, the MBean returns -1 if the value is not available on the platform. I think there should be a message that tells the user that
>
> Now it's just a matter of time before somebody files a bug that they got 0% instead of the CPU load they actually have on their machine. The negative value was at least a hint to the user that the value can't be trusted
>
> Erik
>
>
> On 31 maj 2013, at 13:59, Nils Loodin <nils.loodin at oracle.com> wrote:
>
>> Simple fix to not show negative CPU usage in JConsole:
>>
>> http://cr.openjdk.java.net/~nloodin/6526682/webrev.00/
>>
>> Regards,
>> Nils Loodin





More information about the serviceability-dev mailing list