| 596 | } |
| 597 | |
| 598 | bool |
| 599 | pages_boot(void) { |
| 600 | os_page = os_page_detect(); |
| 601 | if (os_page > PAGE) { |
| 602 | malloc_write("<jemalloc>: Unsupported system page size\n"); |
| 603 | if (opt_abort) { |
| 604 | abort(); |
| 605 | } |
| 606 | return true; |
| 607 | } |
| 608 | |
| 609 | #ifndef _WIN32 |
| 610 | mmap_flags = MAP_PRIVATE | MAP_ANON; |
| 611 | #endif |
| 612 | |
| 613 | #ifdef JEMALLOC_SYSCTL_VM_OVERCOMMIT |
| 614 | os_overcommits = os_overcommits_sysctl(); |
| 615 | #elif defined(JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY) |
| 616 | os_overcommits = os_overcommits_proc(); |
| 617 | # ifdef MAP_NORESERVE |
| 618 | if (os_overcommits) { |
| 619 | mmap_flags |= MAP_NORESERVE; |
| 620 | } |
| 621 | # endif |
| 622 | #else |
| 623 | os_overcommits = false; |
| 624 | #endif |
| 625 | |
| 626 | init_thp_state(); |
| 627 | |
| 628 | #ifdef __FreeBSD__ |
| 629 | /* |
| 630 | * FreeBSD doesn't need the check; madvise(2) is known to work. |
| 631 | */ |
| 632 | #else |
| 633 | /* Detect lazy purge runtime support. */ |
| 634 | if (pages_can_purge_lazy) { |
| 635 | bool committed = false; |
| 636 | void *madv_free_page = os_pages_map(NULL, PAGE, PAGE, &committed); |
| 637 | if (madv_free_page == NULL) { |
| 638 | return true; |
| 639 | } |
| 640 | assert(pages_can_purge_lazy_runtime); |
| 641 | if (pages_purge_lazy(madv_free_page, PAGE)) { |
| 642 | pages_can_purge_lazy_runtime = false; |
| 643 | } |
| 644 | os_pages_unmap(madv_free_page, PAGE); |
| 645 | } |
| 646 | #endif |
| 647 | |
| 648 | return false; |
| 649 | } |
no test coverage detected