From 6e6ffc5058c2fd5daea4776b02de00d50e1cb41a Mon Sep 17 00:00:00 2001 From: digant73 Date: Fri, 25 Sep 2026 20:21:05 +0200 Subject: [PATCH] Fix thread affinity on Linux for thread scheduler different than OS --- Utilities/Thread.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index a831ac7c09..747a2181d8 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2811,6 +2811,14 @@ void thread_base::initialize(void (*error_cb)()) } #endif +#if !defined(ANDROID) && (defined(__linux__) || defined(__DragonFly__) || defined(__FreeBSD__)) + // A new thread inherits its creator's affinity mask (e.g. compile workers spawned by a pinned PPU thread): reset it to the process mask + if (g_cfg.core.thread_scheduler != thread_scheduler_mode::os) + { + thread_ctrl::set_thread_affinity_mask(0); + } +#endif + // Initialize TLS variables thread_ctrl::g_tls_this_thread = this;