[前][次][番号順一覧][スレッド一覧]

ruby-changes:65685

From: David <ko1@a...>
Date: Mon, 29 Mar 2021 05:32:52 +0900 (JST)
Subject: [ruby-changes:65685] 875c85a8bd (master): fiber context update for Mac OS.

https://git.ruby-lang.org/ruby.git/commit/?id=875c85a8bd

From 875c85a8bdca6cc2c7d0a26291ec4a6b2647b195 Mon Sep 17 00:00:00 2001
From: David CARLIER <devnexen@g...>
Date: Tue, 23 Mar 2021 18:39:36 +0000
Subject: 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.
---
 cont.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/cont.c b/cont.c
index 7fbca90..0d95a09 100644
--- a/cont.c
+++ b/cont.c
@@ -433,6 +433,12 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) https://github.com/ruby/ruby/blob/trunk/cont.c#L433
             *count = (*count) >> 1;
         }
         else {
+#if defined(MADV_FREE_REUSE)
+            // 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);
+#endif
             return base;
         }
 #endif
@@ -649,7 +655,11 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack) https://github.com/ruby/ruby/blob/trunk/cont.c#L655
 #elif defined(POSIX_MADV_DONTNEED)
     posix_madvise(base, size, POSIX_MADV_DONTNEED);
 #elif defined(MADV_FREE_REUSABLE)
-    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);
 #elif defined(MADV_FREE)
     madvise(base, size, MADV_FREE);
 #elif defined(MADV_DONTNEED)
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]