|author||David CARLIER <firstname.lastname@example.org>||2021-03-23 18:39:36 +0000|
|committer||Samuel Williams <email@example.com>||2021-03-29 09:32:40 +1300|
fiber context update for Mac OS.
it is more about memory accounting sake. At allocation time, we make clear we re possibly reusing regions marked as reusable. Noted also calls might not necessarily succeed at first so we do only when necessary.
Notes: Merged: https://github.com/ruby/ruby/pull/4313
1 files changed, 11 insertions, 1 deletions
@@ -433,6 +433,12 @@ fiber_pool_allocate_memory(size_t * count, size_t stride)
*count = (*count) >> 1;
+ // On Mac MADV_FREE_REUSE is necessary for the task_info api
+ // to keep the accounting accurate as possible when a page is marked as reusable
+ // it can possibly not occuring at first call thus re-iterating if necessary.
+ while (madvise(base, (*count)*stride, MADV_FREE_REUSE) == -1 && errno == EAGAIN);
@@ -649,7 +655,11 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack)
posix_madvise(base, size, POSIX_MADV_DONTNEED);
- madvise(base, size, MADV_FREE_REUSABLE);
+ // Acknowledge the kernel down to the task info api we make this
+ // page reusable for future use.
+ // As for MADV_FREE_REUSE below we ensure in the rare occassions the task was not
+ // completed at the time of the call to re-iterate.
+ while (madvise(base, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN);
madvise(base, size, MADV_FREE);