[Git][ghc/ghc][wip/T22264] 6 commits: nonmoving: Add missing no-op in busy-wait loop
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Mon Dec 5 18:28:07 UTC 2022
Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC
Commits:
ae95ecac by Ben Gamari at 2022-12-04T16:18:47-05:00
nonmoving: Add missing no-op in busy-wait loop
- - - - -
4bb3c523 by Ben Gamari at 2022-12-04T16:19:25-05:00
nonmoving: Clarify comment
- - - - -
f885b896 by Ben Gamari at 2022-12-04T16:41:15-05:00
nonmoving: Don't push if nonmoving collector isn't enabled
- - - - -
d2b42867 by Ben Gamari at 2022-12-04T19:54:23-05:00
setNumCapabilities
- - - - -
ba130fcd by Ben Gamari at 2022-12-04T19:54:34-05:00
nonmovingMark: noop
- - - - -
8ce0eb1f by Ben Gamari at 2022-12-04T19:54:44-05:00
nonmoving: Disable shortcutting
- - - - -
6 changed files:
- libraries/base/GHC/Conc/Sync.hs
- rts/Schedule.c
- rts/include/rts/Threads.h
- rts/sm/NonMoving.h
- rts/sm/NonMovingMark.c
- rts/sm/NonMovingShortcut.c
Changes:
=====================================
libraries/base/GHC/Conc/Sync.hs
=====================================
@@ -380,10 +380,15 @@ to avoid contention with other processes in the machine.
setNumCapabilities :: Int -> IO ()
setNumCapabilities i
| i <= 0 = failIO $ "setNumCapabilities: Capability count ("++show i++") must be positive"
- | otherwise = c_setNumCapabilities (fromIntegral i)
+ | otherwise = do
+ ret <- c_setNumCapabilities (fromIntegral i)
+ case ret of
+ 0 -> return ()
+ 1 -> yield >> setNumCapabilities i
+ _ -> failIO $ "setNumCapabilities: Unknown result"
foreign import ccall safe "setNumCapabilities"
- c_setNumCapabilities :: CUInt -> IO ()
+ c_setNumCapabilities :: CUInt -> IO CInt
-- | Returns the number of CPUs that the machine has
--
=====================================
rts/Schedule.c
=====================================
@@ -2212,9 +2212,12 @@ forkProcess(HsStablePtr *entry
* Finally we release the Capabilities we are holding, and start
* worker Tasks on the new Capabilities we created.
*
+ * One wrinkle here is that we must also ensure that we don't change the
+ * capability count while the nonmoving mark thread is active.
+ *
* ------------------------------------------------------------------------- */
-void
+int
setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS)
{
#if !defined(THREADED_RTS)
@@ -2234,11 +2237,15 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS)
Capability *old_capabilities = NULL;
uint32_t old_n_capabilities = n_capabilities;
+ if (RELAXED_LOAD(&concurrent_coll_running)) {
+ return 1;
+ }
+
if (new_n_capabilities == enabled_capabilities) {
- return;
+ return 0;
} else if (new_n_capabilities <= 0) {
errorBelch("setNumCapabilities: Capability count must be positive");
- return;
+ return 1;
}
@@ -2340,6 +2347,7 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS)
rts_unlock(cap);
+ return 0;
#endif // THREADED_RTS
}
=====================================
rts/include/rts/Threads.h
=====================================
@@ -85,4 +85,4 @@ extern Capability MainCapability;
// Change the number of capabilities (only supports increasing the
// current value at the moment).
//
-extern void setNumCapabilities (uint32_t new_);
+extern int setNumCapabilities (uint32_t new_);
=====================================
rts/sm/NonMoving.h
=====================================
@@ -344,7 +344,7 @@ INLINE_HEADER bool nonmovingClosureBeingSwept(StgClosure *p)
INLINE_HEADER bool isNonmovingClosure(StgClosure *p)
{
- return !HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING;
+ return RtsFlags.GcFlags.useNonmoving && (!HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING);
}
#if defined(DEBUG)
=====================================
rts/sm/NonMovingMark.c
=====================================
@@ -1319,8 +1319,11 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
goto done;
case WHITEHOLE:
- while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info);
- // busy_wait_nop(); // FIXME
+ while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info)
+#if defined(PARALLEL_GC)
+ busy_wait_nop()
+#endif
+ ;
goto try_again;
default:
@@ -1599,7 +1602,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
// selectee unreachable. However, we must mark the selectee regardless
// to satisfy the snapshot invariant.
PUSH_FIELD(sel, selectee);
- nonmoving_eval_thunk_selector(queue, sel, origin);
+ //nonmoving_eval_thunk_selector(queue, sel, origin);
break;
}
=====================================
rts/sm/NonMovingShortcut.c
=====================================
@@ -42,7 +42,7 @@ update_selector_chain(
) {
ASSERT(val != NULL);
- // Make sure we don't introduce non-moving-to-moving pointers here.
+ // Make sure we don't introduce nonmoving-to-moving pointers here.
ASSERT(isNonmovingClosure(val));
// This case we can't handle because we don't know info ptr of the closure
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f095454b5bcf0d604e62c784931f80b5d7f0fb88...8ce0eb1fc8563838fe6b6ec151eedba395a2e0d1
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f095454b5bcf0d604e62c784931f80b5d7f0fb88...8ce0eb1fc8563838fe6b6ec151eedba395a2e0d1
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221205/62aab2dc/attachment-0001.html>
More information about the ghc-commits
mailing list