rpm/0002-Cap-number-of-threads-on-32bit-platforms-add-a-tunab.patch
2019-08-23 14:12:34 +03:00

61 lines
2.1 KiB
Diff

From 4c772fcf7114d6ce20800c12bc377b490d267548 Mon Sep 17 00:00:00 2001
Message-Id: <4c772fcf7114d6ce20800c12bc377b490d267548.1566558648.git.pmatilai@redhat.com>
In-Reply-To: <4d16d81a1af3e43b8392e7c335f616c9c0c6e41b.1566558648.git.pmatilai@redhat.com>
References: <4d16d81a1af3e43b8392e7c335f616c9c0c6e41b.1566558648.git.pmatilai@redhat.com>
From: Panu Matilainen <pmatilai@redhat.com>
Date: Fri, 23 Aug 2019 11:17:21 +0300
Subject: [PATCH 2/2] Cap number of threads on 32bit platforms, add a tunable
(RhBug:1729382)
On 32bit plaforms, address space is easily exhausted with multiple
threads, causing arbitrary builds failure regressions (RhBug:1729382).
Simply cap the number of threads to maximum of four on any 32bit
platform to play it safe. It's still three more than we were able to
use on older releases...
In addition, introduce a separate tunable for tweaking the maximum
number of threads just in case, defaulting to max CPUs available.
---
build/parseSpec.c | 10 +++++++++-
platform.in | 3 +++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 737a1233c..ab3ba9cae 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -1035,7 +1035,15 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
#ifdef ENABLE_OPENMP
/* Set number of OMP threads centrally */
- int ncpus = rpmExpandNumeric("%{?_smp_build_ncpus}");
+ int ncpus = rpmExpandNumeric("%{?_smp_nthreads_max}");
+#if __WORDSIZE == 32
+ /* On 32bit platforms, address space shortage is an issue. Play safe. */
+ if (ncpus <= 0 || ncpus > 4) {
+ ncpus = 4;
+ rpmlog(RPMLOG_DEBUG,
+ "limiting number of threads to %d due to platform\n", ncpus);
+ }
+#endif
if (ncpus > 0)
omp_set_num_threads(ncpus);
#endif
diff --git a/platform.in b/platform.in
index db6d2382f..c70f44193 100644
--- a/platform.in
+++ b/platform.in
@@ -59,6 +59,9 @@
%_smp_mflags -j%{_smp_build_ncpus}
+# Maximum number of CPU's to use for threads
+%_smp_nthreads_max %{_smp_build_ncpus}
+
#==============================================================================
# ---- Build policy macros.
#
--
2.21.0