< prev index next >

src/os/solaris/vm/perfMemory_solaris.cpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2016, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"

  27 #include "memory/allocation.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "os_solaris.inline.hpp"
  31 #include "runtime/handles.inline.hpp"
  32 #include "runtime/perfMemory.hpp"
  33 #include "services/memTracker.hpp"
  34 #include "utilities/exceptions.hpp"
  35 
  36 // put OS-includes here
  37 #include <sys/types.h>
  38 #include <sys/mman.h>
  39 #include <errno.h>
  40 #include <stdio.h>
  41 #include <unistd.h>
  42 #include <sys/stat.h>
  43 #include <signal.h>
  44 #include <procfs.h>
  45 
  46 /* For POSIX-compliant getpwuid_r on Solaris */


1167   mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
1168 
1169   result = ::close(fd);
1170   assert(result != OS_ERR, "could not close file");
1171 
1172   if (mapAddress == MAP_FAILED) {
1173     if (PrintMiscellaneous && Verbose) {
1174       warning("mmap failed: %s\n", os::strerror(errno));
1175     }
1176     THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(),
1177               "Could not map PerfMemory");
1178   }
1179 
1180   // it does not go through os api, the operation has to record from here
1181   MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress,
1182     size, CURRENT_PC, mtInternal);
1183 
1184   *addr = mapAddress;
1185   *sizep = size;
1186 
1187   if (PerfTraceMemOps) {
1188     tty->print("mapped " SIZE_FORMAT " bytes for vmid %d at "
1189                INTPTR_FORMAT "\n", size, vmid, (void*)mapAddress);
1190   }
1191 }
1192 
1193 
1194 
1195 
1196 // create the PerfData memory region
1197 //
1198 // This method creates the memory region used to store performance
1199 // data for the JVM. The memory may be created in standard or
1200 // shared memory.
1201 //
1202 void PerfMemory::create_memory_region(size_t size) {
1203 
1204   if (PerfDisableSharedMem) {
1205     // do not share the memory for the performance data.
1206     _start = create_standard_memory(size);
1207   }
1208   else {
1209     _start = create_shared_memory(size);
1210     if (_start == NULL) {
1211 
1212       // creation of the shared memory region failed, attempt
1213       // to create a contiguous, non-shared memory region instead.
1214       //


   1 /*
   2  * Copyright (c) 2001, 2017, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"
  27 #include "logging/log.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "os_solaris.inline.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/perfMemory.hpp"
  34 #include "services/memTracker.hpp"
  35 #include "utilities/exceptions.hpp"
  36 
  37 // put OS-includes here
  38 #include <sys/types.h>
  39 #include <sys/mman.h>
  40 #include <errno.h>
  41 #include <stdio.h>
  42 #include <unistd.h>
  43 #include <sys/stat.h>
  44 #include <signal.h>
  45 #include <procfs.h>
  46 
  47 /* For POSIX-compliant getpwuid_r on Solaris */


1168   mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
1169 
1170   result = ::close(fd);
1171   assert(result != OS_ERR, "could not close file");
1172 
1173   if (mapAddress == MAP_FAILED) {
1174     if (PrintMiscellaneous && Verbose) {
1175       warning("mmap failed: %s\n", os::strerror(errno));
1176     }
1177     THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(),
1178               "Could not map PerfMemory");
1179   }
1180 
1181   // it does not go through os api, the operation has to record from here
1182   MemTracker::record_virtual_memory_reserve_and_commit((address)mapAddress,
1183     size, CURRENT_PC, mtInternal);
1184 
1185   *addr = mapAddress;
1186   *sizep = size;
1187 
1188   log_debug(perf, memops)("mapped " SIZE_FORMAT " bytes for vmid %d at "

1189                           INTPTR_FORMAT "\n", size, vmid, (void*)mapAddress);

1190 }



1191 
1192 // create the PerfData memory region
1193 //
1194 // This method creates the memory region used to store performance
1195 // data for the JVM. The memory may be created in standard or
1196 // shared memory.
1197 //
1198 void PerfMemory::create_memory_region(size_t size) {
1199 
1200   if (PerfDisableSharedMem) {
1201     // do not share the memory for the performance data.
1202     _start = create_standard_memory(size);
1203   }
1204   else {
1205     _start = create_shared_memory(size);
1206     if (_start == NULL) {
1207 
1208       // creation of the shared memory region failed, attempt
1209       // to create a contiguous, non-shared memory region instead.
1210       //


< prev index next >