Merge

Thu, 16 Feb 2017 13:21:41 -0800

author
asaha
date
Thu, 16 Feb 2017 13:21:41 -0800
changeset 8929
b1b140f0c504
parent 8917
e49557628945
parent 8928
c468dc338392
child 8934
268b63233d3e

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Mon Jan 23 17:09:40 2017 -0800
     1.2 +++ b/.hgtags	Thu Feb 16 13:21:41 2017 -0800
     1.3 @@ -931,6 +931,8 @@
     1.4  b28d012a24cab8f4ceeee0c9d3252969757423ed jdk8u112-b15
     1.5  e134dc1879b72124e478be01680b0646a2fbf585 jdk8u112-b16
     1.6  87440ed4e1de7753a436f957d35555d8b4e26f1d jdk8u112-b31
     1.7 +ba25f5833a128b8062e597f794efda26b30f095d jdk8u112-b32
     1.8 +919ffdca10c2721ee0f6f233e704709174556510 jdk8u112-b33
     1.9  3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00
    1.10  251a2493b1857f2ff4f11eab2dfd8b2fe8ed441b jdk8u121-b01
    1.11  70c4a50f576a01ec975d0a02b3642ee33db39ed8 jdk8u121-b02
    1.12 @@ -945,10 +947,14 @@
    1.13  11f91811e4d7e5ddfaf938dcf386ec8fe5bf7b7c jdk8u121-b11
    1.14  b132b08b28bf23a26329928cf6b4ffda5857f4d3 jdk8u121-b12
    1.15  90f94521c3515e5f27af0ab9b31d036e88bb322a jdk8u121-b13
    1.16 +351bf1d4ff9a41137f91e2ec97ec59ed29a38d8b jdk8u121-b31
    1.17 +41daac438a2ac5a80755dc3de88b76e4ac66750a jdk8u121-b32
    1.18  c0a1ba0df20fda10ddb8599e888eb56ad98b3874 jdk8u131-b00
    1.19  0b85ccd6240991e1a501602ff5addec6b88ae0af jdk8u131-b01
    1.20  ef90c721a4e59b01ca36f25619010a1afe9ed4d5 jdk8u131-b02
    1.21  0ca47d0811b01ecf8651b6045a1e33a4a9bed0ee jdk8u131-b03
    1.22  dab1d597165207e14b6886b1823c1e990bc776a3 jdk8u131-b04
    1.23 +c965fc1aa840a0903709ad69aa0e2100330ccd84 jdk8u131-b05
    1.24 +6e4cfbc7534f83902692132efb61683528c04a59 jdk8u131-b06
    1.25  692bc6b674dcab72453de08ee9da0856a7e41c0f jdk8u141-b00
    1.26  2d5100bddeb80cf767485b787fc3051311e3d7b9 jdk8u151-b00
     2.1 --- a/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Mon Jan 23 17:09:40 2017 -0800
     2.2 +++ b/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Thu Feb 16 13:21:41 2017 -0800
     2.3 @@ -4261,6 +4261,7 @@
     2.4    assert(UseBlockZeroing && VM_Version::has_block_zeroing(), "only works with BIS zeroing");
     2.5    Register end = count;
     2.6    int cache_line_size = VM_Version::prefetch_data_size();
     2.7 +  assert(cache_line_size > 0, "cache line size should be known for this code");
     2.8    // Minimum count when BIS zeroing can be used since
     2.9    // it needs membar which is expensive.
    2.10    int block_zero_size  = MAX2(cache_line_size*3, (int)BlockZeroingLowLimit);
     3.1 --- a/src/cpu/sparc/vm/vm_version_sparc.cpp	Mon Jan 23 17:09:40 2017 -0800
     3.2 +++ b/src/cpu/sparc/vm/vm_version_sparc.cpp	Thu Feb 16 13:21:41 2017 -0800
     3.3 @@ -74,7 +74,7 @@
     3.4      AllocatePrefetchDistance = AllocatePrefetchStepSize;
     3.5    }
     3.6  
     3.7 -  if (AllocatePrefetchStyle == 3 && !has_blk_init()) {
     3.8 +  if (AllocatePrefetchStyle == 3 && (!has_blk_init() || cache_line_size <= 0)) {
     3.9      warning("BIS instructions are not available on this CPU");
    3.10      FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
    3.11    }
    3.12 @@ -138,7 +138,7 @@
    3.13        FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
    3.14      }
    3.15      if (is_niagara_plus()) {
    3.16 -      if (has_blk_init() && UseTLAB &&
    3.17 +      if (has_blk_init() && (cache_line_size > 0) && UseTLAB &&
    3.18            FLAG_IS_DEFAULT(AllocatePrefetchInstr)) {
    3.19          // Use BIS instruction for TLAB allocation prefetch.
    3.20          FLAG_SET_ERGO(intx, AllocatePrefetchInstr, 1);
     4.1 --- a/src/os/linux/vm/globals_linux.hpp	Mon Jan 23 17:09:40 2017 -0800
     4.2 +++ b/src/os/linux/vm/globals_linux.hpp	Thu Feb 16 13:21:41 2017 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -47,7 +47,10 @@
    4.11            "Load DLLs with executable-stack attribute in the VM Thread") \
    4.12                                                                          \
    4.13    product(bool, UseSHM, false,                                          \
    4.14 -          "Use SYSV shared memory for large pages")
    4.15 +          "Use SYSV shared memory for large pages")                     \
    4.16 +                                                                        \
    4.17 +  diagnostic(bool, PrintActiveCpus, false,                              \
    4.18 +          "Print the number of CPUs detected in os::active_processor_count")
    4.19  
    4.20  //
    4.21  // Defines Linux-specific default values. The flags are available on all
     5.1 --- a/src/os/linux/vm/os_linux.cpp	Mon Jan 23 17:09:40 2017 -0800
     5.2 +++ b/src/os/linux/vm/os_linux.cpp	Thu Feb 16 13:21:41 2017 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -104,6 +104,14 @@
    5.11  
    5.12  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    5.13  
    5.14 +#ifndef _GNU_SOURCE
    5.15 +  #define _GNU_SOURCE
    5.16 +  #include <sched.h>
    5.17 +  #undef _GNU_SOURCE
    5.18 +#else
    5.19 +  #include <sched.h>
    5.20 +#endif
    5.21 +
    5.22  // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
    5.23  // getrusage() is prepared to handle the associated failure.
    5.24  #ifndef RUSAGE_THREAD
    5.25 @@ -1067,29 +1075,30 @@
    5.26  
    5.27  // Locate initial thread stack. This special handling of initial thread stack
    5.28  // is needed because pthread_getattr_np() on most (all?) Linux distros returns
    5.29 -// bogus value for initial thread.
    5.30 +// bogus value for the primordial process thread. While the launcher has created
    5.31 +// the VM in a new thread since JDK 6, we still have to allow for the use of the
    5.32 +// JNI invocation API from a primordial thread.
    5.33  void os::Linux::capture_initial_stack(size_t max_size) {
    5.34 -  // stack size is the easy part, get it from RLIMIT_STACK
    5.35 -  size_t stack_size;
    5.36 +
    5.37 +  // max_size is either 0 (which means accept OS default for thread stacks) or
    5.38 +  // a user-specified value known to be at least the minimum needed. If we
    5.39 +  // are actually on the primordial thread we can make it appear that we have a
    5.40 +  // smaller max_size stack by inserting the guard pages at that location. But we
    5.41 +  // cannot do anything to emulate a larger stack than what has been provided by
    5.42 +  // the OS or threading library. In fact if we try to use a stack greater than
    5.43 +  // what is set by rlimit then we will crash the hosting process.
    5.44 +
    5.45 +  // Maximum stack size is the easy part, get it from RLIMIT_STACK.
    5.46 +  // If this is "unlimited" then it will be a huge value.
    5.47    struct rlimit rlim;
    5.48    getrlimit(RLIMIT_STACK, &rlim);
    5.49 -  stack_size = rlim.rlim_cur;
    5.50 +  size_t stack_size = rlim.rlim_cur;
    5.51  
    5.52    // 6308388: a bug in ld.so will relocate its own .data section to the
    5.53    //   lower end of primordial stack; reduce ulimit -s value a little bit
    5.54    //   so we won't install guard page on ld.so's data section.
    5.55    stack_size -= 2 * page_size();
    5.56  
    5.57 -  // 4441425: avoid crash with "unlimited" stack size on SuSE 7.1 or Redhat
    5.58 -  //   7.1, in both cases we will get 2G in return value.
    5.59 -  // 4466587: glibc 2.2.x compiled w/o "--enable-kernel=2.4.0" (RH 7.0,
    5.60 -  //   SuSE 7.2, Debian) can not handle alternate signal stack correctly
    5.61 -  //   for initial thread if its stack size exceeds 6M. Cap it at 2M,
    5.62 -  //   in case other parts in glibc still assumes 2M max stack size.
    5.63 -  // FIXME: alt signal stack is gone, maybe we can relax this constraint?
    5.64 -  // Problem still exists RH7.2 (IA64 anyway) but 2MB is a little small
    5.65 -  if (stack_size > 2 * K * K IA64_ONLY(*2))
    5.66 -      stack_size = 2 * K * K IA64_ONLY(*2);
    5.67    // Try to figure out where the stack base (top) is. This is harder.
    5.68    //
    5.69    // When an application is started, glibc saves the initial stack pointer in
    5.70 @@ -1249,14 +1258,18 @@
    5.71    // stack_top could be partially down the page so align it
    5.72    stack_top = align_size_up(stack_top, page_size());
    5.73  
    5.74 -  if (max_size && stack_size > max_size) {
    5.75 -     _initial_thread_stack_size = max_size;
    5.76 +  // Allowed stack value is minimum of max_size and what we derived from rlimit
    5.77 +  if (max_size > 0) {
    5.78 +    _initial_thread_stack_size = MIN2(max_size, stack_size);
    5.79    } else {
    5.80 -     _initial_thread_stack_size = stack_size;
    5.81 +    // Accept the rlimit max, but if stack is unlimited then it will be huge, so
    5.82 +    // clamp it at 8MB as we do on Solaris
    5.83 +    _initial_thread_stack_size = MIN2(stack_size, 8*M);
    5.84    }
    5.85  
    5.86    _initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size());
    5.87    _initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
    5.88 +  assert(_initial_thread_stack_bottom < (address)stack_top, "overflow!");
    5.89  }
    5.90  
    5.91  ////////////////////////////////////////////////////////////////////////////////
    5.92 @@ -5016,12 +5029,42 @@
    5.93    }
    5.94  };
    5.95  
    5.96 +static int os_cpu_count(const cpu_set_t* cpus) {
    5.97 +  int count = 0;
    5.98 +  // only look up to the number of configured processors
    5.99 +  for (int i = 0; i < os::processor_count(); i++) {
   5.100 +    if (CPU_ISSET(i, cpus)) {
   5.101 +      count++;
   5.102 +    }
   5.103 +  }
   5.104 +  return count;
   5.105 +}
   5.106 +
   5.107 +// Get the current number of available processors for this process.
   5.108 +// This value can change at any time during a process's lifetime.
   5.109 +// sched_getaffinity gives an accurate answer as it accounts for cpusets.
   5.110 +// If anything goes wrong we fallback to returning the number of online
   5.111 +// processors - which can be greater than the number available to the process.
   5.112  int os::active_processor_count() {
   5.113 -  // Linux doesn't yet have a (official) notion of processor sets,
   5.114 -  // so just return the number of online processors.
   5.115 -  int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
   5.116 -  assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
   5.117 -  return online_cpus;
   5.118 +  cpu_set_t cpus;  // can represent at most 1024 (CPU_SETSIZE) processors
   5.119 +  int cpus_size = sizeof(cpu_set_t);
   5.120 +  int cpu_count = 0;
   5.121 +
   5.122 +  // pid 0 means the current thread - which we have to assume represents the process
   5.123 +  if (sched_getaffinity(0, cpus_size, &cpus) == 0) {
   5.124 +    cpu_count = os_cpu_count(&cpus);
   5.125 +    if (PrintActiveCpus) {
   5.126 +      tty->print_cr("active_processor_count: sched_getaffinity processor count: %d", cpu_count);
   5.127 +    }
   5.128 +  }
   5.129 +  else {
   5.130 +    cpu_count = ::sysconf(_SC_NPROCESSORS_ONLN);
   5.131 +    warning("sched_getaffinity failed (%s)- using online processor count (%d) "
   5.132 +            "which may exceed available processors", strerror(errno), cpu_count);
   5.133 +  }
   5.134 +
   5.135 +  assert(cpu_count > 0 && cpu_count <= processor_count(), "sanity check");
   5.136 +  return cpu_count;
   5.137  }
   5.138  
   5.139  void os::set_native_thread_name(const char *name) {
     6.1 --- a/src/share/vm/classfile/systemDictionary.cpp	Mon Jan 23 17:09:40 2017 -0800
     6.2 +++ b/src/share/vm/classfile/systemDictionary.cpp	Thu Feb 16 13:21:41 2017 -0800
     6.3 @@ -1084,15 +1084,18 @@
     6.4                                                               THREAD);
     6.5  
     6.6    const char* pkg = "java/";
     6.7 +  size_t pkglen = strlen(pkg);
     6.8    if (!HAS_PENDING_EXCEPTION &&
     6.9        !class_loader.is_null() &&
    6.10        parsed_name != NULL &&
    6.11 -      !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) {
    6.12 +      parsed_name->utf8_length() >= (int)pkglen &&
    6.13 +      !strncmp((const char*)parsed_name->bytes(), pkg, pkglen)) {
    6.14      // It is illegal to define classes in the "java." package from
    6.15      // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader
    6.16      ResourceMark rm(THREAD);
    6.17      char* name = parsed_name->as_C_string();
    6.18      char* index = strrchr(name, '/');
    6.19 +    assert(index != NULL, "must be");
    6.20      *index = '\0'; // chop to just the package name
    6.21      while ((index = strchr(name, '/')) != NULL) {
    6.22        *index = '.'; // replace '/' with '.' in package name
     7.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Mon Jan 23 17:09:40 2017 -0800
     7.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Feb 16 13:21:41 2017 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -631,11 +631,10 @@
    7.11        double overall_cm_overhead =
    7.12          (double) MaxGCPauseMillis * marking_overhead /
    7.13          (double) GCPauseIntervalMillis;
    7.14 -      double cpu_ratio = 1.0 / (double) os::processor_count();
    7.15 +      double cpu_ratio = 1.0 / os::initial_active_processor_count();
    7.16        double marking_thread_num = ceil(overall_cm_overhead / cpu_ratio);
    7.17        double marking_task_overhead =
    7.18 -        overall_cm_overhead / marking_thread_num *
    7.19 -                                                (double) os::processor_count();
    7.20 +        overall_cm_overhead / marking_thread_num * os::initial_active_processor_count();
    7.21        double sleep_factor =
    7.22                           (1.0 - marking_task_overhead) / marking_task_overhead;
    7.23  
     8.1 --- a/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Mon Jan 23 17:09:40 2017 -0800
     8.2 +++ b/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Thu Feb 16 13:21:41 2017 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  /*
     8.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     8.6 + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     8.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8   *
     8.9   * This code is free software; you can redistribute it and/or modify it
    8.10 @@ -80,7 +80,7 @@
    8.11  
    8.12  // Determines how many mutator threads can process the buffers in parallel.
    8.13  uint DirtyCardQueueSet::num_par_ids() {
    8.14 -  return (uint)os::processor_count();
    8.15 +  return (uint)os::initial_active_processor_count();
    8.16  }
    8.17  
    8.18  void DirtyCardQueueSet::initialize(CardTableEntryClosure* cl, Monitor* cbl_mon, Mutex* fl_lock,
     9.1 --- a/src/share/vm/opto/cfgnode.hpp	Mon Jan 23 17:09:40 2017 -0800
     9.2 +++ b/src/share/vm/opto/cfgnode.hpp	Thu Feb 16 13:21:41 2017 -0800
     9.3 @@ -119,6 +119,9 @@
     9.4  // input in slot 0.
     9.5  class PhiNode : public TypeNode {
     9.6    const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes.
     9.7 +  // The following fields are only used for data PhiNodes to indicate
     9.8 +  // that the PhiNode represents the value of a known instance field.
     9.9 +        int _inst_mem_id; // Instance memory id (node index of the memory Phi)
    9.10    const int _inst_id;     // Instance id of the memory slice.
    9.11    const int _inst_index;  // Alias index of the instance memory slice.
    9.12    // Array elements references have the same alias_idx but different offset.
    9.13 @@ -138,11 +141,13 @@
    9.14    };
    9.15  
    9.16    PhiNode( Node *r, const Type *t, const TypePtr* at = NULL,
    9.17 +           const int imid = -1,
    9.18             const int iid = TypeOopPtr::InstanceTop,
    9.19             const int iidx = Compile::AliasIdxTop,
    9.20             const int ioffs = Type::OffsetTop )
    9.21      : TypeNode(t,r->req()),
    9.22        _adr_type(at),
    9.23 +      _inst_mem_id(imid),
    9.24        _inst_id(iid),
    9.25        _inst_index(iidx),
    9.26        _inst_offset(ioffs)
    9.27 @@ -187,11 +192,14 @@
    9.28    virtual bool pinned() const { return in(0) != 0; }
    9.29    virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
    9.30  
    9.31 +  void  set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; }
    9.32 +  const int inst_mem_id() const { return _inst_mem_id; }
    9.33    const int inst_id()     const { return _inst_id; }
    9.34    const int inst_index()  const { return _inst_index; }
    9.35    const int inst_offset() const { return _inst_offset; }
    9.36 -  bool is_same_inst_field(const Type* tp, int id, int index, int offset) {
    9.37 +  bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) {
    9.38      return type()->basic_type() == tp->basic_type() &&
    9.39 +           inst_mem_id() == mem_id &&
    9.40             inst_id()     == id     &&
    9.41             inst_index()  == index  &&
    9.42             inst_offset() == offset &&
    10.1 --- a/src/share/vm/opto/macro.cpp	Mon Jan 23 17:09:40 2017 -0800
    10.2 +++ b/src/share/vm/opto/macro.cpp	Thu Feb 16 13:21:41 2017 -0800
    10.3 @@ -401,7 +401,7 @@
    10.4    for (DUIterator_Fast kmax, k = region->fast_outs(kmax); k < kmax; k++) {
    10.5      Node* phi = region->fast_out(k);
    10.6      if (phi->is_Phi() && phi != mem &&
    10.7 -        phi->as_Phi()->is_same_inst_field(phi_type, instance_id, alias_idx, offset)) {
    10.8 +        phi->as_Phi()->is_same_inst_field(phi_type, (int)mem->_idx, instance_id, alias_idx, offset)) {
    10.9        return phi;
   10.10      }
   10.11    }
   10.12 @@ -420,7 +420,7 @@
   10.13    GrowableArray <Node *> values(length, length, NULL, false);
   10.14  
   10.15    // create a new Phi for the value
   10.16 -  PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, instance_id, alias_idx, offset);
   10.17 +  PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, mem->_idx, instance_id, alias_idx, offset);
   10.18    transform_later(phi);
   10.19    value_phis->push(phi, mem->_idx);
   10.20  
    11.1 --- a/src/share/vm/opto/memnode.cpp	Mon Jan 23 17:09:40 2017 -0800
    11.2 +++ b/src/share/vm/opto/memnode.cpp	Thu Feb 16 13:21:41 2017 -0800
    11.3 @@ -1155,7 +1155,7 @@
    11.4      for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
    11.5        Node* phi = region->fast_out(i);
    11.6        if (phi->is_Phi() && phi != mem &&
    11.7 -          phi->as_Phi()->is_same_inst_field(this_type, this_iid, this_index, this_offset)) {
    11.8 +          phi->as_Phi()->is_same_inst_field(this_type, (int)mem->_idx, this_iid, this_index, this_offset)) {
    11.9          return phi;
   11.10        }
   11.11      }
   11.12 @@ -1400,7 +1400,7 @@
   11.13      this_iid = base->_idx;
   11.14    }
   11.15    PhaseIterGVN* igvn = phase->is_IterGVN();
   11.16 -  Node* phi = new (C) PhiNode(region, this_type, NULL, this_iid, this_index, this_offset);
   11.17 +  Node* phi = new (C) PhiNode(region, this_type, NULL, mem->_idx, this_iid, this_index, this_offset);
   11.18    for (uint i = 1; i < region->req(); i++) {
   11.19      Node* x;
   11.20      Node* the_clone = NULL;
    12.1 --- a/src/share/vm/opto/phaseX.cpp	Mon Jan 23 17:09:40 2017 -0800
    12.2 +++ b/src/share/vm/opto/phaseX.cpp	Thu Feb 16 13:21:41 2017 -0800
    12.3 @@ -481,6 +481,8 @@
    12.4    uint current_idx = 0; // The current new node ID. Incremented after every assignment.
    12.5    for (uint i = 0; i < _useful.size(); i++) {
    12.6      Node* n = _useful.at(i);
    12.7 +    // Sanity check that fails if we ever decide to execute this phase after EA
    12.8 +    assert(!n->is_Phi() || n->as_Phi()->inst_mem_id() == -1, "should not be linked to data Phi");
    12.9      const Type* type = gvn->type_or_null(n);
   12.10      new_type_array.map(current_idx, type);
   12.11  
   12.12 @@ -1378,6 +1380,18 @@
   12.13      i -= num_edges;    // we deleted 1 or more copies of this edge
   12.14    }
   12.15  
   12.16 +  // Search for instance field data PhiNodes in the same region pointing to the old
   12.17 +  // memory PhiNode and update their instance memory ids to point to the new node.
   12.18 +  if (old->is_Phi() && old->as_Phi()->type()->has_memory() && old->in(0) != NULL) {
   12.19 +    Node* region = old->in(0);
   12.20 +    for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
   12.21 +      PhiNode* phi = region->fast_out(i)->isa_Phi();
   12.22 +      if (phi != NULL && phi->inst_mem_id() == (int)old->_idx) {
   12.23 +        phi->set_inst_mem_id((int)nn->_idx);
   12.24 +      }
   12.25 +    }
   12.26 +  }
   12.27 +
   12.28    // Smash all inputs to 'old', isolating him completely
   12.29    Node *temp = new (C) Node(1);
   12.30    temp->init_req(0,nn);     // Add a use to nn to prevent him from dying
    13.1 --- a/src/share/vm/opto/type.hpp	Mon Jan 23 17:09:40 2017 -0800
    13.2 +++ b/src/share/vm/opto/type.hpp	Thu Feb 16 13:21:41 2017 -0800
    13.3 @@ -882,7 +882,7 @@
    13.4  
    13.5    // If not InstanceTop or InstanceBot, indicates that this is
    13.6    // a particular instance of this type which is distinct.
    13.7 -  // This is the the node index of the allocation node creating this instance.
    13.8 +  // This is the node index of the allocation node creating this instance.
    13.9    int           _instance_id;
   13.10  
   13.11    // Extra type information profiling gave us. We propagate it the
    14.1 --- a/src/share/vm/runtime/arguments.cpp	Mon Jan 23 17:09:40 2017 -0800
    14.2 +++ b/src/share/vm/runtime/arguments.cpp	Thu Feb 16 13:21:41 2017 -0800
    14.3 @@ -1,5 +1,5 @@
    14.4  /*
    14.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    14.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    14.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.8   *
    14.9   * This code is free software; you can redistribute it and/or modify it
   14.10 @@ -1768,10 +1768,39 @@
   14.11      FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
   14.12    }
   14.13  
   14.14 -  const julong phys_mem =
   14.15 +  julong phys_mem =
   14.16      FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
   14.17                              : (julong)MaxRAM;
   14.18  
   14.19 +  // Experimental support for CGroup memory limits
   14.20 +  if (UseCGroupMemoryLimitForHeap) {
   14.21 +    // This is a rough indicator that a CGroup limit may be in force
   14.22 +    // for this process
   14.23 +    const char* lim_file = "/sys/fs/cgroup/memory/memory.limit_in_bytes";
   14.24 +    FILE *fp = fopen(lim_file, "r");
   14.25 +    if (fp != NULL) {
   14.26 +      julong cgroup_max = 0;
   14.27 +      int ret = fscanf(fp, JULONG_FORMAT, &cgroup_max);
   14.28 +      if (ret == 1 && cgroup_max > 0) {
   14.29 +        // If unlimited, cgroup_max will be a very large, but unspecified
   14.30 +        // value, so use initial phys_mem as a limit
   14.31 +        if (PrintGCDetails && Verbose) {
   14.32 +          // Cannot use gclog_or_tty yet.
   14.33 +          tty->print_cr("Setting phys_mem to the min of cgroup limit ("
   14.34 +                        JULONG_FORMAT "MB) and initial phys_mem ("
   14.35 +                        JULONG_FORMAT "MB)", cgroup_max/M, phys_mem/M);
   14.36 +        }
   14.37 +        phys_mem = MIN2(cgroup_max, phys_mem);
   14.38 +      } else {
   14.39 +        warning("Unable to read/parse cgroup memory limit from %s: %s",
   14.40 +                lim_file, errno != 0 ? strerror(errno) : "unknown error");
   14.41 +      }
   14.42 +      fclose(fp);
   14.43 +    } else {
   14.44 +      warning("Unable to open cgroup memory limit file %s (%s)", lim_file, strerror(errno));
   14.45 +    }
   14.46 +  }
   14.47 +
   14.48    // If the maximum heap size has not been set with -Xmx,
   14.49    // then set it as fraction of the size of physical memory,
   14.50    // respecting the maximum and minimum sizes of the heap.
    15.1 --- a/src/share/vm/runtime/globals.hpp	Mon Jan 23 17:09:40 2017 -0800
    15.2 +++ b/src/share/vm/runtime/globals.hpp	Thu Feb 16 13:21:41 2017 -0800
    15.3 @@ -1,5 +1,5 @@
    15.4  /*
    15.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    15.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    15.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.8   *
    15.9   * This code is free software; you can redistribute it and/or modify it
   15.10 @@ -2068,6 +2068,10 @@
   15.11            "Maximum ergonomically set heap size (in bytes); zero means use " \
   15.12            "MaxRAM / MaxRAMFraction")                                        \
   15.13                                                                              \
   15.14 +  experimental(bool, UseCGroupMemoryLimitForHeap, false,                    \
   15.15 +          "Use CGroup memory limit as physical memory limit for heap "      \
   15.16 +          "sizing")                                                         \
   15.17 +                                                                            \
   15.18    product(uintx, MaxRAMFraction, 4,                                         \
   15.19            "Maximum fraction (1/n) of real memory used for maximum heap "    \
   15.20            "size")                                                           \
    16.1 --- a/src/share/vm/runtime/os.cpp	Mon Jan 23 17:09:40 2017 -0800
    16.2 +++ b/src/share/vm/runtime/os.cpp	Thu Feb 16 13:21:41 2017 -0800
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    16.6 + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
   16.10 @@ -78,6 +78,7 @@
   16.11  uintptr_t         os::_serialize_page_mask = 0;
   16.12  long              os::_rand_seed          = 1;
   16.13  int               os::_processor_count    = 0;
   16.14 +int               os::_initial_active_processor_count = 0;
   16.15  size_t            os::_page_sizes[os::page_sizes_max];
   16.16  
   16.17  #ifndef PRODUCT
   16.18 @@ -322,6 +323,7 @@
   16.19  }
   16.20  
   16.21  void os::init_before_ergo() {
   16.22 +  initialize_initial_active_processor_count();
   16.23    // We need to initialize large page support here because ergonomics takes some
   16.24    // decisions depending on large page support and the calculated large page size.
   16.25    large_page_init();
   16.26 @@ -835,7 +837,11 @@
   16.27    st->print("CPU:");
   16.28    st->print("total %d", os::processor_count());
   16.29    // It's not safe to query number of active processors after crash
   16.30 -  // st->print("(active %d)", os::active_processor_count());
   16.31 +  // st->print("(active %d)", os::active_processor_count()); but we can
   16.32 +  // print the initial number of active processors.
   16.33 +  // We access the raw value here because the assert in the accessor will
   16.34 +  // fail if the crash occurs before initialization of this value.
   16.35 +  st->print(" (initial active %d)", _initial_active_processor_count);
   16.36    st->print(" %s", VM_Version::cpu_features());
   16.37    st->cr();
   16.38    pd_print_cpu_info(st);
   16.39 @@ -1418,6 +1424,11 @@
   16.40    return result;
   16.41  }
   16.42  
   16.43 +void os::initialize_initial_active_processor_count() {
   16.44 +  assert(_initial_active_processor_count == 0, "Initial active processor count already set.");
   16.45 +  _initial_active_processor_count = active_processor_count();
   16.46 +}
   16.47 +
   16.48  void os::SuspendedThreadTask::run() {
   16.49    assert(Threads_lock->owned_by_self() || (_thread == VMThread::vm_thread()), "must have threads lock to call this");
   16.50    internal_do_task();
    17.1 --- a/src/share/vm/runtime/os.hpp	Mon Jan 23 17:09:40 2017 -0800
    17.2 +++ b/src/share/vm/runtime/os.hpp	Thu Feb 16 13:21:41 2017 -0800
    17.3 @@ -151,6 +151,7 @@
    17.4  
    17.5    static size_t page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned);
    17.6  
    17.7 +  static void initialize_initial_active_processor_count();
    17.8   public:
    17.9    static void init(void);                      // Called before command line parsing
   17.10    static void init_before_ergo(void);          // Called after command line parsing
   17.11 @@ -238,6 +239,13 @@
   17.12    // Note that on some OSes this can change dynamically.
   17.13    static int active_processor_count();
   17.14  
   17.15 +  // At startup the number of active CPUs this process is allowed to run on.
   17.16 +  // This value does not change dynamically. May be different from active_processor_count().
   17.17 +  static int initial_active_processor_count() {
   17.18 +    assert(_initial_active_processor_count > 0, "Initial active processor count not set yet.");
   17.19 +    return _initial_active_processor_count;
   17.20 +  }
   17.21 +
   17.22    // Bind processes to processors.
   17.23    //     This is a two step procedure:
   17.24    //     first you generate a distribution of processes to processors,
   17.25 @@ -975,8 +983,9 @@
   17.26  
   17.27  
   17.28   protected:
   17.29 -  static long _rand_seed;                   // seed for random number generator
   17.30 -  static int _processor_count;              // number of processors
   17.31 +  static long _rand_seed;                     // seed for random number generator
   17.32 +  static int _processor_count;                // number of processors
   17.33 +  static int _initial_active_processor_count; // number of active processors during initialization.
   17.34  
   17.35    static char* format_boot_path(const char* format_string,
   17.36                                  const char* home,
    18.1 --- a/src/share/vm/runtime/vm_version.cpp	Mon Jan 23 17:09:40 2017 -0800
    18.2 +++ b/src/share/vm/runtime/vm_version.cpp	Thu Feb 16 13:21:41 2017 -0800
    18.3 @@ -1,5 +1,5 @@
    18.4  /*
    18.5 - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    18.6 + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
    18.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.8   *
    18.9   * This code is free software; you can redistribute it and/or modify it
   18.10 @@ -296,7 +296,7 @@
   18.11      // processor after the first 8.  For example, on a 72 cpu machine
   18.12      // and a chosen fraction of 5/8
   18.13      // use 8 + (72 - 8) * (5/8) == 48 worker threads.
   18.14 -    unsigned int ncpus = (unsigned int) os::active_processor_count();
   18.15 +    unsigned int ncpus = (unsigned int) os::initial_active_processor_count();
   18.16      return (ncpus <= switch_pt) ?
   18.17             ncpus :
   18.18            (switch_pt + ((ncpus - switch_pt) * num) / den);
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/runtime/os/AvailableProcessors.java	Thu Feb 16 13:21:41 2017 -0800
    19.3 @@ -0,0 +1,103 @@
    19.4 +/*
    19.5 + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +import java.io.File;
   19.27 +import com.oracle.java.testlibrary.ProcessTools;
   19.28 +import com.oracle.java.testlibrary.OutputAnalyzer;
   19.29 +import java.util.ArrayList;
   19.30 +
   19.31 +/*
   19.32 + * @test
   19.33 + * @bug 6515172
   19.34 + * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux
   19.35 + * @requires os.family == "linux"
   19.36 + * @library /testlibrary
   19.37 + * @build com.oracle.java.testlibrary.*
   19.38 + * @run driver AvailableProcessors
   19.39 + */
   19.40 +public class AvailableProcessors {
   19.41 +
   19.42 +    static final String SUCCESS_STRING = "Found expected processors: ";
   19.43 +
   19.44 +    public static void main(String[] args) throws Throwable {
   19.45 +        if (args.length > 0)
   19.46 +            checkProcessors(Integer.parseInt(args[0]));
   19.47 +        else {
   19.48 +            // run ourselves under different cpu configurations
   19.49 +            // using the taskset command
   19.50 +            String taskset;
   19.51 +            final String taskset1 = "/bin/taskset";
   19.52 +            final String taskset2 = "/usr/bin/taskset";
   19.53 +            if (new File(taskset1).exists())
   19.54 +                taskset = taskset1;
   19.55 +            else if (new File(taskset2).exists())
   19.56 +                taskset = taskset2;
   19.57 +            else {
   19.58 +                System.out.println("Skipping test: could not find taskset command");
   19.59 +                return;
   19.60 +            }
   19.61 +
   19.62 +            int available = Runtime.getRuntime().availableProcessors();
   19.63 +
   19.64 +            if (available == 1) {
   19.65 +                System.out.println("Skipping test: only one processor available");
   19.66 +                return;
   19.67 +            }
   19.68 +
   19.69 +            // Get the java command we want to execute
   19.70 +            // Enable logging for easier failure diagnosis
   19.71 +            ProcessBuilder master =
   19.72 +                    ProcessTools.createJavaProcessBuilder(false,
   19.73 +                                                          "-XX:+UnlockDiagnosticVMOptions",
   19.74 +                                                          "-XX:+PrintActiveCpus",
   19.75 +                                                          "AvailableProcessors");
   19.76 +
   19.77 +            int[] expected = new int[] { 1, available/2, available-1, available };
   19.78 +
   19.79 +            for (int i : expected) {
   19.80 +                System.out.println("Testing for " + i + " processors ...");
   19.81 +                int max = i - 1;
   19.82 +                ArrayList<String> cmdline = new ArrayList<>(master.command());
   19.83 +                // prepend taskset command
   19.84 +                cmdline.add(0, "0-" + max);
   19.85 +                cmdline.add(0, "-c");
   19.86 +                cmdline.add(0, taskset);
   19.87 +                // append expected processor count
   19.88 +                cmdline.add(String.valueOf(i));
   19.89 +                ProcessBuilder pb = new ProcessBuilder(cmdline);
   19.90 +                System.out.println("Final command line: " +
   19.91 +                                   ProcessTools.getCommandLine(pb));
   19.92 +                OutputAnalyzer output = ProcessTools.executeProcess(pb);
   19.93 +                output.shouldContain(SUCCESS_STRING);
   19.94 +            }
   19.95 +        }
   19.96 +    }
   19.97 +
   19.98 +    static void checkProcessors(int expected) {
   19.99 +        int available = Runtime.getRuntime().availableProcessors();
  19.100 +        if (available != expected)
  19.101 +            throw new Error("Expected " + expected + " processors, but found "
  19.102 +                            + available);
  19.103 +        else
  19.104 +            System.out.println(SUCCESS_STRING + available);
  19.105 +    }
  19.106 +}

mercurial