Commit 2df2c550 authored by Nathan Bronson's avatar Nathan Bronson Committed by Noam Lerner

disable stack madvise optimization on non-Linux platforms

Summary:
This diff strengthens the preconditions for attempting to use
optimize by madvising away idle stacks, because it seemed to be causing
problems on OS X (https://github.com/facebook/proxygen/issues/3).

Test Plan: unit tests

Reviewed By: ldbrandy@fb.com

Subscribers: folly-diffs@, yfeldblum, chalfant

FB internal diff: D2129100

Signature: t1:2129100:1433458268:0b6b3696dde6c2bd13b89bc7ec58f0b1898be458
parent 59badf85
...@@ -80,7 +80,10 @@ void MemoryIdler::flushLocalMallocCaches() { ...@@ -80,7 +80,10 @@ void MemoryIdler::flushLocalMallocCaches() {
} }
#if FOLLY_X64 // Stack madvise isn't Linux or glibc specific, but the system calls
// and arithmetic (and bug compatibility) are not portable. The set of
// platforms could be increased if it was useful.
#if FOLLY_X64 && defined(_GNU_SOURCE) && defined(__linux__)
static const size_t s_pageSize = sysconf(_SC_PAGESIZE); static const size_t s_pageSize = sysconf(_SC_PAGESIZE);
static FOLLY_TLS uintptr_t tls_stackLimit; static FOLLY_TLS uintptr_t tls_stackLimit;
...@@ -88,11 +91,7 @@ static FOLLY_TLS size_t tls_stackSize; ...@@ -88,11 +91,7 @@ static FOLLY_TLS size_t tls_stackSize;
static void fetchStackLimits() { static void fetchStackLimits() {
pthread_attr_t attr; pthread_attr_t attr;
#if defined(_GNU_SOURCE) && defined(__linux__) // Linux+GNU extension
pthread_getattr_np(pthread_self(), &attr); pthread_getattr_np(pthread_self(), &attr);
#else
pthread_attr_init(&attr);
#endif
SCOPE_EXIT { pthread_attr_destroy(&attr); }; SCOPE_EXIT { pthread_attr_destroy(&attr); };
void* addr; void* addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment