mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-26 10:45:29 +03:00
Fix Scheduler Core Migration Deadlock
Encountered in 不如帰大乱 when `HOS-3` is awoken at the same time as `HOS-0` called `SvcSetThreadCoreMask` resulting in a deadlock where `HOS-0` owns `HOS-3`'s `coreMigrationMutex` while `HOS-3` owns the core mutex with the both of them attempting to lock the other mutex
This commit is contained in:
parent
b43541c1a4
commit
a74eb8dbd6
@ -147,7 +147,10 @@ namespace skyline::kernel {
|
||||
|
||||
auto wakeFunction{[&]() {
|
||||
if (!thread->affinityMask.test(thread->coreId)) [[unlikely]] {
|
||||
lock.unlock(); // If the core migration mutex is locked by a thread seeking the core mutex, it'll result in a deadlock
|
||||
std::lock_guard migrationLock(thread->coreMigrationMutex);
|
||||
lock.lock();
|
||||
if (!thread->affinityMask.test(thread->coreId)) // We need to retest in case the thread was migrated while the core was unlocked
|
||||
MigrateToCore(thread, core, &cores.at(thread->idealCore), lock);
|
||||
}
|
||||
return !core->queue.empty() && core->queue.front() == thread;
|
||||
|
Loading…
Reference in New Issue
Block a user