зеркало из https://github.com/microsoft/snmalloc.git
Workaround for QEMU behaviour. (#147)
* Fixes for ARM * Workaround for QEMU behaviour.
This commit is contained in:
Родитель
a6d6eecf22
Коммит
4246d9a065
|
@ -7,6 +7,7 @@ option(USE_MEASURE "Measure performance with histograms" OFF)
|
|||
option(EXPOSE_EXTERNAL_PAGEMAP "Expose the global pagemap" OFF)
|
||||
option(EXPOSE_EXTERNAL_RESERVE "Expose an interface to reserve memory using the default memory provider" OFF)
|
||||
option(SNMALLOC_RUST_SUPPORT "Build static library for rust" OFF)
|
||||
option(SNMALLOC_QEMU_WORKAROUND "Disable using madvise(DONT_NEED) to zero memory on Linux" Off)
|
||||
set(CACHE_FRIENDLY_OFFSET OFF CACHE STRING "Base offset to place linked-list nodes.")
|
||||
|
||||
if ((CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT SNMALLOC_CI_BUILD))
|
||||
|
@ -112,6 +113,10 @@ if(USE_SNMALLOC_STATS)
|
|||
target_compile_definitions(snmalloc_lib INTERFACE -DUSE_SNMALLOC_STATS)
|
||||
endif()
|
||||
|
||||
if(SNMALLOC_QEMU_WORKAROUND)
|
||||
target_compile_definitions(snmalloc_lib INTERFACE -DSNMALLOC_QEMU_WORKAROUND)
|
||||
endif()
|
||||
|
||||
if(USE_MEASURE)
|
||||
target_compile_definitions(snmalloc_lib INTERFACE -DUSE_MEASURE)
|
||||
endif()
|
||||
|
|
|
@ -2,8 +2,14 @@
|
|||
|
||||
#if defined(__aarch64__)
|
||||
# define SNMALLOC_VA_BITS_64
|
||||
# ifdef _MSC_VER
|
||||
# include <arm64_neon.h>
|
||||
# endif
|
||||
#else
|
||||
# define SNMALLOC_VA_BITS_32
|
||||
# ifdef _MSC_VER
|
||||
# include <arm_neon.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
@ -20,13 +26,27 @@ namespace snmalloc
|
|||
*/
|
||||
static constexpr uint64_t aal_features =
|
||||
IntegerPointers | NoCpuCycleCounters;
|
||||
|
||||
/**
|
||||
* On pipelined processors, notify the core that we are in a spin loop and
|
||||
* that speculative execution past this point may not be a performance gain.
|
||||
*/
|
||||
static inline void pause()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
__yield();
|
||||
#else
|
||||
__asm__ volatile("yield");
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void prefetch(void* ptr)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
__prefetch(ptr);
|
||||
#else
|
||||
__asm__ inline("prfm pldl1keep, [%0]" : "=r"(ptr));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -37,12 +37,16 @@ namespace snmalloc
|
|||
template<bool page_aligned = false>
|
||||
void zero(void* p, size_t size) noexcept
|
||||
{
|
||||
// QEMU does not seem to be giving the desired behaviour for MADV_DONTNEED.
|
||||
// switch back to memset only for QEMU.
|
||||
# ifndef SNMALLOC_QEMU_WORKAROUND
|
||||
if (page_aligned || is_aligned_block<OS_PAGE_SIZE>(p, size))
|
||||
{
|
||||
SNMALLOC_ASSERT(is_aligned_block<OS_PAGE_SIZE>(p, size));
|
||||
madvise(p, size, MADV_DONTNEED);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
::memset(p, 0, size);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче