Commit db0b6239 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Fix #6292. mincore is broken on centos 5.8, so workaround it. {{{svn merge...

Fix #6292.  mincore is broken on centos 5.8, so workaround it. {{{svn merge -r54513:54514 https://svn.tokutek.com/tokudb/toku/tokudb.6292}}}.

git-svn-id: file:///svn/toku/tokudb@54515 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6c2abeda
...@@ -50,7 +50,6 @@ static bool check_huge_pages_config_file(const char *fname) ...@@ -50,7 +50,6 @@ static bool check_huge_pages_config_file(const char *fname)
static bool check_huge_pages_in_practice(void) static bool check_huge_pages_in_practice(void)
// Effect: Return true if huge pages appear to be defined in practice. // Effect: Return true if huge pages appear to be defined in practice.
{ {
return false;
const size_t TWO_MB = 2UL*1024UL*1024UL; const size_t TWO_MB = 2UL*1024UL*1024UL;
void *first = mmap(NULL, 2*TWO_MB, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); void *first = mmap(NULL, 2*TWO_MB, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
...@@ -70,6 +69,11 @@ static bool check_huge_pages_in_practice(void) ...@@ -70,6 +69,11 @@ static bool check_huge_pages_in_practice(void)
unsigned char vec[n_pages]; unsigned char vec[n_pages];
{ {
int r = mincore(second, TWO_MB, vec); int r = mincore(second, TWO_MB, vec);
if (r!=0 && errno==ENOMEM) {
// On some kernels (e.g., Centos 5.8), mincore doesn't work. It seems unlikely that huge pages are here.
munmap(second, TWO_MB);
return false;
}
assert(r==0); assert(r==0);
} }
for (long i=0; i<n_pages; i++) { for (long i=0; i<n_pages; i++) {
...@@ -78,6 +82,7 @@ static bool check_huge_pages_in_practice(void) ...@@ -78,6 +82,7 @@ static bool check_huge_pages_in_practice(void)
((char*)second)[0] = 1; ((char*)second)[0] = 1;
{ {
int r = mincore(second, TWO_MB, vec); int r = mincore(second, TWO_MB, vec);
// If the mincore worked the first time, it probably works here too.x
assert(r==0); assert(r==0);
} }
assert(vec[0]); assert(vec[0]);
......
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