hotspot/test/runtime/NMT/MallocSiteHashOverflow.java
author gtriantafill
Tue, 12 Aug 2014 14:06:41 -0700
changeset 25952 25c2dca04a31
child 26302 e3228e31a08d
permissions -rw-r--r--
8054952: [TESTBUG] Add missing NMT2 tests Summary: The new NMT2 tests got lost on the way into jdk9 yesterday, this change adds them. Reviewed-by: coleenp, zgu, ctornqvi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25952
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     1
/*
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     4
 *
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     7
 * published by the Free Software Foundation.
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     8
 *
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    13
 * accompanied this code).
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    14
 *
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    18
 *
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    21
 * questions.
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    22
 */
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    23
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    24
/*
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    25
 * @key stress
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    26
 * @test
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    27
 * @summary Test corner case that overflows malloc site hashtable bucket
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    28
 * @key nmt jcmd
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    29
 * @library /testlibrary /testlibrary/whitebox
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    30
 * @ignore - This test is disabled since it will stress NMT and timeout during normal testing
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    31
 * @build MallocSiteHashOverflow
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    32
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    33
 * @run main/othervm/timeout=480 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocSiteHashOverflow
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    34
 */
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    35
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    36
import com.oracle.java.testlibrary.*;
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    37
import sun.hotspot.WhiteBox;
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    38
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    39
public class MallocSiteHashOverflow {
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    40
    private static long K = 1024;
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    41
    public static void main(String args[]) throws Exception {
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    42
        String vm_name = System.getProperty("java.vm.name");
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    43
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    44
        // For 32-bit systems, create 257 malloc sites with the same hash bucket to overflow a hash bucket
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    45
        // For 64-bit systems, create 64K + 1 malloc sites with the same hash bucket to overflow a hash bucket
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    46
        long entries = 257;
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    47
        if (Platform.is64bit()) {
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    48
            entries = 64 * K + 1;
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    49
        }
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    50
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    51
        OutputAnalyzer output;
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    52
        WhiteBox wb = WhiteBox.getWhiteBox();
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    53
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    54
        // Grab my own PID
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    55
        String pid = Integer.toString(ProcessTools.getProcessId());
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    56
        ProcessBuilder pb = new ProcessBuilder();
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    57
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    58
        wb.NMTOverflowHashBucket(entries);
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    59
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    60
        // Run 'jcmd <pid> VM.native_memory summary'
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    61
        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "statistics"});
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    62
        output = new OutputAnalyzer(pb.start());
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    63
        output.shouldContain("Tracking level has been downgraded due to lack of resources");
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    64
    }
25c2dca04a31 8054952: [TESTBUG] Add missing NMT2 tests
gtriantafill
parents:
diff changeset
    65
}