Merge branch 'dev' into overcommit_if_the_system_approves

This commit is contained in:
Daan 2021-10-27 17:12:18 -07:00 committed by GitHub
commit 13b30bf2dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 5 deletions

View File

@ -173,7 +173,7 @@ extern "C" {
void cfree(void* p) MI_FORWARD0(mi_free, p) void cfree(void* p) MI_FORWARD0(mi_free, p)
void* reallocf(void* p, size_t newsize) MI_FORWARD2(mi_reallocf,p,newsize) void* reallocf(void* p, size_t newsize) MI_FORWARD2(mi_reallocf,p,newsize)
size_t malloc_size(const void* p) MI_FORWARD1(mi_usable_size,p) size_t malloc_size(const void* p) MI_FORWARD1(mi_usable_size,p)
#if !defined(__ANDROID__) #if !defined(__ANDROID__) && !defined(__FreeBSD__)
size_t malloc_usable_size(void *p) MI_FORWARD1(mi_usable_size,p) size_t malloc_usable_size(void *p) MI_FORWARD1(mi_usable_size,p)
#else #else
size_t malloc_usable_size(const void *p) MI_FORWARD1(mi_usable_size,p) size_t malloc_usable_size(const void *p) MI_FORWARD1(mi_usable_size,p)

View File

@ -53,7 +53,12 @@ terms of the MIT license. A copy of the license can be found in the file
#include <mach/vm_statistics.h> #include <mach/vm_statistics.h>
#endif #endif
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <sys/param.h>
#if __FreeBSD_version >= 1200000
#include <sys/cpuset.h>
#include <sys/domainset.h>
#endif
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
#endif #endif
@ -1272,6 +1277,47 @@ static size_t mi_os_numa_node_countx(void) {
} }
return (node+1); return (node+1);
} }
#elif defined(__FreeBSD__) && __FreeBSD_version >= 1200000
static size_t mi_os_numa_nodex(void) {
domainset_t dom;
size_t node;
int policy;
if (cpuset_getdomain(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, sizeof(dom), &dom, &policy) == -1) return 0ul;
for (node = 0; node < MAXMEMDOM; node++) {
if (DOMAINSET_ISSET(node, &dom)) return node;
}
return 0ul;
}
static size_t mi_os_numa_node_countx(void) {
size_t ndomains = 0;
size_t len = sizeof(ndomains);
if (sysctlbyname("vm.ndomains", &ndomains, &len, NULL, 0) == -1) return 0ul;
return ndomains;
}
#elif defined(__DragonFly__)
static size_t mi_os_numa_nodex(void) {
// TODO DragonFlyBSD does not seem to provide any userland mean to
// check this information, even less the possibility to control
// the allocation to a logical core level's granularity, only the kernel
// is fully NUMA aware at the moment.
return 0ul;
}
static size_t mi_os_numa_node_countx(void) {
size_t ncpus = 0, nvirtcoresperphys = 0;
size_t len = sizeof(size_t);
if (sysctlbyname("hw.ncpu", &ncpus, &len, NULL, 0) == -1) return 0ul;
if (sysctlbyname("hw.cpu_topology_ht_ids", &nvirtcoresperphys, &len, NULL, 0) == -1) return 0ul;
return nvirtcoresperphys * ncpus;
}
#else #else
static size_t mi_os_numa_nodex(void) { static size_t mi_os_numa_nodex(void) {
return 0; return 0;

View File

@ -84,9 +84,10 @@ static bool mi_page_is_valid_init(mi_page_t* page) {
mi_assert_internal(mi_page_list_is_valid(page,page->local_free)); mi_assert_internal(mi_page_list_is_valid(page,page->local_free));
#if MI_DEBUG>3 // generally too expensive to check this #if MI_DEBUG>3 // generally too expensive to check this
if (page->flags.is_zero) { if (page->is_zero) {
for(mi_block_t* block = page->free; block != NULL; mi_block_next(page,block)) { const size_t ubsize = mi_page_usable_block_size(page);
mi_assert_expensive(mi_mem_is_zero(block + 1, page->block_size - sizeof(mi_block_t))); for(mi_block_t* block = page->free; block != NULL; block = mi_block_next(page,block)) {
mi_assert_expensive(mi_mem_is_zero(block + 1, ubsize - sizeof(mi_block_t)));
} }
} }
#endif #endif