kern: fix kscheduler interrupt api, adjust debug logging

This commit is contained in:
Michael Scire 2020-07-17 22:10:50 -07:00 committed by SciresM
parent fae2daf77c
commit 5fa59ec888
6 changed files with 18 additions and 8 deletions

View file

@ -70,6 +70,11 @@ namespace ams::kern {
NOINLINE void Initialize(KThread *idle_thread); NOINLINE void Initialize(KThread *idle_thread);
NOINLINE void Activate(); NOINLINE void Activate();
ALWAYS_INLINE void SetInterruptTaskRunnable() {
this->state.interrupt_task_thread_runnable = true;
this->state.needs_scheduling = true;
}
ALWAYS_INLINE void RequestScheduleOnInterrupt() { ALWAYS_INLINE void RequestScheduleOnInterrupt() {
SetSchedulerUpdateNeeded(); SetSchedulerUpdateNeeded();
@ -85,13 +90,13 @@ namespace ams::kern {
static ALWAYS_INLINE KSchedulerPriorityQueue &GetPriorityQueue() { return s_priority_queue; } static ALWAYS_INLINE KSchedulerPriorityQueue &GetPriorityQueue() { return s_priority_queue; }
static NOINLINE u64 UpdateHighestPriorityThreadsImpl(); static NOINLINE u64 UpdateHighestPriorityThreadsImpl();
static NOINLINE void InterruptTaskThreadToRunnable();
public: public:
/* Static public API. */ /* Static public API. */
static ALWAYS_INLINE bool CanSchedule() { return GetCurrentThread().GetDisableDispatchCount() == 0; } static ALWAYS_INLINE bool CanSchedule() { return GetCurrentThread().GetDisableDispatchCount() == 0; }
static ALWAYS_INLINE bool IsSchedulerLockedByCurrentThread() { return s_scheduler_lock.IsLockedByCurrentThread(); } static ALWAYS_INLINE bool IsSchedulerLockedByCurrentThread() { return s_scheduler_lock.IsLockedByCurrentThread(); }
static NOINLINE void SetInterruptTaskThreadRunnable();
static ALWAYS_INLINE void DisableScheduling() { static ALWAYS_INLINE void DisableScheduling() {
MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() >= 0); MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() >= 0);
GetCurrentThread().DisableDispatch(); GetCurrentThread().DisableDispatch();

View file

@ -38,6 +38,8 @@ namespace ams::kern::arch::arm64 {
KProcess *cur_process = GetCurrentProcessPointer(); KProcess *cur_process = GetCurrentProcessPointer();
bool should_process_user_exception = KTargetSystem::IsUserExceptionHandlersEnabled(); bool should_process_user_exception = KTargetSystem::IsUserExceptionHandlersEnabled();
MESOSPHERE_LOG("User Exception occurred in %s\n", cur_process->GetName());
const u64 ec = (esr >> 26) & 0x3F; const u64 ec = (esr >> 26) & 0x3F;
switch (ec) { switch (ec) {
case 0x0: /* Unknown */ case 0x0: /* Unknown */

View file

@ -91,7 +91,7 @@ namespace ams::kern {
/* Enqueue the task and signal the scheduler. */ /* Enqueue the task and signal the scheduler. */
this->task_queue.Enqueue(task); this->task_queue.Enqueue(task);
Kernel::GetScheduler().SetInterruptTaskThreadRunnable(); Kernel::GetScheduler().SetInterruptTaskRunnable();
} }
} }

View file

@ -199,7 +199,7 @@ namespace ams::kern {
return cores_needing_scheduling; return cores_needing_scheduling;
} }
void KScheduler::SetInterruptTaskThreadRunnable() { void KScheduler::InterruptTaskThreadToRunnable() {
MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() == 1); MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() == 1);
KThread *task_thread = Kernel::GetInterruptTaskManager().GetThread(); KThread *task_thread = Kernel::GetInterruptTaskManager().GetThread();
@ -252,7 +252,7 @@ namespace ams::kern {
/* Switch the current process, if we're switching processes. */ /* Switch the current process, if we're switching processes. */
if (KProcess *next_process = next_thread->GetOwnerProcess(); next_process != cur_process) { if (KProcess *next_process = next_thread->GetOwnerProcess(); next_process != cur_process) {
MESOSPHERE_LOG("!!! PROCESS SWITCH !!! %s -> %s\n", cur_process != nullptr ? cur_process->GetName() : nullptr, next_process != nullptr ? next_process->GetName() : nullptr); /* MESOSPHERE_LOG("!!! PROCESS SWITCH !!! %s -> %s\n", cur_process != nullptr ? cur_process->GetName() : nullptr, next_process != nullptr ? next_process->GetName() : nullptr); */
KProcess::Switch(cur_process, next_process); KProcess::Switch(cur_process, next_process);
} }

View file

@ -120,6 +120,9 @@ namespace ams::kern {
::std::va_list vl; ::std::va_list vl;
va_start(vl, format); va_start(vl, format);
MESOSPHERE_RELEASE_LOG("Core[%d]: Kernel Panic at %s:%d\n", GetCurrentCoreId(), file, line); MESOSPHERE_RELEASE_LOG("Core[%d]: Kernel Panic at %s:%d\n", GetCurrentCoreId(), file, line);
if (KProcess *cur_process = GetCurrentProcessPointer(); cur_process != nullptr) {
MESOSPHERE_RELEASE_LOG("Core[%d]: Current Process: %s\n", GetCurrentCoreId(), cur_process->GetName());
}
MESOSPHERE_RELEASE_VLOG(format, vl); MESOSPHERE_RELEASE_VLOG(format, vl);
MESOSPHERE_RELEASE_LOG("\n"); MESOSPHERE_RELEASE_LOG("\n");
va_end(vl); va_end(vl);

View file

@ -115,10 +115,10 @@ _ZN3ams4kern10KScheduler12ScheduleImplEv:
ldrb w3, [x1, #1] ldrb w3, [x1, #1]
cbz w3, 0f cbz w3, 0f
/* If it is, we want to call KScheduler::SetInterruptTaskThreadRunnable() to note it runnable. */ /* If it is, we want to call KScheduler::InterruptTaskThreadToRunnable() to change its state to runnable. */
stp x0, x1, [sp, #-16]! stp x0, x1, [sp, #-16]!
stp x30, xzr, [sp, #-16]! stp x30, xzr, [sp, #-16]!
bl _ZN3ams4kern10KScheduler30SetInterruptTaskThreadRunnableEv bl _ZN3ams4kern10KScheduler29InterruptTaskThreadToRunnableEv
ldp x30, xzr, [sp], 16 ldp x30, xzr, [sp], 16
ldp x0, x1, [sp], 16 ldp x0, x1, [sp], 16
@ -271,7 +271,7 @@ _ZN3ams4kern10KScheduler12ScheduleImplEv:
cbz w3, 4b cbz w3, 4b
/* It does, so do so. We're using the idle thread stack so no register state preserve needed. */ /* It does, so do so. We're using the idle thread stack so no register state preserve needed. */
bl _ZN3ams4kern10KScheduler30SetInterruptTaskThreadRunnableEv bl _ZN3ams4kern10KScheduler29InterruptTaskThreadToRunnableEv
/* Clear the interrupt task thread as runnable. */ /* Clear the interrupt task thread as runnable. */
strb wzr, [x20, #1] strb wzr, [x20, #1]