< prev index next >

test/hotspot/jtreg/runtime/whitebox/WBStackSize.java

Print this page

        

@@ -19,11 +19,11 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-/*
+/**
  * @test WBStackSize
  * @summary verify that whitebox functions getThreadFullStackSize() and getThreadRemainingStackSize are working
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @build sun.hotspot.WhiteBox

@@ -41,10 +41,11 @@
  *
  * Please file a test bug, if this is a problem.
  */
 
 import sun.hotspot.WhiteBox;
+import jdk.test.lib.Platform;
 
 public class WBStackSize {
 
     static final long K = 1024;
 

@@ -81,23 +82,45 @@
             }
         }
     }
 
     public static void main(String[] args) {
+        long pageSize = wb.getVMPageSize();
+
         long configStackSize = wb.getIntxVMFlag("ThreadStackSize") * K;
         System.out.println("ThreadStackSize VM option: " + configStackSize);
 
-        long stackProtectionSize = wb.getIntxVMFlag("StackShadowPages") * wb.getVMPageSize();
+        long stackProtectionSize = wb.getIntxVMFlag("StackShadowPages") * pageSize;
         System.out.println("Size of protected shadow pages: " + stackProtectionSize);
 
         long actualStackSize = wb.getThreadStackSize();
         System.out.println("Full stack size: " + actualStackSize);
 
+        if (!Platform.isAix()) {
         if (Math.abs(actualStackSize - configStackSize) > configStackSize * 0.1) {
-            throw new RuntimeException("getThreadFullStackSize value [" + actualStackSize
+                throw new RuntimeException("getThreadStackSize value [" + actualStackSize
                                      + "] should be within 90%..110% of ThreadStackSize value");
         }
+        } else {
+            // AIX pthread implementation returns stacks with sizes varying a lot.
+            // We add +64K to assure stacks are not too small, thus we get
+            // even more variation to bigger sizes. So only check the lower bound.
+            // Allow for at least one page deviation.
+            long slack = (long)(configStackSize * 0.1);
+            if (slack < pageSize) {
+                if (configStackSize - actualStackSize > pageSize) {
+                    throw new RuntimeException("getThreadStackSize value [" + actualStackSize
+                                               + "] should not be more than one page smaller than "
+                                               + "ThreadStackSize value");
+                }
+            } else {
+                if (configStackSize - actualStackSize > slack) {
+                    throw new RuntimeException("getThreadStackSize value [" + actualStackSize
+                                               + "] should not be less than 90% of ThreadStackSize value");
+                }
+            }
+        }
 
         long remainingStackSize = wb.getThreadRemainingStackSize();
         System.out.println("Remaining stack size in main(): " + remainingStackSize);
 
         // Up to 150k can be already allocated by VM and some space is used for stack protection.
< prev index next >