src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 54264 41af8d0546bc
child 59060 fce1fa1bdc91
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     1
/*
54264
41af8d0546bc 8221260: Initialize more class members on construction, remove some unused ones
lkorinth
parents: 53116
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     4
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     8
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    14
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    18
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    21
 * questions.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    22
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    23
 */
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    24
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    26
#include "gc/g1/g1BiasedArray.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    27
#include "gc/g1/g1RegionToSpaceMapper.hpp"
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
    28
#include "logging/log.hpp"
26163
89f44df5b438 8055635: Missing include in g1RegionToSpaceMapper.hpp results in unresolved symbol of fastdebug build without precompiled headers
tschatzl
parents: 26160
diff changeset
    29
#include "memory/allocation.inline.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 30158
diff changeset
    30
#include "memory/virtualspace.hpp"
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
    31
#include "runtime/java.hpp"
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
    32
#include "runtime/os.inline.hpp"
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    33
#include "services/memTracker.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    34
#include "utilities/align.hpp"
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    35
#include "utilities/bitMap.inline.hpp"
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
    36
#include "utilities/formatBuffer.hpp"
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    37
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    38
G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    39
                                             size_t used_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    40
                                             size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    41
                                             size_t region_granularity,
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 33105
diff changeset
    42
                                             size_t commit_factor,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    43
                                             MemoryType type) :
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 47216
diff changeset
    44
  _listener(NULL),
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    45
  _storage(rs, used_size, page_size),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    46
  _region_granularity(region_granularity),
46745
f7b9bb98bb72 8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents: 46625
diff changeset
    47
  _commit_map(rs.size() * commit_factor / region_granularity, mtGC) {
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    48
  guarantee(is_power_of_2(page_size), "must be");
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    49
  guarantee(is_power_of_2(region_granularity), "must be");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    50
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    51
  MemTracker::record_virtual_memory_type((address)rs.base(), type);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    52
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    53
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    54
// G1RegionToSpaceMapper implementation where the region granularity is larger than
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    55
// or the same as the commit granularity.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    56
// Basically, the space corresponding to one region region spans several OS pages.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    57
class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    58
 private:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    59
  size_t _pages_per_region;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    60
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    61
 public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    62
  G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    63
                                      size_t actual_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    64
                                      size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    65
                                      size_t alloc_granularity,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    66
                                      size_t commit_factor,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    67
                                      MemoryType type) :
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 33105
diff changeset
    68
    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    69
    _pages_per_region(alloc_granularity / (page_size * commit_factor)) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    70
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    71
    guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity");
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    72
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    73
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    74
  virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    75
    size_t const start_page = (size_t)start_idx * _pages_per_region;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    76
    bool zero_filled = _storage.commit(start_page, num_regions * _pages_per_region);
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    77
    if (AlwaysPreTouch) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    78
      _storage.pretouch(start_page, num_regions * _pages_per_region, pretouch_gang);
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    79
    }
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    80
    _commit_map.set_range(start_idx, start_idx + num_regions);
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 27149
diff changeset
    81
    fire_on_commit(start_idx, num_regions, zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    82
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    83
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    84
  virtual void uncommit_regions(uint start_idx, size_t num_regions) {
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    85
    _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    86
    _commit_map.clear_range(start_idx, start_idx + num_regions);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    87
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    88
};
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    89
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    90
// G1RegionToSpaceMapper implementation where the region granularity is smaller
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    91
// than the commit granularity.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    92
// Basically, the contents of one OS page span several regions.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    93
class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    94
 private:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    95
  class CommitRefcountArray : public G1BiasedMappedArray<uint> {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    96
   protected:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    97
     virtual uint default_value() const { return 0; }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    98
  };
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    99
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   100
  size_t _regions_per_page;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   101
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   102
  CommitRefcountArray _refcounts;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   103
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   104
  uintptr_t region_idx_to_page_idx(uint region) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   105
    return region / _regions_per_page;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   106
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   107
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   108
 public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   109
  G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   110
                                       size_t actual_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   111
                                       size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   112
                                       size_t alloc_granularity,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   113
                                       size_t commit_factor,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   114
                                       MemoryType type) :
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 33105
diff changeset
   115
    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   116
    _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   117
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   118
    guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity");
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 41178
diff changeset
   119
    _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_up(rs.size(), page_size)), page_size);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   120
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   121
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   122
  virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   123
    size_t const NoPage = ~(size_t)0;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   124
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   125
    size_t first_committed = NoPage;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   126
    size_t num_committed = 0;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   127
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   128
    bool all_zero_filled = true;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   129
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   130
    for (uint i = start_idx; i < start_idx + num_regions; i++) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
   131
      assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i);
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   132
      size_t idx = region_idx_to_page_idx(i);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   133
      uint old_refcount = _refcounts.get_by_index(idx);
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   134
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26163
diff changeset
   135
      bool zero_filled = false;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   136
      if (old_refcount == 0) {
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   137
        if (first_committed == NoPage) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   138
          first_committed = idx;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   139
          num_committed = 1;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   140
        } else {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   141
          num_committed++;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   142
        }
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 27149
diff changeset
   143
        zero_filled = _storage.commit(idx, 1);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   144
      }
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   145
      all_zero_filled &= zero_filled;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   146
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   147
      _refcounts.set_by_index(idx, old_refcount + 1);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   148
      _commit_map.set_bit(i);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   149
    }
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   150
    if (AlwaysPreTouch && num_committed > 0) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   151
      _storage.pretouch(first_committed, num_committed, pretouch_gang);
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   152
    }
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   153
    fire_on_commit(start_idx, num_regions, all_zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   154
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   155
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   156
  virtual void uncommit_regions(uint start_idx, size_t num_regions) {
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   157
    for (uint i = start_idx; i < start_idx + num_regions; i++) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
   158
      assert(_commit_map.at(i), "Trying to uncommit storage at region %u that is not committed", i);
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   159
      size_t idx = region_idx_to_page_idx(i);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   160
      uint old_refcount = _refcounts.get_by_index(idx);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   161
      assert(old_refcount > 0, "must be");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   162
      if (old_refcount == 1) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   163
        _storage.uncommit(idx, 1);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   164
      }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   165
      _refcounts.set_by_index(idx, old_refcount - 1);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   166
      _commit_map.clear_bit(i);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   167
    }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   168
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   169
};
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   170
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26163
diff changeset
   171
