diff options
| author | 2020-03-12 16:48:43 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:48 -0400 | |
| commit | 7020d498c5aef7c1180bfc57031cdd7fbfecdf0f (patch) | |
| tree | f2508e39a02966cdd4d9acda1e14ed93cdc150cd /src/core/hle/kernel | |
| parent | General: Fix Stop function (diff) | |
| download | yuzu-7020d498c5aef7c1180bfc57031cdd7fbfecdf0f.tar.gz yuzu-7020d498c5aef7c1180bfc57031cdd7fbfecdf0f.tar.xz yuzu-7020d498c5aef7c1180bfc57031cdd7fbfecdf0f.zip | |
General: Fix microprofile on dynarmic/svc, fix wait tree showing which threads were running.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 15 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 18 |
5 files changed, 51 insertions, 3 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 24da4367e..d2f5f9bf2 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | #include "common/assert.h" | 14 | #include "common/assert.h" |
| 15 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 16 | #include "common/microprofile.h" | ||
| 16 | #include "common/thread.h" | 17 | #include "common/thread.h" |
| 17 | #include "core/arm/arm_interface.h" | 18 | #include "core/arm/arm_interface.h" |
| 18 | #include "core/arm/exclusive_monitor.h" | 19 | #include "core/arm/exclusive_monitor.h" |
| @@ -41,6 +42,8 @@ | |||
| 41 | #include "core/hle/result.h" | 42 | #include "core/hle/result.h" |
| 42 | #include "core/memory.h" | 43 | #include "core/memory.h" |
| 43 | 44 | ||
| 45 | MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); | ||
| 46 | |||
| 44 | namespace Kernel { | 47 | namespace Kernel { |
| 45 | 48 | ||
| 46 | /** | 49 | /** |
| @@ -408,6 +411,8 @@ struct KernelCore::Impl { | |||
| 408 | bool is_multicore{}; | 411 | bool is_multicore{}; |
| 409 | std::thread::id single_core_thread_id{}; | 412 | std::thread::id single_core_thread_id{}; |
| 410 | 413 | ||
| 414 | std::array<u64, Core::Hardware::NUM_CPU_CORES> svc_ticks{}; | ||
| 415 | |||
| 411 | // System context | 416 | // System context |
| 412 | Core::System& system; | 417 | Core::System& system; |
| 413 | }; | 418 | }; |
| @@ -666,4 +671,14 @@ void KernelCore::ExceptionalExit() { | |||
| 666 | Suspend(true); | 671 | Suspend(true); |
| 667 | } | 672 | } |
| 668 | 673 | ||
| 674 | void KernelCore::EnterSVCProfile() { | ||
| 675 | std::size_t core = impl->GetCurrentHostThreadID(); | ||
| 676 | impl->svc_ticks[core] = MicroProfileEnter(MICROPROFILE_TOKEN(Kernel_SVC)); | ||
| 677 | } | ||
| 678 | |||
| 679 | void KernelCore::ExitSVCProfile() { | ||
| 680 | std::size_t core = impl->GetCurrentHostThreadID(); | ||
| 681 | MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[core]); | ||
| 682 | } | ||
| 683 | |||
| 669 | } // namespace Kernel | 684 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 50eeb50ec..1eb6ede73 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -214,6 +214,10 @@ public: | |||
| 214 | 214 | ||
| 215 | bool IsMulticore() const; | 215 | bool IsMulticore() const; |
| 216 | 216 | ||
| 217 | void EnterSVCProfile(); | ||
| 218 | |||
| 219 | void ExitSVCProfile(); | ||
| 220 | |||
| 217 | private: | 221 | private: |
| 218 | friend class Object; | 222 | friend class Object; |
| 219 | friend class Process; | 223 | friend class Process; |
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 25fc8a3e8..2ad380b17 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -354,7 +354,9 @@ void GlobalScheduler::EnableInterruptAndSchedule(u32 cores_pending_reschedule, | |||
| 354 | } | 354 | } |
| 355 | if (must_context_switch) { | 355 | if (must_context_switch) { |
| 356 | auto& core_scheduler = kernel.CurrentScheduler(); | 356 | auto& core_scheduler = kernel.CurrentScheduler(); |
| 357 | kernel.ExitSVCProfile(); | ||
| 357 | core_scheduler.TryDoContextSwitch(); | 358 | core_scheduler.TryDoContextSwitch(); |
| 359 | kernel.EnterSVCProfile(); | ||
| 358 | } | 360 | } |
| 359 | } | 361 | } |
| 360 | 362 | ||
| @@ -628,6 +630,7 @@ void Scheduler::Reload() { | |||
| 628 | 630 | ||
| 629 | // Cancel any outstanding wakeup events for this thread | 631 | // Cancel any outstanding wakeup events for this thread |
| 630 | thread->SetIsRunning(true); | 632 | thread->SetIsRunning(true); |
| 633 | thread->SetWasRunning(false); | ||
| 631 | thread->last_running_ticks = system.CoreTiming().GetCPUTicks(); | 634 | thread->last_running_ticks = system.CoreTiming().GetCPUTicks(); |
| 632 | 635 | ||
| 633 | auto* const thread_owner_process = thread->GetOwnerProcess(); | 636 | auto* const thread_owner_process = thread->GetOwnerProcess(); |
| @@ -660,6 +663,7 @@ void Scheduler::SwitchContextStep2() { | |||
| 660 | // Cancel any outstanding wakeup events for this thread | 663 | // Cancel any outstanding wakeup events for this thread |
| 661 | new_thread->SetIsRunning(true); | 664 | new_thread->SetIsRunning(true); |
| 662 | new_thread->last_running_ticks = system.CoreTiming().GetCPUTicks(); | 665 | new_thread->last_running_ticks = system.CoreTiming().GetCPUTicks(); |
| 666 | new_thread->SetWasRunning(false); | ||
| 663 | 667 | ||
| 664 | auto* const thread_owner_process = current_thread->GetOwnerProcess(); | 668 | auto* const thread_owner_process = current_thread->GetOwnerProcess(); |
| 665 | if (previous_process != thread_owner_process && thread_owner_process != nullptr) { | 669 | if (previous_process != thread_owner_process && thread_owner_process != nullptr) { |
| @@ -698,6 +702,9 @@ void Scheduler::SwitchContext() { | |||
| 698 | 702 | ||
| 699 | // Save context for previous thread | 703 | // Save context for previous thread |
| 700 | if (previous_thread) { | 704 | if (previous_thread) { |
| 705 | if (new_thread != nullptr && new_thread->IsSuspendThread()) { | ||
| 706 | previous_thread->SetWasRunning(true); | ||
| 707 | } | ||
| 701 | previous_thread->SetContinuousOnSVC(false); | 708 | previous_thread->SetContinuousOnSVC(false); |
| 702 | previous_thread->last_running_ticks = system.CoreTiming().GetCPUTicks(); | 709 | previous_thread->last_running_ticks = system.CoreTiming().GetCPUTicks(); |
| 703 | if (!previous_thread->IsHLEThread()) { | 710 | if (!previous_thread->IsHLEThread()) { |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index d3d4e7bf9..9b9f9402e 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -2454,10 +2454,10 @@ static const FunctionDef* GetSVCInfo64(u32 func_num) { | |||
| 2454 | return &SVC_Table_64[func_num]; | 2454 | return &SVC_Table_64[func_num]; |
| 2455 | } | 2455 | } |
| 2456 | 2456 | ||
| 2457 | MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70)); | ||
| 2458 | |||
| 2459 | void Call(Core::System& system, u32 immediate) { | 2457 | void Call(Core::System& system, u32 immediate) { |
| 2460 | MICROPROFILE_SCOPE(Kernel_SVC); | 2458 | system.ExitDynarmicProfile(); |
| 2459 | auto& kernel = system.Kernel(); | ||
| 2460 | kernel.EnterSVCProfile(); | ||
| 2461 | 2461 | ||
| 2462 | auto* thread = system.CurrentScheduler().GetCurrentThread(); | 2462 | auto* thread = system.CurrentScheduler().GetCurrentThread(); |
| 2463 | thread->SetContinuousOnSVC(true); | 2463 | thread->SetContinuousOnSVC(true); |
| @@ -2474,10 +2474,14 @@ void Call(Core::System& system, u32 immediate) { | |||
| 2474 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate); | 2474 | LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate); |
| 2475 | } | 2475 | } |
| 2476 | 2476 | ||
| 2477 | kernel.ExitSVCProfile(); | ||
| 2478 | |||
| 2477 | if (!thread->IsContinuousOnSVC()) { | 2479 | if (!thread->IsContinuousOnSVC()) { |
| 2478 | auto* host_context = thread->GetHostContext().get(); | 2480 | auto* host_context = thread->GetHostContext().get(); |
| 2479 | host_context->Rewind(); | 2481 | host_context->Rewind(); |
| 2480 | } | 2482 | } |
| 2483 | |||
| 2484 | system.EnterDynarmicProfile(); | ||
| 2481 | } | 2485 | } |
| 2482 | 2486 | ||
| 2483 | } // namespace Kernel::Svc | 2487 | } // namespace Kernel::Svc |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 168828ab0..f42d7bd13 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -350,6 +350,22 @@ public: | |||
| 350 | return (type & THREADTYPE_HLE) != 0; | 350 | return (type & THREADTYPE_HLE) != 0; |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | bool IsSuspendThread() const { | ||
| 354 | return (type & THREADTYPE_SUSPEND) != 0; | ||
| 355 | } | ||
| 356 | |||
| 357 | bool IsIdleThread() const { | ||
| 358 | return (type & THREADTYPE_IDLE) != 0; | ||
| 359 | } | ||
| 360 | |||
| 361 | bool WasRunning() const { | ||
| 362 | return was_running; | ||
| 363 | } | ||
| 364 | |||
| 365 | void SetWasRunning(bool value) { | ||
| 366 | was_running = value; | ||
| 367 | } | ||
| 368 | |||
| 353 | std::shared_ptr<Common::Fiber> GetHostContext() const; | 369 | std::shared_ptr<Common::Fiber> GetHostContext() const; |
| 354 | 370 | ||
| 355 | ThreadStatus GetStatus() const { | 371 | ThreadStatus GetStatus() const { |
| @@ -684,6 +700,8 @@ private: | |||
| 684 | 700 | ||
| 685 | bool will_be_terminated = false; | 701 | bool will_be_terminated = false; |
| 686 | 702 | ||
| 703 | bool was_running = false; | ||
| 704 | |||
| 687 | std::string name; | 705 | std::string name; |
| 688 | }; | 706 | }; |
| 689 | 707 | ||