diff --git a/mfbt/TaggedAnonymousMemory.cpp b/mfbt/TaggedAnonymousMemory.cpp index 9e66a56c5094..382b9cef7ad3 100644 --- a/mfbt/TaggedAnonymousMemory.cpp +++ b/mfbt/TaggedAnonymousMemory.cpp @@ -53,38 +53,28 @@ static uintptr_t GetPageMask() { } // namespace mozilla -int MozTaggedMemoryIsSupported(void) { - static int supported = -1; - - if (supported == -1) { - // Tagging an empty range always "succeeds" if the feature is supported, - // regardless of the start pointer. - supported = mozilla::TagAnonymousMemoryAligned(nullptr, 0, nullptr) == 0; - } - return supported; -} - void MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag) { - if (MozTaggedMemoryIsSupported()) { - // The kernel will round up the end of the range to the next page - // boundary if it's not aligned (comments indicate this behavior - // is based on that of madvise), but it will reject the request if - // the start is not aligned. We therefore round down the start - // address and adjust the length accordingly. - uintptr_t addr = reinterpret_cast(aPtr); - uintptr_t end = addr + aLength; - uintptr_t addrRounded = addr & mozilla::GetPageMask(); - const void* ptrRounded = reinterpret_cast(addrRounded); + // The kernel will round up the end of the range to the next page + // boundary if it's not aligned (comments indicate this behavior is + // based on that of madvise), but it will reject the request if the + // start is not aligned. We therefore round down the start address + // and adjust the length accordingly. + uintptr_t addr = reinterpret_cast(aPtr); + uintptr_t end = addr + aLength; + uintptr_t addrRounded = addr & mozilla::GetPageMask(); + const void* ptrRounded = reinterpret_cast(addrRounded); - mozilla::TagAnonymousMemoryAligned(ptrRounded, end - addrRounded, aTag); - } + // Ignore the return value. TagAnonymousMemoryAligned will harmlessly fail on + // kernels without CONFIG_ANON_VMA_NAME. + mozilla::TagAnonymousMemoryAligned(ptrRounded, end - addrRounded, aTag); } void* MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags, int aFd, off_t aOffset, const char* aTag) { void* mapped = mmap(aAddr, aLength, aProt, aFlags, aFd, aOffset); - if (MozTaggedMemoryIsSupported() && - (aFlags & MAP_ANONYMOUS) == MAP_ANONYMOUS && mapped != MAP_FAILED) { + if ((aFlags & MAP_ANONYMOUS) == MAP_ANONYMOUS && mapped != MAP_FAILED) { + // Ignore the return value. TagAnonymousMemoryAligned will harmlessly fail + // on kernels without CONFIG_ANON_VMA_NAME. mozilla::TagAnonymousMemoryAligned(mapped, aLength, aTag); } return mapped; diff --git a/mfbt/TaggedAnonymousMemory.h b/mfbt/TaggedAnonymousMemory.h index ddd4713a7800..7ca5e60c9d08 100644 --- a/mfbt/TaggedAnonymousMemory.h +++ b/mfbt/TaggedAnonymousMemory.h @@ -55,8 +55,6 @@ MFBT_API void* MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags, int aFd, off_t aOffset, const char* aTag); -MFBT_API int MozTaggedMemoryIsSupported(void); - # ifdef __cplusplus } // extern "C" # endif @@ -77,8 +75,6 @@ static inline void* MozTaggedAnonymousMmap(void* aAddr, size_t aLength, # endif } -static inline int MozTaggedMemoryIsSupported(void) { return 0; } - # endif // XP_LINUX #endif // !XP_WIN