2760 static int page_size = -1;
2761
2762 // The mmap MAP_ALIGN flag is supported on Solaris 9 and later. init_2() will
2763 // clear this var if support is not available.
2764 static bool has_map_align = true;
2765
2766 int os::vm_page_size() {
2767 assert(page_size != -1, "must call os::init");
2768 return page_size;
2769 }
2770
2771 // Solaris allocates memory by pages.
2772 int os::vm_allocation_granularity() {
2773 assert(page_size != -1, "must call os::init");
2774 return page_size;
2775 }
2776
2777 bool os::commit_memory(char* addr, size_t bytes, bool exec) {
2778 int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
2779 size_t size = bytes;
2780 return
2781 NULL != Solaris::mmap_chunk(addr, size, MAP_PRIVATE|MAP_FIXED, prot);
2782 }
2783
2784 bool os::commit_memory(char* addr, size_t bytes, size_t alignment_hint,
2785 bool exec) {
2786 if (commit_memory(addr, bytes, exec)) {
2787 if (UseMPSS && alignment_hint > (size_t)vm_page_size()) {
2788 // If the large page size has been set and the VM
2789 // is using large pages, use the large page size
2790 // if it is smaller than the alignment hint. This is
2791 // a case where the VM wants to use a larger alignment size
2792 // for its own reasons but still want to use large pages
2793 // (which is what matters to setting the mpss range.
2794 size_t page_size = 0;
2795 if (large_page_size() < alignment_hint) {
2796 assert(UseLargePages, "Expected to be here for large page use only");
2797 page_size = large_page_size();
2798 } else {
2799 // If the alignment hint is less than the large page
2800 // size, the VM wants a particular alignment (thus the hint)
2801 // for internal reasons. Try to set the mpss range using
3420 }
3421
3422 // Attach to the region
3423 retAddr = (char *) shmat(shmid, 0, SHM_SHARE_MMU | SHM_R | SHM_W);
3424 int err = errno;
3425
3426 // Remove shmid. If shmat() is successful, the actual shared memory segment
3427 // will be deleted when it's detached by shmdt() or when the process
3428 // terminates. If shmat() is not successful this will remove the shared
3429 // segment immediately.
3430 shmctl(shmid, IPC_RMID, NULL);
3431
3432 if (retAddr == (char *) -1) {
3433 if (warn_on_failure) {
3434 jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
3435 warning(msg);
3436 }
3437 return NULL;
3438 }
3439
3440 return retAddr;
3441 }
3442
3443 bool os::release_memory_special(char* base, size_t bytes) {
3444 // detaching the SHM segment will also delete it, see reserve_memory_special()
3445 int rslt = shmdt(base);
3446 return rslt == 0;
3447 }
3448
3449 size_t os::large_page_size() {
3450 return _large_page_size;
3451 }
3452
3453 // MPSS allows application to commit large page memory on demand; with ISM
3454 // the entire memory region must be allocated as shared memory.
3455 bool os::can_commit_large_page_memory() {
3456 return UseISM ? false : true;
3457 }
3458
3459 bool os::can_execute_large_page_memory() {
|
2760 static int page_size = -1;
2761
2762 // The mmap MAP_ALIGN flag is supported on Solaris 9 and later. init_2() will
2763 // clear this var if support is not available.
2764 static bool has_map_align = true;
2765
2766 int os::vm_page_size() {
2767 assert(page_size != -1, "must call os::init");
2768 return page_size;
2769 }
2770
2771 // Solaris allocates memory by pages.
2772 int os::vm_allocation_granularity() {
2773 assert(page_size != -1, "must call os::init");
2774 return page_size;
2775 }
2776
2777 bool os::commit_memory(char* addr, size_t bytes, bool exec) {
2778 int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
2779 size_t size = bytes;
2780 char *res = Solaris::mmap_chunk(addr, size, MAP_PRIVATE|MAP_FIXED, prot);
2781 if (UseNUMAInterleaving) {
2782 numa_make_global(addr, bytes);
2783 }
2784 return res != NULL;
2785 }
2786
2787 bool os::commit_memory(char* addr, size_t bytes, size_t alignment_hint,
2788 bool exec) {
2789 if (commit_memory(addr, bytes, exec)) {
2790 if (UseMPSS && alignment_hint > (size_t)vm_page_size()) {
2791 // If the large page size has been set and the VM
2792 // is using large pages, use the large page size
2793 // if it is smaller than the alignment hint. This is
2794 // a case where the VM wants to use a larger alignment size
2795 // for its own reasons but still want to use large pages
2796 // (which is what matters to setting the mpss range.
2797 size_t page_size = 0;
2798 if (large_page_size() < alignment_hint) {
2799 assert(UseLargePages, "Expected to be here for large page use only");
2800 page_size = large_page_size();
2801 } else {
2802 // If the alignment hint is less than the large page
2803 // size, the VM wants a particular alignment (thus the hint)
2804 // for internal reasons. Try to set the mpss range using
3423 }
3424
3425 // Attach to the region
3426 retAddr = (char *) shmat(shmid, 0, SHM_SHARE_MMU | SHM_R | SHM_W);
3427 int err = errno;
3428
3429 // Remove shmid. If shmat() is successful, the actual shared memory segment
3430 // will be deleted when it's detached by shmdt() or when the process
3431 // terminates. If shmat() is not successful this will remove the shared
3432 // segment immediately.
3433 shmctl(shmid, IPC_RMID, NULL);
3434
3435 if (retAddr == (char *) -1) {
3436 if (warn_on_failure) {
3437 jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
3438 warning(msg);
3439 }
3440 return NULL;
3441 }
3442
3443 if (UseNUMAInterleaving) {
3444 numa_make_global(retAddr, bytes);
3445 }
3446 return retAddr;
3447 }
3448
3449 bool os::release_memory_special(char* base, size_t bytes) {
3450 // detaching the SHM segment will also delete it, see reserve_memory_special()
3451 int rslt = shmdt(base);
3452 return rslt == 0;
3453 }
3454
3455 size_t os::large_page_size() {
3456 return _large_page_size;
3457 }
3458
3459 // MPSS allows application to commit large page memory on demand; with ISM
3460 // the entire memory region must be allocated as shared memory.
3461 bool os::can_commit_large_page_memory() {
3462 return UseISM ? false : true;
3463 }
3464
3465 bool os::can_execute_large_page_memory() {
|