| 1748 | } |
| 1749 | |
| 1750 | void |
| 1751 | rpmalloc_global_statistics(rpmalloc_global_statistics_t* stats) { |
| 1752 | memset(stats, 0, sizeof(rpmalloc_global_statistics_t)); |
| 1753 | #if ENABLE_STATISTICS |
| 1754 | stats->mapped = (size_t)atomic_load32(&_mapped_pages) * PAGE_SIZE; |
| 1755 | stats->mapped_total = (size_t)atomic_load32(&_mapped_total) * PAGE_SIZE; |
| 1756 | stats->unmapped_total = (size_t)atomic_load32(&_unmapped_total) * PAGE_SIZE; |
| 1757 | #endif |
| 1758 | for (size_t iclass = 0; iclass < SPAN_CLASS_COUNT; ++iclass) { |
| 1759 | void* global_span_ptr = atomic_load_ptr(&_memory_span_cache[iclass]); |
| 1760 | while (global_span_ptr == SPAN_LIST_LOCK_TOKEN) { |
| 1761 | thread_yield(); |
| 1762 | global_span_ptr = atomic_load_ptr(&_memory_span_cache[iclass]); |
| 1763 | } |
| 1764 | uintptr_t global_span_count = (uintptr_t)global_span_ptr & ~SPAN_MASK; |
| 1765 | size_t list_bytes = global_span_count * (iclass + 1) * SPAN_CLASS_GRANULARITY * PAGE_SIZE; |
| 1766 | stats->cached += list_bytes; |
| 1767 | } |
| 1768 | for (size_t iclass = 0; iclass < LARGE_CLASS_COUNT; ++iclass) { |
| 1769 | void* global_span_ptr = atomic_load_ptr(&_memory_large_cache[iclass]); |
| 1770 | while (global_span_ptr == SPAN_LIST_LOCK_TOKEN) { |
| 1771 | thread_yield(); |
| 1772 | global_span_ptr = atomic_load_ptr(&_memory_large_cache[iclass]); |
| 1773 | } |
| 1774 | uintptr_t global_span_count = (uintptr_t)global_span_ptr & ~SPAN_MASK; |
| 1775 | size_t list_bytes = global_span_count * (iclass + 1) * SPAN_MAX_PAGE_COUNT * PAGE_SIZE; |
| 1776 | stats->cached_large += list_bytes; |
| 1777 | } |
| 1778 | } |
nothing calls this directly
no test coverage detected