Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package tbb for openSUSE:Factory checked in 
at 2022-08-09 15:25:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/tbb (Old)
 and      /work/SRC/openSUSE:Factory/.tbb.new.1521 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "tbb"

Tue Aug  9 15:25:54 2022 rev:27 rq:993616 version:2021.5.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/tbb/tbb.changes  2022-05-08 21:52:18.859460245 
+0200
+++ /work/SRC/openSUSE:Factory/.tbb.new.1521/tbb.changes        2022-08-09 
15:25:58.741218308 +0200
@@ -1,0 +2,6 @@
+Fri Aug  5 19:04:35 UTC 2022 - Martin Li??ka <mli...@suse.cz>
+
+- Add retry-pthread_create.patch that fixes
+  gh#oneapi-src/oneTBB#824.
+
+-------------------------------------------------------------------

New:
----
  retry-pthread_create.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ tbb.spec ++++++
--- /var/tmp/diff_new_pack.EAapP3/_old  2022-08-09 15:25:59.221219679 +0200
+++ /var/tmp/diff_new_pack.EAapP3/_new  2022-08-09 15:25:59.225219691 +0200
@@ -51,7 +51,8 @@
 # PATCH-FIX-UPSTREAM tbb-pr609-32bit-mwaitpkg.patch
 Patch1:         
https://github.com/oneapi-src/oneTBB/pull/609.patch#/tbb-pr609-32bit-mwaitpkg.patch
 # PATCH-FIX-OPENSUSE cmake-remove-include-path.patch -- openCV include error
-Patch4:         cmake-remove-include-path.patch
+Patch2:         cmake-remove-include-path.patch
+Patch3:         retry-pthread_create.patch
 BuildRequires:  cmake
 BuildRequires:  fdupes
 BuildRequires:  gcc-c++

++++++ retry-pthread_create.patch ++++++
>From f12c93efd04991bc982a27e2fa6142538c33ca82 Mon Sep 17 00:00:00 2001
From: Rui Ueyama <r...@cs.stanford.edu>
Date: Sat, 7 May 2022 19:55:24 +0800
Subject: [PATCH] Retry if pthread_create fails with EAGAIN

On many Unix-like systems, pthread_create can fail spuriously even if
the running machine has enough resources to spawn a new thread.
Therefore, if EAGAIN is returned from pthread_create, we actually have
to try again.

I observed this issue when running the mold linker
(https://github.com/rui314/mold) under a heavy load. mold uses OneTBB
for parallelization.

As another data point, Go has the same logic to retry on EAGAIN:
https://go-review.googlesource.com/c/go/+/33894/

nanosleep is defined in POSIX 2001, so I believe that all Unix-like
systems support it.

Signed-off-by: Rui Ueyama <r...@cs.stanford.edu>
---
 src/tbb/rml_thread_monitor.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/tbb/rml_thread_monitor.h b/src/tbb/rml_thread_monitor.h
index 13b556380..5b844b232 100644
--- a/src/tbb/rml_thread_monitor.h
+++ b/src/tbb/rml_thread_monitor.h
@@ -31,6 +31,7 @@
 #include <pthread.h>
 #include <cstring>
 #include <cstdlib>
+#include <time.h>
 #else
 #error Unsupported platform
 #endif
@@ -191,8 +192,24 @@ inline thread_monitor::handle_type thread_monitor::launch( 
void* (*thread_routin
     check(pthread_attr_init( &s ), "pthread_attr_init has failed");
     if( stack_size>0 )
         check(pthread_attr_setstacksize( &s, stack_size ), 
"pthread_attr_setstack_size has failed" );
+
     pthread_t handle;
-    check( pthread_create( &handle, &s, thread_routine, arg ), "pthread_create 
has failed" );
+    int tries = 0;
+    for (;;) {
+      int error_code = pthread_create(&handle, &s, thread_routine, arg);
+      if (!error_code)
+        break;
+      if (error_code != EAGAIN || tries++ > 20) {
+        handle_perror(error_code, "pthread_create has failed");
+        break;
+      }
+
+      // pthreaed_create can spuriously fail on many Unix-like systems.
+      // Retry after tries * 1 millisecond.
+      struct timespec ts = {0, tries * 1000 * 1000};
+      nanosleep(&ts, NULL);
+    }
+
     check( pthread_attr_destroy( &s ), "pthread_attr_destroy has failed" );
     return handle;
 }

Reply via email to