kernel/listeners: Use an rw_spinlock for the gWaitObjectListenerLock.

When the system profiler is in use, this spinlock is used very often.
Internally there's another spinlock which isn't (yet) rw, though.
This commit is contained in:
Augustin Cavalier 2024-12-13 17:17:43 -05:00
parent 5a39b9f82f
commit 038d9b44d1
3 changed files with 6 additions and 6 deletions

View File

@ -80,7 +80,7 @@ struct WaitObjectListener : DoublyLinkedListLinkImpl<WaitObjectListener> {
typedef DoublyLinkedList<WaitObjectListener> WaitObjectListenerList;
extern WaitObjectListenerList gWaitObjectListeners;
extern spinlock gWaitObjectListenerLock;
extern rw_spinlock gWaitObjectListenerLock;
template<typename Parameter1>
@ -89,7 +89,7 @@ NotifyWaitObjectListeners(void (WaitObjectListener::*hook)(Parameter1),
Parameter1 parameter1)
{
if (!gWaitObjectListeners.IsEmpty()) {
InterruptsSpinLocker locker(gWaitObjectListenerLock);
InterruptsReadSpinLocker locker(gWaitObjectListenerLock);
WaitObjectListenerList::Iterator it
= gWaitObjectListeners.GetIterator();
while (WaitObjectListener* listener = it.Next())
@ -105,7 +105,7 @@ NotifyWaitObjectListeners(
Parameter1 parameter1, Parameter2 parameter2)
{
if (!gWaitObjectListeners.IsEmpty()) {
InterruptsSpinLocker locker(gWaitObjectListenerLock);
InterruptsReadSpinLocker locker(gWaitObjectListenerLock);
WaitObjectListenerList::Iterator it
= gWaitObjectListeners.GetIterator();
while (WaitObjectListener* listener = it.Next())

View File

@ -321,7 +321,7 @@ SystemProfiler::~SystemProfiler()
// stop wait object listening
if (fWaitObjectNotificationsRequested) {
InterruptsSpinLocker locker(gWaitObjectListenerLock);
InterruptsWriteSpinLocker locker(gWaitObjectListenerLock);
remove_wait_object_listener(this);
}
@ -514,7 +514,7 @@ SystemProfiler::Init()
scheduler_add_listener(this);
fSchedulerNotificationsRequested = true;
InterruptsSpinLocker waitObjectLocker(gWaitObjectListenerLock);
InterruptsWriteSpinLocker waitObjectLocker(gWaitObjectListenerLock);
add_wait_object_listener(this);
fWaitObjectNotificationsRequested = true;
waitObjectLocker.Unlock();

View File

@ -7,7 +7,7 @@
WaitObjectListenerList gWaitObjectListeners;
spinlock gWaitObjectListenerLock = B_SPINLOCK_INITIALIZER;
rw_spinlock gWaitObjectListenerLock = B_RW_SPINLOCK_INITIALIZER;
WaitObjectListener::~WaitObjectListener()