mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-16 16:14:25 -04:00
kern/util: use custom atomics wrapper to substantially improve codegen
This commit is contained in:
parent
52332e8d75
commit
d74f364107
26 changed files with 688 additions and 260 deletions
|
@ -96,7 +96,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
KLightLock m_lock;
|
||||
KLightLock m_cv_lock;
|
||||
KLightConditionVariable m_cv;
|
||||
std::atomic<u64> m_target_cores;
|
||||
util::Atomic<u64> m_target_cores;
|
||||
volatile Operation m_operation;
|
||||
private:
|
||||
static void ThreadFunction(uintptr_t _this) {
|
||||
|
@ -109,7 +109,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
/* Wait for a request to come in. */
|
||||
{
|
||||
KScopedLightLock lk(m_cv_lock);
|
||||
while ((m_target_cores.load() & (1ul << core_id)) == 0) {
|
||||
while ((m_target_cores.Load() & (1ul << core_id)) == 0) {
|
||||
m_cv.Wait(std::addressof(m_cv_lock));
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
/* Broadcast, if there's nothing pending. */
|
||||
{
|
||||
KScopedLightLock lk(m_cv_lock);
|
||||
if (m_target_cores.load() == 0) {
|
||||
if (m_target_cores.Load() == 0) {
|
||||
m_cv.Broadcast();
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
|
||||
void ProcessOperation();
|
||||
public:
|
||||
constexpr KCacheHelperInterruptHandler() : KInterruptHandler(), m_lock(), m_cv_lock(), m_cv(), m_target_cores(), m_operation(Operation::Idle) { /* ... */ }
|
||||
constexpr KCacheHelperInterruptHandler() : KInterruptHandler(), m_lock(), m_cv_lock(), m_cv(), m_target_cores(0), m_operation(Operation::Idle) { /* ... */ }
|
||||
|
||||
void Initialize(s32 core_id) {
|
||||
/* Reserve a thread from the system limit. */
|
||||
|
@ -163,7 +163,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
if ((op == Operation::InstructionMemoryBarrier) || (Kernel::GetState() == Kernel::State::Initializing)) {
|
||||
/* Check that there's no on-going operation. */
|
||||
MESOSPHERE_ABORT_UNLESS(m_operation == Operation::Idle);
|
||||
MESOSPHERE_ABORT_UNLESS(m_target_cores.load() == 0);
|
||||
MESOSPHERE_ABORT_UNLESS(m_target_cores.Load() == 0);
|
||||
|
||||
/* Set operation. */
|
||||
m_operation = op;
|
||||
|
@ -171,13 +171,13 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
/* For certain operations, we want to send an interrupt. */
|
||||
m_target_cores = other_cores_mask;
|
||||
|
||||
const u64 target_mask = m_target_cores.load();
|
||||
const u64 target_mask = m_target_cores.Load();
|
||||
|
||||
DataSynchronizationBarrier();
|
||||
Kernel::GetInterruptManager().SendInterProcessorInterrupt(KInterruptName_CacheOperation, target_mask);
|
||||
|
||||
this->ProcessOperation();
|
||||
while (m_target_cores.load() != 0) {
|
||||
while (m_target_cores.Load() != 0) {
|
||||
cpu::Yield();
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
|
||||
/* Check that there's no on-going operation. */
|
||||
MESOSPHERE_ABORT_UNLESS(m_operation == Operation::Idle);
|
||||
MESOSPHERE_ABORT_UNLESS(m_target_cores.load() == 0);
|
||||
MESOSPHERE_ABORT_UNLESS(m_target_cores.Load() == 0);
|
||||
|
||||
/* Set operation. */
|
||||
m_operation = op;
|
||||
|
@ -199,7 +199,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
|
||||
/* Use the condvar. */
|
||||
m_cv.Broadcast();
|
||||
while (m_target_cores.load() != 0) {
|
||||
while (m_target_cores.Load() != 0) {
|
||||
m_cv.Wait(std::addressof(m_cv_lock));
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ namespace ams::kern::arch::arm64::cpu {
|
|||
break;
|
||||
}
|
||||
|
||||
m_target_cores &= ~(1ul << GetCurrentCoreId());
|
||||
m_target_cores.FetchAnd(~(1ul << GetCurrentCoreId()));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void SetEventLocally() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue