< prev index next >

src/hotspot/share/services/virtualMemoryTracker.cpp

Print this page
rev 59964 : 8248426: NMT: VirtualMemoryTracker::split_reserved_region() does not properly update summary counting
   1 /*
   2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 495         return true;
 496       }
 497     }
 498   }
 499 }
 500 
 501 // Given an existing memory mapping registered with NMT, split the mapping in
 502 //  two. The newly created two mappings will be registered under the call
 503 //  stack and the memory flags of the original section.
 504 bool VirtualMemoryTracker::split_reserved_region(address addr, size_t size, size_t split) {
 505 
 506   ReservedMemoryRegion  rgn(addr, size);
 507   ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn);
 508   assert(reserved_rgn->same_region(addr, size), "Must be identical region");
 509   assert(reserved_rgn != NULL, "No reserved region");
 510   assert(reserved_rgn->committed_size() == 0, "Splitting committed region?");
 511 
 512   NativeCallStack original_stack = *reserved_rgn->call_stack();
 513   MEMFLAGS original_flags = reserved_rgn->flag();
 514 
 515   _reserved_regions->remove(rgn);
 516 
 517   // Now, create two new regions.
 518   add_reserved_region(addr, split, original_stack, original_flags);
 519   add_reserved_region(addr + split, size - split, original_stack, original_flags);
 520 
 521   return true;
 522 }
 523 
 524 
 525 // Iterate the range, find committed region within its bound.
 526 class RegionIterator : public StackObj {
 527 private:
 528   const address _start;
 529   const size_t  _size;
 530 
 531   address _current_start;
 532   size_t  _current_size;
 533 public:
 534   RegionIterator(address start, size_t size) :
 535     _start(start), _size(size), _current_start(start), _current_size(size) {


   1 /*
   2  * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 495         return true;
 496       }
 497     }
 498   }
 499 }
 500 
 501 // Given an existing memory mapping registered with NMT, split the mapping in
 502 //  two. The newly created two mappings will be registered under the call
 503 //  stack and the memory flags of the original section.
 504 bool VirtualMemoryTracker::split_reserved_region(address addr, size_t size, size_t split) {
 505 
 506   ReservedMemoryRegion  rgn(addr, size);
 507   ReservedMemoryRegion* reserved_rgn = _reserved_regions->find(rgn);
 508   assert(reserved_rgn->same_region(addr, size), "Must be identical region");
 509   assert(reserved_rgn != NULL, "No reserved region");
 510   assert(reserved_rgn->committed_size() == 0, "Splitting committed region?");
 511 
 512   NativeCallStack original_stack = *reserved_rgn->call_stack();
 513   MEMFLAGS original_flags = reserved_rgn->flag();
 514 
 515   remove_released_region(addr, size);
 516 
 517   // Now, create two new regions.
 518   add_reserved_region(addr, split, original_stack, original_flags);
 519   add_reserved_region(addr + split, size - split, original_stack, original_flags);
 520 
 521   return true;
 522 }
 523 
 524 
 525 // Iterate the range, find committed region within its bound.
 526 class RegionIterator : public StackObj {
 527 private:
 528   const address _start;
 529   const size_t  _size;
 530 
 531   address _current_start;
 532   size_t  _current_size;
 533 public:
 534   RegionIterator(address start, size_t size) :
 535     _start(start), _size(size), _current_start(start), _current_size(size) {


< prev index next >