[Kernel] Fix null in thread affinity init + ignore affinity when less than 6 cores

This commit is contained in:
Triang3l 2020-11-16 23:15:51 +03:00
parent 52230fd4e8
commit b7ba3051f2
1 changed files with 10 additions and 9 deletions

View File

@ -370,10 +370,6 @@ X_STATUS XThread::Create() {
pcr->dpc_active = 0; // DPC active bool? pcr->dpc_active = 0; // DPC active bool?
// Assign the thread to the logical processor, and also set up the current CPU
// in KPCR and KTHREAD.
SetActiveCpu(cpu_index);
// Always retain when starting - the thread owns itself until exited. // Always retain when starting - the thread owns itself until exited.
RetainHandle(); RetainHandle();
@ -434,6 +430,10 @@ X_STATUS XThread::Create() {
thread_->set_priority(creation_params_.creation_flags & 0x20 ? 1 : 0); thread_->set_priority(creation_params_.creation_flags & 0x20 ? 1 : 0);
} }
// Assign the newly created thread to the logical processor, and also set up
// the current CPU in KPCR and KTHREAD.
SetActiveCpu(cpu_index);
// Notify processor of our creation. // Notify processor of our creation.
emulator()->processor()->OnThreadCreated(handle(), thread_state_, this); emulator()->processor()->OnThreadCreated(handle(), thread_state_, this);
@ -728,12 +728,13 @@ void XThread::SetActiveCpu(uint8_t cpu_index) {
thread_object.current_cpu = cpu_index; thread_object.current_cpu = cpu_index;
} }
if (xe::threading::logical_processor_count() < 6) { if (xe::threading::logical_processor_count() >= 6) {
XELOGW("Too few processors - scheduling will be wonky");
}
if (!cvars::ignore_thread_affinities) { if (!cvars::ignore_thread_affinities) {
thread_->set_affinity_mask(uint64_t(1) << cpu_index); thread_->set_affinity_mask(uint64_t(1) << cpu_index);
} }
} else {
XELOGW("Too few processor cores - scheduling will be wonky");
}
} }
bool XThread::GetTLSValue(uint32_t slot, uint32_t* value_out) { bool XThread::GetTLSValue(uint32_t slot, uint32_t* value_out) {