[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 19 commits: testsuite: Unmark T14028 as broken on FreeBSD
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Dec 11 21:30:40 UTC 2024
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
4a8fc928 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Unmark T14028 as broken on FreeBSD
This now appears to pass on FreeBSD 14.
Closes #19723.
- - - - -
d7c0eb5a by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Migrate FreeBSD runner tag to FreeBSD 14
- - - - -
7246dacc by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Reintroduce FreeBSD 14 job
- - - - -
4af936da by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Allow use of newer cabal-install bindists
Newer cabal-install bindists have internal directory structure.
Here we detect and account for the presence of such structure.
- - - - -
cbf38c1b by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Enable documentation build on FreeBSD 14
- - - - -
d68107fb by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Use system libffi on FreeBSD
- - - - -
fea3b590 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark linker_unload as broken on FreeeBSD
Due to #25491.
- - - - -
ccf171ee by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Prefer system toolchain on FreeBSD
It's not uncommon to find machines with gcc installed via ports. We
should be using the system's default clang-based toolchain instead.
- - - - -
cfb34738 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark T21969 as broken on FreeBSD
Due to #25512.
- - - - -
0b64e37c by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark RestartEventLogging as broken on FreeBSD
I am seeing this fail quite reproducibly.
Due to #19724.
- - - - -
3b412019 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark T16180 as "broken" on FreeBSD
Sadly we in fact need to skip it as it merely times out during
compilation.
See #14012.
- - - - -
57e3cab5 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Skip T16992 unless in slow speed
This test has extraordinary memory requirements and tests a rather
niche aspect of the compact region mechanism. It has been suggested
multiple times that we shouldn't run it in the default testsuite
configuration. Finally implement this.
See #21890.
See #21892.
- - - - -
c9a2b202 by Ben Gamari at 2024-12-11T16:30:13-05:00
rts(setNumCapabilities): Assert that n_caps < MAX_N_CAPS
It was noticed in #25560 that this would previously be allowed,
resulting in a segfault.
I will add a proper exception in `base` in a future commit.
- - - - -
ec1bce19 by Ben Gamari at 2024-12-11T16:30:13-05:00
ghc-internal: Fix inconsistent FFI import types
The foreign imports of `enabled_capabilities` and
`getNumberOfProcessors` were declared as `CInt` whereas they are defined
as `uint32_t`.
- - - - -
7589fa1c by Ben Gamari at 2024-12-11T16:30:13-05:00
rts: Mention maximum capability count in users guide
Addresses #25560.
- - - - -
25fb2d91 by Ben Gamari at 2024-12-11T16:30:13-05:00
rts/Capability: Move induction variable declaration into `for`s
Just a stylistic change.
- - - - -
258ed11f by Ben Gamari at 2024-12-11T16:30:13-05:00
rts: Determine max_n_capabilities at RTS startup
Previously the maximum number of capabilities supported by the RTS was
statically capped at 256. However, this bound is uncomfortably low given
the size of today's machine.
While supporting unbounded, fully-dynamic adjustment would be nice, it
is complex and so instead we do something simpler: Probe the logical
core count at RTS startup and use this as the static bound for the rest
of our execution.
This should avoid users running into the capability limit on large
machines while avoiding wasting memory on a large capabilities array for
most users and keeping complexity at bay.
Addresses #25560.
- - - - -
45c86903 by Ben Gamari at 2024-12-11T16:30:13-05:00
testsuite: Introduce req_c_rts
As suggested by @hsyl20, this is intended to mark tests that rely on the
behavior of the C RTS.
- - - - -
dc646c2d by Ben Gamari at 2024-12-11T16:30:13-05:00
testsuite: Add test for #25560
- - - - -
19 changed files:
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- docs/users_guide/using-concurrent.rst
- libraries/ghc-compact/tests/all.T
- libraries/ghc-internal/src/GHC/Internal/Conc/Sync.hs
- rts/Capability.c
- rts/Capability.h
- rts/RtsSymbols.c
- rts/Schedule.c
- rts/include/rts/Config.h
- rts/include/rts/Threads.h
- testsuite/driver/testlib.py
- testsuite/tests/concurrent/should_run/all.T
- testsuite/tests/quasiquotation/all.T
- + testsuite/tests/rts/T25560.hs
- testsuite/tests/rts/all.T
- testsuite/tests/rts/linker/all.T
- testsuite/tests/th/all.T
Changes:
=====================================
.gitlab/ci.sh
=====================================
@@ -326,13 +326,19 @@ function fetch_cabal() {
local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/"
case "$(uname)" in
Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;;
- FreeBSD) cabal_url="$base_url/cabal-install-$v-x86_64-freebsd13.tar.xz" ;;
+ FreeBSD) cabal_url="$base_url/cabal-install-$v-x86_64-freebsd14.tar.xz" ;;
*) fail "don't know where to fetch cabal-install for $(uname)"
esac
echo "Fetching cabal-install from $cabal_url"
curl "$cabal_url" > cabal.tar.xz
+ tmp="$(tar -tJf cabal.tar.xz | head -n1)"
$TAR -xJf cabal.tar.xz
- mv cabal "$toolchain/bin"
+ # Check if the bindist has directory structure
+ if [[ "$tmp" = "cabal" ]]; then
+ mv cabal "$toolchain/bin"
+ else
+ mv "$tmp/cabal" "$toolchain/bin"
+ fi
;;
esac
end_section "fetch cabal"
=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -101,7 +101,7 @@ There are two different modes this script can operate in:
data Opsys
= Linux LinuxDistro
| Darwin
- | FreeBSD13
+ | FreeBSD14
| Windows deriving (Eq)
data LinuxDistro
@@ -293,7 +293,7 @@ runnerTag arch (Linux _) =
runnerTag AArch64 Darwin = "aarch64-darwin"
runnerTag Amd64 Darwin = "x86_64-darwin-m1"
runnerTag Amd64 Windows = "new-x86_64-windows"
-runnerTag Amd64 FreeBSD13 = "x86_64-freebsd13"
+runnerTag Amd64 FreeBSD14 = "x86_64-freebsd14"
runnerTag _ _ = error "Invalid arch/opsys"
tags :: Arch -> Opsys -> BuildConfig -> [String]
@@ -326,7 +326,7 @@ distroName Rocky8 = "rocky8"
opsysName :: Opsys -> String
opsysName (Linux distro) = "linux-" ++ distroName distro
opsysName Darwin = "darwin"
-opsysName FreeBSD13 = "freebsd13"
+opsysName FreeBSD14 = "freebsd14"
opsysName Windows = "windows"
archName :: Arch -> String
@@ -423,15 +423,19 @@ brokenTest :: TestName -- ^ test name
brokenTest test _why = "BROKEN_TESTS" =: test
opsysVariables :: Arch -> Opsys -> Variables
-opsysVariables _ FreeBSD13 = mconcat
+opsysVariables _ FreeBSD14 = mconcat
[ -- N.B. we use iconv from ports as I see linker errors when we attempt
-- to use the "native" iconv embedded in libc as suggested by the
-- porting guide [1].
-- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html)
- "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib"
- , "HADRIAN_ARGS" =: "--docs=no-sphinx"
+ "CONFIGURE_ARGS" =: "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib"
+ , "CONFIGURE_ARGS" =: "--with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib"
+ , "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib"
+ -- Prefer to use the system's clang-based toolchain and not gcc
+ , "CC" =: "cc"
+ , "CXX" =: "c++"
, "GHC_VERSION" =: "9.6.4"
- , "CABAL_INSTALL_VERSION" =: "3.10.2.0"
+ , "CABAL_INSTALL_VERSION" =: "3.10.3.0"
]
opsysVariables arch (Linux distro) = distroVariables arch distro
opsysVariables AArch64 (Darwin {}) =
@@ -1140,6 +1144,11 @@ darwin =
, fastCI (standardBuilds AArch64 Darwin)
]
+freebsd_jobs :: [JobGroup Job]
+freebsd_jobs =
+ [ addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD14)
+ ]
+
alpine_x86 :: [JobGroup Job]
alpine_x86 =
[ -- Fully static build, in theory usable on any linux distribution.
@@ -1213,6 +1222,7 @@ job_groups =
++ alpine_x86
++ alpine_aarch64
++ cross_jobs
+ ++ freebsd_jobs
mkPlatform :: Arch -> Opsys -> String
=====================================
.gitlab/jobs.yaml
=====================================
@@ -1082,6 +1082,72 @@
"ac_cv_func_utimensat": "no"
}
},
+ "nightly-x86_64-freebsd14-validate": {
+ "after_script": [
+ ".gitlab/ci.sh save_cache",
+ ".gitlab/ci.sh save_test_output",
+ ".gitlab/ci.sh clean",
+ "cat ci_timings"
+ ],
+ "allow_failure": false,
+ "artifacts": {
+ "expire_in": "8 weeks",
+ "paths": [
+ "ghc-x86_64-freebsd14-validate.tar.xz",
+ "junit.xml",
+ "unexpected-test-output.tar.gz"
+ ],
+ "reports": {
+ "junit": "junit.xml"
+ },
+ "when": "always"
+ },
+ "cache": {
+ "key": "x86_64-freebsd14-$CACHE_REV",
+ "paths": [
+ "cabal-cache",
+ "toolchain"
+ ]
+ },
+ "dependencies": [],
+ "image": null,
+ "needs": [
+ {
+ "artifacts": false,
+ "job": "hadrian-ghc-in-ghci"
+ }
+ ],
+ "rules": [
+ {
+ "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY)",
+ "when": "on_success"
+ }
+ ],
+ "script": [
+ ".gitlab/ci.sh setup",
+ ".gitlab/ci.sh configure",
+ ".gitlab/ci.sh build_hadrian",
+ ".gitlab/ci.sh test_hadrian"
+ ],
+ "stage": "full-build",
+ "tags": [
+ "x86_64-freebsd14"
+ ],
+ "variables": {
+ "BIGNUM_BACKEND": "gmp",
+ "BIN_DIST_NAME": "ghc-x86_64-freebsd14-validate",
+ "BUILD_FLAVOUR": "validate",
+ "CABAL_INSTALL_VERSION": "3.10.3.0",
+ "CC": "cc",
+ "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
+ "CXX": "c++",
+ "GHC_VERSION": "9.6.4",
+ "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
+ "RUNTEST_ARGS": "",
+ "TEST_ENV": "x86_64-freebsd14-validate",
+ "XZ_OPT": "-9"
+ }
+ },
"nightly-x86_64-linux-alpine3_12-int_native-validate+fully_static": {
"after_script": [
".gitlab/ci.sh save_cache",
@@ -3844,6 +3910,74 @@
"ac_cv_func_utimensat": "no"
}
},
+ "release-x86_64-freebsd14-release": {
+ "after_script": [
+ ".gitlab/ci.sh save_cache",
+ ".gitlab/ci.sh save_test_output",
+ ".gitlab/ci.sh clean",
+ "cat ci_timings"
+ ],
+ "allow_failure": false,
+ "artifacts": {
+ "expire_in": "1 year",
+ "paths": [
+ "ghc-x86_64-freebsd14-release.tar.xz",
+ "junit.xml",
+ "unexpected-test-output.tar.gz"
+ ],
+ "reports": {
+ "junit": "junit.xml"
+ },
+ "when": "always"
+ },
+ "cache": {
+ "key": "x86_64-freebsd14-$CACHE_REV",
+ "paths": [
+ "cabal-cache",
+ "toolchain"
+ ]
+ },
+ "dependencies": [],
+ "image": null,
+ "needs": [
+ {
+ "artifacts": false,
+ "job": "hadrian-ghc-in-ghci"
+ }
+ ],
+ "rules": [
+ {
+ "if": "(\"true\" == \"true\") && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null)",
+ "when": "on_success"
+ }
+ ],
+ "script": [
+ ".gitlab/ci.sh setup",
+ ".gitlab/ci.sh configure",
+ ".gitlab/ci.sh build_hadrian",
+ ".gitlab/ci.sh test_hadrian"
+ ],
+ "stage": "full-build",
+ "tags": [
+ "x86_64-freebsd14"
+ ],
+ "variables": {
+ "BIGNUM_BACKEND": "gmp",
+ "BIN_DIST_NAME": "ghc-x86_64-freebsd14-release",
+ "BUILD_FLAVOUR": "release",
+ "CABAL_INSTALL_VERSION": "3.10.3.0",
+ "CC": "cc",
+ "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
+ "CXX": "c++",
+ "GHC_VERSION": "9.6.4",
+ "HADRIAN_ARGS": "--hash-unit-ids",
+ "IGNORE_PERF_FAILURES": "all",
+ "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
+ "RUNTEST_ARGS": "",
+ "TEST_ENV": "x86_64-freebsd14-release",
+ "XZ_OPT": "-9"
+ }
+ },
"release-x86_64-linux-alpine3_12-int_native-release+fully_static": {
"after_script": [
".gitlab/ci.sh save_cache",
@@ -5222,6 +5356,71 @@
"ac_cv_func_utimensat": "no"
}
},
+ "x86_64-freebsd14-validate": {
+ "after_script": [
+ ".gitlab/ci.sh save_cache",
+ ".gitlab/ci.sh save_test_output",
+ ".gitlab/ci.sh clean",
+ "cat ci_timings"
+ ],
+ "allow_failure": false,
+ "artifacts": {
+ "expire_in": "2 weeks",
+ "paths": [
+ "ghc-x86_64-freebsd14-validate.tar.xz",
+ "junit.xml",
+ "unexpected-test-output.tar.gz"
+ ],
+ "reports": {
+ "junit": "junit.xml"
+ },
+ "when": "always"
+ },
+ "cache": {
+ "key": "x86_64-freebsd14-$CACHE_REV",
+ "paths": [
+ "cabal-cache",
+ "toolchain"
+ ]
+ },
+ "dependencies": [],
+ "image": null,
+ "needs": [
+ {
+ "artifacts": false,
+ "job": "hadrian-ghc-in-ghci"
+ }
+ ],
+ "rules": [
+ {
+ "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-freebsd14-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && ((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/)))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
+ "when": "on_success"
+ }
+ ],
+ "script": [
+ ".gitlab/ci.sh setup",
+ ".gitlab/ci.sh configure",
+ ".gitlab/ci.sh build_hadrian",
+ ".gitlab/ci.sh test_hadrian"
+ ],
+ "stage": "full-build",
+ "tags": [
+ "x86_64-freebsd14"
+ ],
+ "variables": {
+ "BIGNUM_BACKEND": "gmp",
+ "BIN_DIST_NAME": "ghc-x86_64-freebsd14-validate",
+ "BUILD_FLAVOUR": "validate",
+ "CABAL_INSTALL_VERSION": "3.10.3.0",
+ "CC": "cc",
+ "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
+ "CXX": "c++",
+ "GHC_VERSION": "9.6.4",
+ "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
+ "RUNTEST_ARGS": "",
+ "TEST_ENV": "x86_64-freebsd14-validate"
+ }
+ },
"x86_64-linux-alpine3_12-int_native-validate+fully_static": {
"after_script": [
".gitlab/ci.sh save_cache",
=====================================
docs/users_guide/using-concurrent.rst
=====================================
@@ -153,6 +153,14 @@ use the RTS :rts-flag:`-N ⟨x⟩` options.
changed while the program is running by calling
``Control.Concurrent.setNumCapabilities``.
+
+.. note::
+
+ The maximum number of capabilities supported by the GHC runtime system is
+ determined when at RTS startup to be either 256, the value given by
+ :rts-flag:`-N ⟨x⟩`, or the number of logical CPU cores, whichever is
+ greater.
+
The following options affect the way the runtime schedules threads on
CPUs:
=====================================
libraries/ghc-compact/tests/all.T
=====================================
@@ -28,5 +28,8 @@ test('T18757', omit_ghci, compile_and_run, [''])
# N.B. Sanity check times out due to large list.
test('T16992', [when(wordsize(32), skip), # Resource limit exceeded on 32-bit
high_memory_usage,
+ # This test has extraordinary memory requirement,
+ # skip unless testing slow speed
+ unless(slow(), skip),
run_timeout_multiplier(5),
omit_ways(['sanity'])], compile_and_run, [''])
=====================================
libraries/ghc-internal/src/GHC/Internal/Conc/Sync.hs
=====================================
@@ -1,4 +1,3 @@
-{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
@@ -394,13 +393,14 @@ getNumProcessors :: IO Int
getNumProcessors = fmap fromIntegral c_getNumberOfProcessors
foreign import ccall unsafe "getNumberOfProcessors"
- c_getNumberOfProcessors :: IO CUInt
+ c_getNumberOfProcessors :: IO Word32
-- | Returns the number of sparks currently in the local spark pool
numSparks :: IO Int
numSparks = IO $ \s -> case numSparks# s of (# s', n #) -> (# s', I# n #)
-foreign import ccall "&enabled_capabilities" enabled_capabilities :: Ptr CInt
+foreign import ccall "&enabled_capabilities"
+ enabled_capabilities :: Ptr Word32
childHandler :: SomeException -> IO ()
childHandler err = catch (real_handler err) childHandler
=====================================
rts/Capability.c
=====================================
@@ -16,6 +16,7 @@
*
* --------------------------------------------------------------------------*/
+#include "rts/Config.h"
#include "rts/PosixSource.h"
#include "Rts.h"
@@ -40,12 +41,16 @@ Capability MainCapability;
uint32_t n_capabilities = 0;
uint32_t enabled_capabilities = 0;
+// The size of the `capabilities` array initialized at RTS startup. Referenced
+// by GHC.Internal.Conc.Sync
+uint32_t max_n_capabilities = MAX_N_CAPABILITIES;
+
// The array of Capabilities. It's important that when we need
// to allocate more Capabilities we don't have to move the existing
// Capabilities, because there may be pointers to them in use
// (e.g. threads in waitForCapability(), see #8209), so this is
// an array of Capability* rather than an array of Capability.
-Capability *capabilities[MAX_N_CAPABILITIES];
+Capability **capabilities;
// Holds the Capability which last became free. This is used so that
// an in-call has a chance of quickly finding a free Capability.
@@ -344,8 +349,6 @@ initCapability (Capability *cap, uint32_t i)
* ------------------------------------------------------------------------- */
void initCapabilities (void)
{
- uint32_t i;
-
/* Declare a couple capability sets representing the process and
clock domain. Each capability will get added to these capsets. */
traceCapsetCreate(CAPSET_OSPROCESS_DEFAULT, CapsetTypeOsProcess);
@@ -354,7 +357,7 @@ void initCapabilities (void)
// Initialise NUMA
if (!RtsFlags.GcFlags.numa) {
n_numa_nodes = 1;
- for (i = 0; i < MAX_NUMA_NODES; i++) {
+ for (uint32_t i = 0; i < MAX_NUMA_NODES; i++) {
numa_map[i] = 0;
}
} else if (RtsFlags.DebugFlags.numa) {
@@ -388,12 +391,30 @@ void initCapabilities (void)
}
#endif
- if (RtsFlags.ParFlags.nCapabilities > MAX_N_CAPABILITIES) {
- errorBelch("warning: this GHC runtime system only supports up to %d capabilities",
- MAX_N_CAPABILITIES);
- RtsFlags.ParFlags.nCapabilities = MAX_N_CAPABILITIES;
+ /*
+ * Note [Capabilities array sizing]
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * Determine the size of the capabilities array as the maximum of:
+ * * the static lower bound, `MAX_N_CAPABILITIES`
+ * * the logical core count
+ * * the users's choice of `+RTS -N`
+ * This will serve as the upper bound on the capability count for the rest
+ * of execution. Calls to `setNumCapabilities` exceeding this bound will
+ * issue a warning and otherwise have no effect.
+ *
+ * See #25560.
+ */
+ uint32_t core_count = getNumberOfProcessors();
+ if (core_count > max_n_capabilities) {
+ max_n_capabilities = core_count;
}
+ if (RtsFlags.ParFlags.nCapabilities > max_n_capabilities) {
+ max_n_capabilities = RtsFlags.ParFlags.nCapabilities;
+ }
+
+ capabilities = stgMallocBytes(sizeof(Capability) * max_n_capabilities, "initCapabilities");
+
n_capabilities = 0;
moreCapabilities(0, RtsFlags.ParFlags.nCapabilities);
n_capabilities = RtsFlags.ParFlags.nCapabilities;
@@ -401,6 +422,7 @@ void initCapabilities (void)
#else /* !THREADED_RTS */
n_capabilities = 1;
+ capabilities = stgMallocBytes(sizeof(Capability), "initCapabilities");
capabilities[0] = &MainCapability;
initCapability(&MainCapability, 0);
@@ -412,7 +434,7 @@ void initCapabilities (void)
// There are no free capabilities to begin with. We will start
// a worker Task to each Capability, which will quickly put the
// Capability on the free list when it finds nothing to do.
- for (i = 0; i < n_numa_nodes; i++) {
+ for (uint32_t i = 0; i < n_numa_nodes; i++) {
last_free_capability[i] = getCapability(0);
}
}
=====================================
rts/Capability.h
=====================================
@@ -270,11 +270,13 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED,
// extern Capability MainCapability;
// declared in rts/include/rts/Threads.h:
+// extern uint32_t max_n_capabilities;
// extern uint32_t n_capabilities;
// extern uint32_t enabled_capabilities;
-// Array of all the capabilities
-extern Capability *capabilities[MAX_N_CAPABILITIES];
+// Array of all the capabilities, of size max_n_capabilities
+// See Note [Capabilities array sizing] in rts/Capability.c.
+extern Capability **capabilities;
INLINE_HEADER Capability *getCapability(uint32_t i)
{
=====================================
rts/RtsSymbols.c
=====================================
@@ -909,6 +909,7 @@ extern char **environ;
SymI_NeedsDataProto(rts_stop_on_exception) \
SymI_HasProto(stopTimer) \
SymI_HasProto(n_capabilities) \
+ SymI_HasProto(max_n_capabilities) \
SymI_HasProto(enabled_capabilities) \
SymI_HasDataProto(stg_traceEventzh) \
SymI_HasDataProto(stg_traceMarkerzh) \
=====================================
rts/Schedule.c
=====================================
@@ -2288,9 +2288,12 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS)
} else if (new_n_capabilities <= 0) {
errorBelch("setNumCapabilities: Capability count must be positive");
return;
+ } else if (new_n_capabilities > max_n_capabilities) {
+ // See Note [Capabilities array sizing] in rts/Capability.c.
+ errorBelch("setNumCapabilities: Attempt to increase capability count beyond maximum capability count %" PRIu32 "; clamping...\n", max_n_capabilities);
+ new_n_capabilities = max_n_capabilities;
}
-
debugTrace(DEBUG_sched, "changing the number of Capabilities from %d to %d",
enabled_capabilities, new_n_capabilities);
=====================================
rts/include/rts/Config.h
=====================================
@@ -78,6 +78,10 @@ code.
#endif
#if defined(THREADED_RTS)
+/*
+ * See Note [Capabilities array sizing] in rts/Capability.c.
+ * Update the note in docs/users_guide/using-concurrent.rst when updating this.
+ */
#define MAX_N_CAPABILITIES 256
#else
#define MAX_N_CAPABILITIES 1
=====================================
rts/include/rts/Threads.h
=====================================
@@ -69,7 +69,7 @@ HsBool rtsSupportsBoundThreads (void);
// The number of Capabilities.
// TODO: Ideally we would only provide getNumCapabilities
// but this is used in compiler/cbits/genSym.c
-extern unsigned int n_capabilities;
+extern uint32_t n_capabilities;
INLINE_HEADER unsigned int getNumCapabilities(void)
{ return RELAXED_LOAD(&n_capabilities); }
@@ -77,6 +77,10 @@ INLINE_HEADER unsigned int getNumCapabilities(void)
// The number of Capabilities that are not disabled
extern uint32_t enabled_capabilities;
+// The maximum number of Capabilities supported by the RTS.
+// See Note [Capabilities array sizing] in rts/Capability.c.
+extern uint32_t max_n_capabilities;
+
#if !IN_STG_CODE
extern Capability MainCapability;
#endif
=====================================
testsuite/driver/testlib.py
=====================================
@@ -270,6 +270,10 @@ def req_bco( name, opts ):
# JS backend doesn't support ByteCode
js_skip(name, opts)
+def req_c_rts( name, opts ):
+ """ Require the C runtime system (rather than, e.g. the Javascript RTS). """
+ js_skip(name, opts)
+
def req_rts_linker( name, opts ):
if not config.have_RTS_linker:
opts.expect = 'fail'
@@ -970,6 +974,9 @@ def tables_next_to_code() -> bool:
def fast() -> bool:
return config.speed == 2
+def slow() -> bool:
+ return config.speed == 0
+
def platform( plat: str ) -> bool:
return config.platform == plat
=====================================
testsuite/tests/concurrent/should_run/all.T
=====================================
@@ -268,6 +268,7 @@ test('T21651',
test('T21969',
[ only_ways(['threaded1','threaded2', 'nonmoving_thr', 'profthreaded']),
when(opsys('mingw32'),skip), # uses POSIX pipes
+ when(opsys('freebsd'), expect_broken(25512)),
extra_run_opts('50000'),
run_timeout_multiplier(0.3), # default timeout seems to be 300, but lockups happen quickly
req_target_smp,
=====================================
testsuite/tests/quasiquotation/all.T
=====================================
@@ -8,6 +8,5 @@ test('T7918',
test('T14028',
[req_interp, req_rts_linker,
only_ways([config.ghc_th_way]),
- unless(config.have_ext_interp, skip),
- when(opsys('freebsd'), expect_broken(19723))],
+ unless(config.have_ext_interp, skip)],
makefile_test, ['T14028 ghcThWayFlags=' + config.ghc_th_way_flags])
=====================================
testsuite/tests/rts/T25560.hs
=====================================
@@ -0,0 +1,4 @@
+import GHC.Conc
+
+main :: IO ()
+main = setNumCapabilities 100000
=====================================
testsuite/tests/rts/all.T
=====================================
@@ -531,7 +531,9 @@ test('InitEventLogging',
],
compile_and_run, ['InitEventLogging_c.c'])
test('RestartEventLogging',
- [only_ways(['threaded1','threaded2']), extra_run_opts('+RTS -la -RTS')],
+ [only_ways(['threaded1','threaded2']),
+ extra_run_opts('+RTS -la -RTS'),
+ when(opsys('freebsd'), fragile(19724))],
compile_and_run, ['RestartEventLogging_c.c'])
test('T17088',
@@ -630,3 +632,7 @@ test('T24142', [req_target_smp], compile_and_run, ['-threaded -with-rtsopts "-N2
test('T25232', [unless(have_profiling(), skip), only_ways(['normal','nonmoving','nonmoving_prof','nonmoving_thr_prof']), extra_ways(['nonmoving', 'nonmoving_prof'] + (['nonmoving_thr_prof'] if have_threaded() else []))], compile_and_run, [''])
test('T25280', [unless(opsys('linux'),skip),req_process,js_skip], compile_and_run, [''])
+
+# N.B. This will likely issue a warning on stderr but we merely care that the
+# program doesn't crash.
+test('T25560', [req_c_rts, ignore_stderr], compile_and_run, [''])
=====================================
testsuite/tests/rts/linker/all.T
=====================================
@@ -108,6 +108,7 @@ test('T5435_dyn_gcc',
######################################
test('linker_unload',
[extra_files(['LinkerUnload.hs', 'Test.hs']),
+ when(opsys('freebsd'), expect_broken(25491)),
req_rts_linker],
makefile_test, ['linker_unload'])
=====================================
testsuite/tests/th/all.T
=====================================
@@ -488,9 +488,9 @@ test('T15471', normal, multimod_compile, ['T15471.hs', '-v0'])
test('T16180',
[when(llvm_build(), expect_broken_for(16541, ['ext-interp'])),
req_asm,
- # Ideally OpenBSD should have expect_broken_for(14012, ['ext-interp']).
+ # Ideally {Free,Open}BSD should have expect_broken_for(14012, ['ext-interp']).
# Except the failure is in compilation so skip seems the best we can do.
- when(opsys('openbsd'), skip),
+ when(opsys('openbsd') or opsys('freebsd'), skip),
expect_broken_for(16541, ghci_ways)],
compile_and_run, ['-package ghc'])
test('T16183', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02455f7788ed8839195333651aa34e70a660bb34...dc646c2d19c46899e67d205e80d79185c0c2279d
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02455f7788ed8839195333651aa34e70a660bb34...dc646c2d19c46899e67d205e80d79185c0c2279d
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/20241211/13bc79d5/attachment-0001.html>
More information about the ghc-commits
mailing list