mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-08-01 15:07:49 +00:00
commit
eb9ba2dc6e
@ -0,0 +1,27 @@
|
||||
From 1eb9bea38c320b2b588635cffceaaa2a8d434780 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Wed, 25 Jan 2023 22:09:26 -0800
|
||||
Subject: [PATCH] include missing <cstdint>
|
||||
|
||||
gcc 13 moved some includes around and as a result <cstdint> is no longer transitively
|
||||
included [1]. Explicitly include it for uint{32,64}_t.
|
||||
|
||||
[1] https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
include/crossguid/guid.hpp | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/include/crossguid/guid.hpp b/include/crossguid/guid.hpp
|
||||
index 61e0f17..70966f2 100644
|
||||
--- a/include/crossguid/guid.hpp
|
||||
+++ b/include/crossguid/guid.hpp
|
||||
@@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||
#include <jni.h>
|
||||
#endif
|
||||
|
||||
+#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <array>
|
@ -2,8 +2,8 @@
|
||||
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="tbb"
|
||||
PKG_VERSION="2021.8.0"
|
||||
PKG_SHA256="eee380323bb7ce864355ed9431f85c43955faaae9e9bce35c62b372d7ffd9f8b"
|
||||
PKG_VERSION="2021.9.0"
|
||||
PKG_SHA256="1ce48f34dada7837f510735ff1172f6e2c261b09460e3bf773b49791d247d24e"
|
||||
PKG_LICENSE="Apache-2.0"
|
||||
PKG_SITE="https://github.com/oneapi-src/oneTBB"
|
||||
PKG_URL="https://github.com/oneapi-src/oneTBB/archive/refs/tags/v${PKG_VERSION}.tar.gz"
|
||||
|
@ -1,163 +0,0 @@
|
||||
From 3a8bc6478654afcbd219f45e7ea01353c2d57eb6 Mon Sep 17 00:00:00 2001
|
||||
From: Rui Ueyama <ruiu@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 <ruiu@cs.stanford.edu>
|
||||
---
|
||||
src/tbb/rml_thread_monitor.h | 30 +++++++++++++++-
|
||||
test/CMakeLists.txt | 3 ++
|
||||
test/tbb/test_pthread_create.cpp | 59 ++++++++++++++++++++++++++++++++
|
||||
3 files changed, 91 insertions(+), 1 deletion(-)
|
||||
create mode 100644 test/tbb/test_pthread_create.cpp
|
||||
|
||||
diff --git a/src/tbb/rml_thread_monitor.h b/src/tbb/rml_thread_monitor.h
|
||||
index 13b556380..dc046ba00 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
|
||||
@@ -183,6 +184,32 @@ inline void thread_monitor::check( int error_code, const char* routine ) {
|
||||
}
|
||||
}
|
||||
|
||||
+// pthread_create(2) can spuriously fail on Linux. This is a function
|
||||
+// to wrap pthread_create(2) to retry if it fails with EAGAIN.
|
||||
+inline void do_pthread_create(pthread_t *handle, pthread_attr_t *s, void* (*thread_routine)(void*), void* arg) {
|
||||
+#ifdef __linux__
|
||||
+ int tries = 0;
|
||||
+ const int max_num_tries = 20;
|
||||
+
|
||||
+ for (;;) {
|
||||
+ int error_code = pthread_create(handle, s, thread_routine, arg);
|
||||
+ if (!error_code)
|
||||
+ break;
|
||||
+ if (error_code != EAGAIN || tries++ > max_num_tries) {
|
||||
+ handle_perror(error_code, "pthread_create has failed");
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ // Retry after tries * 1 millisecond.
|
||||
+ struct timespec ts = {0, tries * 1000 * 1000};
|
||||
+ nanosleep(&ts, NULL);
|
||||
+ }
|
||||
+#else
|
||||
+ if (int error_code = pthread_create(handle, s, thread_routine, arg))
|
||||
+ handle_perror(error_code, "pthread_create has failed");
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
inline thread_monitor::handle_type thread_monitor::launch( void* (*thread_routine)(void*), void* arg, std::size_t stack_size ) {
|
||||
// FIXME - consider more graceful recovery than just exiting if a thread cannot be launched.
|
||||
// Note that there are some tricky situations to deal with, such that the thread is already
|
||||
@@ -191,8 +218,9 @@ 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" );
|
||||
+ do_pthread_create(&handle, &s, thread_routine, arg);
|
||||
check( pthread_attr_destroy( &s ), "pthread_attr_destroy has failed" );
|
||||
return handle;
|
||||
}
|
||||
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
|
||||
index f15679e83..92802b015 100644
|
||||
--- a/test/CMakeLists.txt
|
||||
+++ b/test/CMakeLists.txt
|
||||
@@ -373,6 +373,9 @@ if (TARGET TBB::tbb)
|
||||
if (APPLE OR ANDROID_PLATFORM)
|
||||
target_link_libraries(test_dynamic_link PRIVATE -rdynamic) # for the test_dynamic_link
|
||||
endif()
|
||||
+ if (UNIX AND NOT APPLE)
|
||||
+ tbb_add_test(SUBDIR tbb NAME test_pthread_create DEPENDENCIES TBB::tbb)
|
||||
+ endif()
|
||||
tbb_add_test(SUBDIR tbb NAME test_collaborative_call_once DEPENDENCIES TBB::tbb)
|
||||
tbb_add_test(SUBDIR tbb NAME test_concurrent_lru_cache DEPENDENCIES TBB::tbb)
|
||||
tbb_add_test(SUBDIR tbb NAME test_concurrent_unordered_map DEPENDENCIES TBB::tbb)
|
||||
diff --git a/test/tbb/test_pthread_create.cpp b/test/tbb/test_pthread_create.cpp
|
||||
new file mode 100644
|
||||
index 000000000..4cb1f4ea5
|
||||
--- /dev/null
|
||||
+++ b/test/tbb/test_pthread_create.cpp
|
||||
@@ -0,0 +1,59 @@
|
||||
+/*
|
||||
+ Copyright (c) 2005-2022 Intel Corporation
|
||||
+
|
||||
+ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+ you may not use this file except in compliance with the License.
|
||||
+ You may obtain a copy of the License at
|
||||
+
|
||||
+ http://www.apache.org/licenses/LICENSE-2.0
|
||||
+
|
||||
+ Unless required by applicable law or agreed to in writing, software
|
||||
+ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ See the License for the specific language governing permissions and
|
||||
+ limitations under the License.
|
||||
+*/
|
||||
+
|
||||
+#include "common/test.h"
|
||||
+#include "common/utils.h"
|
||||
+
|
||||
+#include <atomic>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/wait.h>
|
||||
+#include <tbb/global_control.h>
|
||||
+#include <tbb/parallel_for.h>
|
||||
+#include <thread>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+//! Test that thread pool creation won't be affected with a spurious failure of pthread_create().
|
||||
+//! \brief \ref error_guessing
|
||||
+TEST_CASE("pthread_create is not affected by fork") {
|
||||
+ std::atomic_bool done;
|
||||
+
|
||||
+ std::thread thr([&]() {
|
||||
+ while (!done) {
|
||||
+ pid_t pid = fork();
|
||||
+ CHECK(pid != -1);
|
||||
+
|
||||
+ if (pid == 0) {
|
||||
+ // child
|
||||
+ _exit(0);
|
||||
+ } else {
|
||||
+ int wstatus;
|
||||
+ do {
|
||||
+ pid_t pid2 = waitpid(pid, &wstatus, 0);
|
||||
+ CHECK(pid2 != -1);
|
||||
+ } while (!WIFEXITED(wstatus) && !WIFSIGNALED(wstatus));
|
||||
+ }
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ for (int i = 0; i < 50; i++) {
|
||||
+ tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
+ tbb::parallel_for(0, 10000, [](int) {});
|
||||
+ tbb::finalize(handle);
|
||||
+ }
|
||||
+
|
||||
+ done = true;
|
||||
+ thr.join();
|
||||
+}
|
@ -3,8 +3,8 @@
|
||||
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="llvm"
|
||||
PKG_VERSION="16.0.1"
|
||||
PKG_SHA256="ab7e3b95adb88fd5b669ca8c1d3c1e8d2a601c4478290d3ae31d8d70e96f2064"
|
||||
PKG_VERSION="16.0.2"
|
||||
PKG_SHA256="6d8acae041ccd34abe144cda6eaa76210e1491f286574815b7261b3f2e58734c"
|
||||
PKG_LICENSE="Apache-2.0"
|
||||
PKG_SITE="http://llvm.org/"
|
||||
PKG_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${PKG_VERSION}/llvm-project-${PKG_VERSION}.src.tar.xz"
|
||||
|
@ -2,8 +2,8 @@
|
||||
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="meson"
|
||||
PKG_VERSION="1.0.1"
|
||||
PKG_SHA256="d926b730de6f518728cc7c57bc5e701667bae0c3522f9e369427b2cc7839d3c1"
|
||||
PKG_VERSION="1.1.0"
|
||||
PKG_SHA256="d9616c44cd6c53689ff8f05fc6958a693f2e17c3472a8daf83cee55dabff829f"
|
||||
PKG_LICENSE="Apache"
|
||||
PKG_SITE="http://mesonbuild.com"
|
||||
PKG_URL="https://github.com/mesonbuild/meson/releases/download/${PKG_VERSION}/${PKG_NAME}-${PKG_VERSION}.tar.gz"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
PKG_NAME="cargo-snapshot"
|
||||
PKG_VERSION="$(get_pkg_version rust)"
|
||||
PKG_SHA256="b25d6f88b93cb75868ff4bc9ca0103facd4622825cf53df67546cea6cb60da0f"
|
||||
PKG_SHA256="336eeabf231a7665c26c127a37b8aefffe28cb087c5c8d4ba0460419f5f8eff2"
|
||||
PKG_LICENSE="MIT"
|
||||
PKG_SITE="https://www.rust-lang.org"
|
||||
PKG_URL="https://static.rust-lang.org/dist/cargo-${PKG_VERSION}-${MACHINE_HARDWARE_NAME}-unknown-linux-gnu.tar.xz"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
PKG_NAME="rust-std-snapshot"
|
||||
PKG_VERSION="$(get_pkg_version rust)"
|
||||
PKG_SHA256="c8a3eaf26b83f1926d86b4db99ca16cbbff8e746e4c63f25f4d75a02a34a3b16"
|
||||
PKG_SHA256="4c95739e6f0f1d4defd937f6d60360b566e051dfb2fa71879d0f9751392f3709"
|
||||
PKG_LICENSE="MIT"
|
||||
PKG_SITE="https://www.rust-lang.org"
|
||||
PKG_URL="https://static.rust-lang.org/dist/rust-std-${PKG_VERSION}-${MACHINE_HARDWARE_NAME}-unknown-linux-gnu.tar.xz"
|
||||
|
@ -2,8 +2,8 @@
|
||||
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="rust"
|
||||
PKG_VERSION="1.68.2"
|
||||
PKG_SHA256="93339c23f7cd4d0c45db58e18b4c6e16d6070f4277aad9d2492d23294bf32e96"
|
||||
PKG_VERSION="1.69.0"
|
||||
PKG_SHA256="fb05971867ad6ccabbd3720279f5a94b99f61024923187b56bb5c455fa3cf60f"
|
||||
PKG_LICENSE="MIT"
|
||||
PKG_SITE="https://www.rust-lang.org"
|
||||
PKG_URL="https://static.rust-lang.org/dist/rustc-${PKG_VERSION}-src.tar.gz"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
PKG_NAME="rustc-snapshot"
|
||||
PKG_VERSION="$(get_pkg_version rust)"
|
||||
PKG_SHA256="d33d493381dd17a4b491d0e978cdb6700badb5905e831dd5f7fe75ffbf8e0584"
|
||||
PKG_SHA256="70e97ab5b9600328b977268fc92ca4aa53064e4e97468df35215d4396e509279"
|
||||
PKG_LICENSE="MIT"
|
||||
PKG_SITE="https://www.rust-lang.org"
|
||||
PKG_URL="https://static.rust-lang.org/dist/rustc-${PKG_VERSION}-${MACHINE_HARDWARE_NAME}-unknown-linux-gnu.tar.xz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user