void G1RegionToSpaceMapper::fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   172
  if (_listener != NULL) {
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26163
diff changeset
   173
    _listener->on_commit(start_idx, num_regions, zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   174
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   175
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   176
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   177
static bool map_nvdimm_space(ReservedSpace rs) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   178
  assert(AllocateOldGenAt != NULL, "");
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   179
  int _backing_fd = os::create_file_for_heap(AllocateOldGenAt);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   180
  if (_backing_fd == -1) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   181
    log_error(gc, init)("Could not create file for Old generation at location %s", AllocateOldGenAt);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   182
    return false;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   183
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   184
  // commit this memory in nv-dimm
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   185
  char* ret = os::attempt_reserve_memory_at(rs.size(), rs.base(), _backing_fd);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   186
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   187
  if (ret != rs.base()) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   188
    if (ret != NULL) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   189
      os::unmap_memory(rs.base(), rs.size());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   190
    }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   191
    log_error(gc, init)("Error in mapping Old Gen to given AllocateOldGenAt = %s", AllocateOldGenAt);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   192
    os::close(_backing_fd);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   193
    return false;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   194
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   195
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   196
  os::close(_backing_fd);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   197
  return true;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   198
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   199
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   200
G1RegionToHeteroSpaceMapper::G1RegionToHeteroSpaceMapper(ReservedSpace rs,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   201
                                                         size_t actual_size,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   202
                                                         size_t page_size,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   203
                                                         size_t alloc_granularity,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   204
                                                         size_t commit_factor,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   205
                                                         MemoryType type) :
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   206
  G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   207
  _rs(rs),
54264
41af8d0546bc 8221260: Initialize more class members on construction, remove some unused ones
lkorinth
parents: 53116
diff changeset
   208
  _dram_mapper(NULL),
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   209
  _num_committed_dram(0),
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   210
  _num_committed_nvdimm(0),
54264
41af8d0546bc 8221260: Initialize more class members on construction, remove some unused ones
lkorinth
parents: 53116
diff changeset
   211
  _start_index_of_dram(0),
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   212
  _page_size(page_size),
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   213
  _commit_factor(commit_factor),
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   214
  _type(type) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   215
  assert(actual_size == 2 * MaxHeapSize, "For 2-way heterogenuous heap, reserved space is two times MaxHeapSize");
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   216
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   217
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   218
bool G1RegionToHeteroSpaceMapper::initialize() {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   219
  // Since we need to re-map the reserved space - 'Xmx' to nv-dimm and 'Xmx' to dram, we need to release the reserved memory first.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   220
  // Because on some OSes (e.g. Windows) you cannot do a file mapping on memory reserved with regular mapping.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   221
  os::release_memory(_rs.base(), _rs.size());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   222
  // First half of size Xmx is for nv-dimm.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   223
  ReservedSpace rs_nvdimm = _rs.first_part(MaxHeapSize);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   224
  assert(rs_nvdimm.base() == _rs.base(), "We should get the same base address");
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   225
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   226
  // Second half of reserved memory is mapped to dram.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   227
  ReservedSpace rs_dram = _rs.last_part(MaxHeapSize);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   228
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   229
  assert(rs_dram.size() == rs_nvdimm.size() && rs_nvdimm.size() == MaxHeapSize, "They all should be same");
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   230
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   231
  // Reserve dram memory
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   232
  char* base = os::attempt_reserve_memory_at(rs_dram.size(), rs_dram.base());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   233
  if (base != rs_dram.base()) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   234
    if (base != NULL) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   235
      os::release_memory(base, rs_dram.size());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   236
    }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   237
    log_error(gc, init)("Error in re-mapping memory on dram during G1 heterogenous memory initialization");
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   238
    return false;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   239
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   240
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   241
  // We reserve and commit this entire space to NV-DIMM.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   242
  if (!map_nvdimm_space(rs_nvdimm)) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   243
    log_error(gc, init)("Error in re-mapping memory to nv-dimm during G1 heterogenous memory initialization");
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   244
    return false;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   245
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   246
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   247
  if (_region_granularity >= (_page_size * _commit_factor)) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   248
    _dram_mapper = new G1RegionsLargerThanCommitSizeMapper(rs_dram, rs_dram.size(), _page_size, _region_granularity, _commit_factor, _type);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   249
  } else {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   250
    _dram_mapper = new G1RegionsSmallerThanCommitSizeMapper(rs_dram, rs_dram.size(), _page_size, _region_granularity, _commit_factor, _type);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   251
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   252
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   253
  _start_index_of_dram = (uint)(rs_nvdimm.size() / _region_granularity);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   254
  return true;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   255
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   256
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   257
void G1RegionToHeteroSpaceMapper::commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   258
  uint end_idx = (start_idx + (uint)num_regions - 1);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   259
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   260
  uint num_dram = end_idx >= _start_index_of_dram ? MIN2((end_idx - _start_index_of_dram + 1), (uint)num_regions) : 0;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   261
  uint num_nvdimm = (uint)num_regions - num_dram;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   262
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   263
  if (num_nvdimm > 0) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   264
    // We do not need to commit nv-dimm regions, since they are committed in the beginning.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   265
    _num_committed_nvdimm += num_nvdimm;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   266
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   267
  if (num_dram > 0) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   268
    _dram_mapper->commit_regions(start_idx > _start_index_of_dram ? (start_idx - _start_index_of_dram) : 0, num_dram, pretouch_gang);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   269
    _num_committed_dram += num_dram;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   270
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   271
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   272
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   273
void G1RegionToHeteroSpaceMapper::uncommit_regions(uint start_idx, size_t num_regions) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   274
  uint end_idx = (start_idx + (uint)num_regions - 1);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   275
  uint num_dram = end_idx >= _start_index_of_dram ? MIN2((end_idx - _start_index_of_dram + 1), (uint)num_regions) : 0;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   276
  uint num_nvdimm = (uint)num_regions - num_dram;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   277
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   278
  if (num_nvdimm > 0) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   279
    // We do not uncommit memory for nv-dimm regions.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   280
    _num_committed_nvdimm -= num_nvdimm;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   281
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   282
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   283
  if (num_dram > 0) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   284
    _dram_mapper->uncommit_regions(start_idx > _start_index_of_dram ? (start_idx - _start_index_of_dram) : 0, num_dram);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   285
    _num_committed_dram -= num_dram;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   286
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   287
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   288
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   289
uint G1RegionToHeteroSpaceMapper::num_committed_dram() const {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   290
  return _num_committed_dram;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   291
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   292
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   293
uint G1RegionToHeteroSpaceMapper::num_committed_nvdimm() const {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   294
  return _num_committed_nvdimm;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   295
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   296
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   297
G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_heap_mapper(ReservedSpace rs,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   298
                                                                 size_t actual_size,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   299
                                                                 size_t page_size,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   300
                                                                 size_t region_granularity,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   301
                                                                 size_t commit_factor,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   302
                                                                 MemoryType type) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   303
  if (AllocateOldGenAt != NULL) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   304
    G1RegionToHeteroSpaceMapper* mapper = new G1RegionToHeteroSpaceMapper(rs, actual_size, page_size, region_granularity, commit_factor, type);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   305
    if (!mapper->initialize()) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   306
      delete mapper;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   307
      return NULL;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   308
    }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   309
    return (G1RegionToSpaceMapper*)mapper;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   310
  } else {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   311
    return create_mapper(rs, actual_size, page_size, region_granularity, commit_factor, type);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   312
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   313
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   314
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   315
G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   316
                                                            size_t actual_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   317
                                                            size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   318
                                                            size_t region_granularity,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   319
                                                            size_t commit_factor,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   320
                                                            MemoryType type) {
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   321
  if (region_granularity >= (page_size * commit_factor)) {
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   322
    return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   323
  } else {
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   324
    return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   325
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   326
}
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   327
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   328
void G1RegionToSpaceMapper::commit_and_set_special() {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   329
  _storage.commit_and_set_special();
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 51332
diff changeset
   330
}