8148766: Test AvailableProcessors.java got wrong number of processors
authordholmes
Tue, 02 Feb 2016 05:38:33 -0500
changeset 35906 1eed370d39f9
parent 35905 7a7ad93cf358
child 35910 73277e369d4b
child 35911 80dd27ae501c
8148766: Test AvailableProcessors.java got wrong number of processors Reviewed-by: dsamersoff, tschatzl, mseledtsov
hotspot/test/runtime/os/AvailableProcessors.java
--- a/hotspot/test/runtime/os/AvailableProcessors.java	Tue Feb 02 09:51:24 2016 +0100
+++ b/hotspot/test/runtime/os/AvailableProcessors.java	Tue Feb 02 05:38:33 2016 -0500
@@ -27,7 +27,7 @@
 
 /*
  * @test
- * @bug 6515172
+ * @bug 6515172 8148766
  * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux
  * @requires os.family == "linux"
  * @library /testlibrary
@@ -93,7 +93,9 @@
 
     static void checkProcessors(int expected) {
         int available = Runtime.getRuntime().availableProcessors();
-        if (available != expected)
+        // available can dynamically drop below expected due to aggressive power management
+        // but we should never have more than expected, else taskset is broken
+        if (available <= 0 || available > expected)
             throw new Error("Expected " + expected + " processors, but found "
                             + available);
         else