test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java
author pliden
Tue, 12 Jun 2018 17:40:28 +0200
changeset 50525 767cdb97f103
parent 47216 71c04702a3d5
child 51287 7b1ddbafa134
permissions -rw-r--r--
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental) Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke Contributed-by: per.liden@oracle.com, stefan.karlsson@oracle.com, erik.osterlund@oracle.com, mikael.gerdin@oracle.com, kim.barrett@oracle.com, nils.eliasson@oracle.com, rickard.backman@oracle.com, rwestrel@redhat.com, coleen.phillimore@oracle.com, robbin.ehn@oracle.com, gerard.ziemski@oracle.com, hugh.wilkinson@intel.com, sandhya.viswanathan@intel.com, bill.npo.wheeler@intel.com, vinay.k.awasthi@intel.com, yasuenag@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20400
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
20400
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     4
 *
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     8
 *
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    13
 * accompanied this code).
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    14
 *
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    18
 *
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    21
 * questions.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    22
 */
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    23
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    24
/* @test TestLargePagesFlags
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    25
 * @summary Tests how large pages are choosen depending on the given large pages flag combinations.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 47216
diff changeset
    26
 * @requires vm.gc != "Z"
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    27
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 30604
diff changeset
    28
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 20400
diff changeset
    29
 *          java.management
20400
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    30
 * @run main TestLargePagesFlags
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    31
 */
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    32
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    33
import jdk.test.lib.process.OutputAnalyzer;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    34
import jdk.test.lib.Platform;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    35
import jdk.test.lib.process.ProcessTools;
20400
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    36
import java.util.ArrayList;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    37
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    38
public class TestLargePagesFlags {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    39
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    40
  public static void main(String [] args) throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    41
    if (!Platform.isLinux()) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    42
      System.out.println("Skipping. TestLargePagesFlags has only been implemented for Linux.");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    43
      return;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    44
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    45
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    46
    testUseTransparentHugePages();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    47
    testUseHugeTLBFS();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    48
    testUseSHM();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    49
    testCombinations();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    50
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    51
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    52
  public static void testUseTransparentHugePages() throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    53
    if (!canUse(UseTransparentHugePages(true))) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    54
      System.out.println("Skipping testUseTransparentHugePages");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    55
      return;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    56
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    57
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    58
    // -XX:-UseLargePages overrides all other flags.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    59
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    60
      .use(UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    61
           UseTransparentHugePages(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    62
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    63
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    64
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    65
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    66
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    67
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    68
    // Explicitly turn on UseTransparentHugePages.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    69
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    70
      .use(UseTransparentHugePages(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    71
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    72
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    73
           UseTransparentHugePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    74
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    75
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    76
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    77
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    78
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    79
           UseTransparentHugePages(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    80
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    81
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    82
           UseTransparentHugePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    83
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    84
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    85
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    86
    // Setting a specific large pages flag will turn
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    87
    // off heuristics to choose large pages type.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    88
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    89
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    90
           UseTransparentHugePages(false))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    91
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    92
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    93
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    94
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    95
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    96
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    97
    // Don't turn on UseTransparentHugePages
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    98
    // unless the user explicitly asks for them.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
    99
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   100
      .use(UseLargePages(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   101
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   102
           UseTransparentHugePages(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   103
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   104
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   105
  public static void testUseHugeTLBFS() throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   106
    if (!canUse(UseHugeTLBFS(true))) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   107
      System.out.println("Skipping testUseHugeTLBFS");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   108
      return;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   109
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   110
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   111
    // -XX:-UseLargePages overrides all other flags.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   112
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   113
      .use(UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   114
           UseHugeTLBFS(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   115
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   116
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   117
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   118
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   119
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   120
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   121
    // Explicitly turn on UseHugeTLBFS.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   122
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   123
      .use(UseHugeTLBFS(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   124
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   125
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   126
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   127
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   128
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   129
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   130
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   131
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   132
           UseHugeTLBFS(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   133
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   134
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   135
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   136
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   137
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   138
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   139
    // Setting a specific large pages flag will turn
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   140
    // off heuristics to choose large pages type.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   141
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   142
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   143
           UseHugeTLBFS(false))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   144
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   145
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   146
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   147
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   148
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   149
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   150
    // Using UseLargePages will default to UseHugeTLBFS large pages.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   151
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   152
      .use(UseLargePages(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   153
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   154
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   155
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   156
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   157
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   158
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   159
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   160
  public static void testUseSHM() throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   161
    if (!canUse(UseSHM(true))) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   162
      System.out.println("Skipping testUseSHM");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   163
      return;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   164
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   165
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   166
    // -XX:-UseLargePages overrides all other flags.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   167
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   168
      .use(UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   169
           UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   170
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   171
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   172
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   173
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   174
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   175
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   176
    // Explicitly turn on UseSHM.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   177
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   178
      .use(UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   179
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   180
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   181
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   182
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   183
           UseSHM(true)) ;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   184
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   185
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   186
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   187
           UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   188
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   189
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   190
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   191
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   192
           UseSHM(true)) ;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   193
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   194
    // Setting a specific large pages flag will turn
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   195
    // off heuristics to choose large pages type.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   196
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   197
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   198
           UseSHM(false))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   199
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   200
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   201
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   202
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   203
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   204
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   205
    // Setting UseLargePages can allow the system to choose
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   206
    // UseHugeTLBFS instead of UseSHM, but never UseTransparentHugePages.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   207
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   208
      .use(UseLargePages(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   209
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   210
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   211
           UseTransparentHugePages(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   212
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   213
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   214
  public static void testCombinations() throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   215
    if (!canUse(UseSHM(true)) || !canUse(UseHugeTLBFS(true))) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   216
      System.out.println("Skipping testUseHugeTLBFSAndUseSHMCombination");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   217
      return;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   218
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   219
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   220
    // UseHugeTLBFS takes precedence over SHM.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   221
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   222
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   223
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   224
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   225
           UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   226
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   227
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   228
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   229
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   230
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   231
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   232
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   233
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   234
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   235
           UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   236
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   237
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   238
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   239
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   240
           UseSHM(true));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   241
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   242
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   243
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   244
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   245
           UseSHM(false))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   246
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   247
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   248
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   249
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   250
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   251
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   252
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   253
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   254
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   255
           UseSHM(false))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   256
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   257
           UseLargePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   258
           UseTransparentHugePages(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   259
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   260
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   261
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   262
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   263
    if (!canUse(UseTransparentHugePages(true))) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   264
      return;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   265
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   266
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   267
    // UseTransparentHugePages takes precedence.
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   268
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   269
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   270
      .use(UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   271
           UseTransparentHugePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   272
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   273
           UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   274
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   275
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   276
           UseTransparentHugePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   277
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   278
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   279
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   280
    new FlagTester()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   281
      .use(UseTransparentHugePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   282
           UseHugeTLBFS(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   283
           UseSHM(true))
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   284
      .expect(
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   285
           UseLargePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   286
           UseTransparentHugePages(true),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   287
           UseHugeTLBFS(false),
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   288
           UseSHM(false));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   289
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   290
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   291
  private static class FlagTester {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   292
    private Flag [] useFlags;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   293
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   294
    public FlagTester use(Flag... useFlags) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   295
      this.useFlags = useFlags;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   296
      return this;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   297
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   298
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   299
    public void expect(Flag... expectedFlags) throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   300
      if (useFlags == null) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   301
        throw new IllegalStateException("Must run use() before expect()");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   302
      }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   303
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   304
      OutputAnalyzer output = executeNewJVM(useFlags);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   305
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   306
      for (Flag flag : expectedFlags) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   307
        System.out.println("Looking for: " + flag.flagString());
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   308
        String strValue = output.firstMatch(".* " + flag.name() +  " .* :?= (\\S+).*", 1);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   309
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   310
        if (strValue == null) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   311
          throw new RuntimeException("Flag " + flag.name() + " couldn't be found");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   312
        }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   313
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   314
        if (!flag.value().equals(strValue)) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   315
          throw new RuntimeException("Wrong value for: " + flag.name()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   316
                                     + " expected: " + flag.value()
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   317
                                     + " got: " + strValue);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   318
        }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   319
      }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   320
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   321
      output.shouldHaveExitValue(0);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   322
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   323
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   324
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   325
  private static OutputAnalyzer executeNewJVM(Flag... flags) throws Exception {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   326
    ArrayList<String> args = new ArrayList<>();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   327
    for (Flag flag : flags) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   328
      args.add(flag.flagString());
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   329
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   330
    args.add("-XX:+PrintFlagsFinal");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   331
    args.add("-version");
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   332
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   333
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   334
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   335
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   336
    return output;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   337
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   338
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   339
  private static boolean canUse(Flag flag) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   340
    try {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   341
      new FlagTester().use(flag).expect(flag);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   342
    } catch (Exception e) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   343
      return false;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   344
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   345
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   346
    return true;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   347
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   348
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   349
  private static Flag UseLargePages(boolean value) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   350
    return new BooleanFlag("UseLargePages", value);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   351
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   352
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   353
  private static Flag UseTransparentHugePages(boolean value) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   354
    return new BooleanFlag("UseTransparentHugePages", value);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   355
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   356
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   357
  private static Flag UseHugeTLBFS(boolean value) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   358
    return new BooleanFlag("UseHugeTLBFS", value);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   359
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   360
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   361
  private static Flag UseSHM(boolean value) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   362
    return new BooleanFlag("UseSHM", value);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   363
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   364
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   365
  private static class BooleanFlag implements Flag {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   366
    private String name;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   367
    private boolean value;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   368
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   369
    BooleanFlag(String name, boolean value) {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   370
      this.name = name;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   371
      this.value = value;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   372
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   373
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   374
    public String flagString() {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   375
      return "-XX:" + (value ? "+" : "-") + name;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   376
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   377
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   378
    public String name() {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   379
      return name;
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   380
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   381
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   382
    public String value() {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   383
      return Boolean.toString(value);
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   384
    }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   385
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   386
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   387
  private static interface Flag {
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   388
    public String flagString();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   389
    public String name();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   390
    public String value();
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   391
  }
1c658ebcb3c1 8024838: Significant slowdown due to transparent huge pages
stefank
parents:
diff changeset
   392
}