src/os/linux/vm/os_linux.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File linux-large-pages Sdiff src/os/linux/vm

src/os/linux/vm/os_linux.cpp

Print this page




2514 
2515 // Define MADV_HUGEPAGE here so we can build HotSpot on old systems.
2516 #ifndef MADV_HUGEPAGE
2517 #define MADV_HUGEPAGE 14
2518 #endif
2519 
2520 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
2521                        bool exec) {
2522   if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
2523     int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
2524     uintptr_t res =
2525       (uintptr_t) ::mmap(addr, size, prot,
2526                          MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB,
2527                          -1, 0);
2528     if (res != (uintptr_t) MAP_FAILED) {
2529       if (UseNUMAInterleaving) {
2530         numa_make_global(addr, size);
2531       }
2532       return true;
2533     }
2534     return false;
2535   }
2536 
2537   return commit_memory(addr, size, exec);




2538 }
2539 
2540 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
2541   if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
2542     // We don't check the return value: madvise(MADV_HUGEPAGE) may not
2543     // be supported or the memory may already be backed by huge pages.
2544     ::madvise(addr, bytes, MADV_HUGEPAGE);
2545   }
2546 }
2547 
2548 void os::free_memory(char *addr, size_t bytes) {
2549   commit_memory(addr, bytes, false);
2550 }
2551 
2552 void os::numa_make_global(char *addr, size_t bytes) {
2553   Linux::numa_interleave_memory(addr, bytes);
2554 }
2555 
2556 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
2557   Linux::numa_tonode_memory(addr, bytes, lgrp_hint);




2514 
2515 // Define MADV_HUGEPAGE here so we can build HotSpot on old systems.
2516 #ifndef MADV_HUGEPAGE
2517 #define MADV_HUGEPAGE 14
2518 #endif
2519 
2520 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
2521                        bool exec) {
2522   if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
2523     int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
2524     uintptr_t res =
2525       (uintptr_t) ::mmap(addr, size, prot,
2526                          MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB,
2527                          -1, 0);
2528     if (res != (uintptr_t) MAP_FAILED) {
2529       if (UseNUMAInterleaving) {
2530         numa_make_global(addr, size);
2531       }
2532       return true;
2533     }
2534     // Fall through and try to use small pages
2535   }
2536 
2537   if (commit_memory(addr, size, exec)) {
2538     realign_memory(addr, size, alignment_hint);
2539     return true;
2540   }
2541   return false;
2542 }
2543 
2544 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
2545   if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
2546     // We don't check the return value: madvise(MADV_HUGEPAGE) may not
2547     // be supported or the memory may already be backed by huge pages.
2548     ::madvise(addr, bytes, MADV_HUGEPAGE);
2549   }
2550 }
2551 
2552 void os::free_memory(char *addr, size_t bytes) {
2553   commit_memory(addr, bytes, false);
2554 }
2555 
2556 void os::numa_make_global(char *addr, size_t bytes) {
2557   Linux::numa_interleave_memory(addr, bytes);
2558 }
2559 
2560 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
2561   Linux::numa_tonode_memory(addr, bytes, lgrp_hint);


src/os/linux/vm/os_linux.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File