diff --git a/Kernel/Arch/Spinlock.h b/Kernel/Arch/Spinlock.h index 0575b400be517fe480bcb5ecc87e54b63f26f023..084abb69ef85051cd135f05f2e628e8436195599 100644 --- a/Kernel/Arch/Spinlock.h +++ b/Kernel/Arch/Spinlock.h @@ -16,7 +16,7 @@ class Spinlock { AK_MAKE_NONMOVABLE(Spinlock); public: - Spinlock(LockRank rank = LockRank::None) + Spinlock(LockRank rank) : m_rank(rank) { } @@ -48,7 +48,7 @@ class RecursiveSpinlock { AK_MAKE_NONMOVABLE(RecursiveSpinlock); public: - RecursiveSpinlock(LockRank rank = LockRank::None) + RecursiveSpinlock(LockRank rank) : m_rank(rank) { } diff --git a/Kernel/Bus/PCI/Access.h b/Kernel/Bus/PCI/Access.h index fa1dc16fb2898763e933e26e6aa61c85d0cc4d38..14b0d4012380964a13c776a66e8dce70f077a5d9 100644 --- a/Kernel/Bus/PCI/Access.h +++ b/Kernel/Bus/PCI/Access.h @@ -53,8 +53,8 @@ private: Vector get_capabilities(Address); Optional get_capabilities_pointer(Address address); - mutable RecursiveSpinlock m_access_lock; - mutable Spinlock m_scan_lock; + mutable RecursiveSpinlock m_access_lock { LockRank::None }; + mutable Spinlock m_scan_lock { LockRank::None }; HashMap> m_host_controllers; Vector m_device_identifiers; diff --git a/Kernel/Bus/PCI/Controller/VolumeManagementDevice.h b/Kernel/Bus/PCI/Controller/VolumeManagementDevice.h index aa5a1e2849bb871353dbfe3256c3d4942d14e175..a5baad70d730b6ca596d9aac389e3179a7d1e98f 100644 --- a/Kernel/Bus/PCI/Controller/VolumeManagementDevice.h +++ b/Kernel/Bus/PCI/Controller/VolumeManagementDevice.h @@ -29,7 +29,7 @@ private: // Note: All read and writes must be done with a spinlock because // Linux says that CPU might deadlock otherwise if access is not serialized. - Spinlock m_config_lock; + Spinlock m_config_lock { LockRank::None }; }; } diff --git a/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h b/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h index ad15ffd8c7433cdcf345fafbac62a2601ceff97e..dc9b5d87de123ca448c660fb873dc58f168d83fa 100644 --- a/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h +++ b/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h @@ -70,6 +70,7 @@ private: UHCIDescriptorPool(NonnullOwnPtr pool_memory_block, StringView name) : m_pool_name(name) , m_pool_region(move(pool_memory_block)) + , m_pool_lock(LockRank::None) { // Go through the number of descriptors to create in the pool, and create a virtual/physical address mapping for (size_t i = 0; i < PAGE_SIZE / sizeof(T); i++) { diff --git a/Kernel/Bus/VirtIO/Queue.h b/Kernel/Bus/VirtIO/Queue.h index 12a5940e15dc42e3d2ff9e1a4e831fbb97afd5e1..6563779866f7de055d04ee47a4d82d029dc17762 100644 --- a/Kernel/Bus/VirtIO/Queue.h +++ b/Kernel/Bus/VirtIO/Queue.h @@ -96,7 +96,7 @@ private: QueueDriver* m_driver { nullptr }; QueueDevice* m_device { nullptr }; NonnullOwnPtr m_queue_region; - Spinlock m_lock; + Spinlock m_lock { LockRank::None }; friend class QueueChain; }; diff --git a/Kernel/Devices/AsyncDeviceRequest.h b/Kernel/Devices/AsyncDeviceRequest.h index bc7376e55d62c1bbe0d9883880fd6475cf943546..47d5aacc9311b522c5a22eef6e56e0889b862d4b 100644 --- a/Kernel/Devices/AsyncDeviceRequest.h +++ b/Kernel/Devices/AsyncDeviceRequest.h @@ -151,7 +151,7 @@ private: WaitQueue m_queue; NonnullRefPtr m_process; void* m_private { nullptr }; - mutable Spinlock m_lock; + mutable Spinlock m_lock { LockRank::None }; }; } diff --git a/Kernel/Devices/Audio/AC97.h b/Kernel/Devices/Audio/AC97.h index c6c5dc158a3486a38d5f0df97a75b55b948c0c22..f904d5b72cf1128db140bd683d3c0f4d4f53ecd6 100644 --- a/Kernel/Devices/Audio/AC97.h +++ b/Kernel/Devices/Audio/AC97.h @@ -144,7 +144,7 @@ private: private: IOAddress m_channel_base; AC97& m_device; - SpinlockProtected m_dma_running { false }; + SpinlockProtected m_dma_running { LockRank::None, false }; StringView m_name; }; diff --git a/Kernel/Devices/ConsoleDevice.cpp b/Kernel/Devices/ConsoleDevice.cpp index 2d68440992e003f937cee3e9e1589121113a4c5c..228c7aba91562618d8043989df0e7a91bc6e18e6 100644 --- a/Kernel/Devices/ConsoleDevice.cpp +++ b/Kernel/Devices/ConsoleDevice.cpp @@ -14,7 +14,7 @@ // Output bytes to kernel debug port 0xE9 (Bochs console). It's very handy. #define CONSOLE_OUT_TO_BOCHS_DEBUG_PORT -static Kernel::Spinlock g_console_lock; +static Kernel::Spinlock g_console_lock { LockRank::None }; UNMAP_AFTER_INIT NonnullRefPtr ConsoleDevice::must_create() { diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 11e3a035a19b90eca1595ab6a54bf146ab6f7aa1..3c143f4c245ea1ea670a8a3e27d91248e97e404a 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -88,7 +88,7 @@ private: State m_state { State::Normal }; - Spinlock m_requests_lock; + Spinlock m_requests_lock { LockRank::None }; DoublyLinkedList> m_requests; protected: diff --git a/Kernel/Devices/DeviceManagement.h b/Kernel/Devices/DeviceManagement.h index 0b4f57ee7bc3ce188396eab2370041fb1340b1d6..d9146f95b4672cf76efdd6a5b0d7803c837c9bc2 100644 --- a/Kernel/Devices/DeviceManagement.h +++ b/Kernel/Devices/DeviceManagement.h @@ -74,9 +74,9 @@ private: RefPtr m_console_device; RefPtr m_device_control_device; // FIXME: Once we have a singleton for managing many sound cards, remove this from here - SpinlockProtected> m_devices; + SpinlockProtected> m_devices { LockRank::None }; - mutable Spinlock m_event_queue_lock; + mutable Spinlock m_event_queue_lock { LockRank::None }; CircularQueue m_event_queue; }; diff --git a/Kernel/Devices/HID/HIDManagement.h b/Kernel/Devices/HID/HIDManagement.h index 8806fbe7d1b8e343f0c3162984871939b003c7e7..49d45f4d2603dcba6fb59c371e377cf791ccf3dc 100644 --- a/Kernel/Devices/HID/HIDManagement.h +++ b/Kernel/Devices/HID/HIDManagement.h @@ -57,13 +57,13 @@ private: size_t generate_minor_device_number_for_mouse(); size_t generate_minor_device_number_for_keyboard(); - SpinlockProtected m_keymap_data; + SpinlockProtected m_keymap_data { LockRank::None }; size_t m_mouse_minor_number { 0 }; size_t m_keyboard_minor_number { 0 }; KeyboardClient* m_client { nullptr }; RefPtr m_i8042_controller; NonnullRefPtrVector m_hid_devices; - Spinlock m_client_lock; + Spinlock m_client_lock { LockRank::None }; }; class KeyboardClient { diff --git a/Kernel/Devices/HID/I8042Controller.h b/Kernel/Devices/HID/I8042Controller.h index 658dfc9712fd1989159330ce899be6f053dc8265..c09a2a32c02ca5fd993d67d359032d78e0d3537b 100644 --- a/Kernel/Devices/HID/I8042Controller.h +++ b/Kernel/Devices/HID/I8042Controller.h @@ -153,7 +153,7 @@ private: void do_write(u8 port, u8 data); u8 do_read(u8 port); - Spinlock m_lock; + Spinlock m_lock { LockRank::None }; bool m_first_port_available { false }; bool m_second_port_available { false }; bool m_is_dual_channel { false }; diff --git a/Kernel/Devices/HID/KeyboardDevice.h b/Kernel/Devices/HID/KeyboardDevice.h index 273fde66619d5bd5e1398089d4066e06aa54f700..6bc315942546a52cd8469120fb207b4c06eace7b 100644 --- a/Kernel/Devices/HID/KeyboardDevice.h +++ b/Kernel/Devices/HID/KeyboardDevice.h @@ -46,7 +46,7 @@ public: protected: KeyboardDevice(); - mutable Spinlock m_queue_lock; + mutable Spinlock m_queue_lock { LockRank::None }; CircularQueue m_queue; // ^CharacterDevice virtual StringView class_name() const override { return "KeyboardDevice"sv; } diff --git a/Kernel/Devices/HID/MouseDevice.h b/Kernel/Devices/HID/MouseDevice.h index d7317a6799ae8eab122f03d74189cd40c323853a..8c9b0b56689d4920bb77f5577f0ccfef1d75c62e 100644 --- a/Kernel/Devices/HID/MouseDevice.h +++ b/Kernel/Devices/HID/MouseDevice.h @@ -36,7 +36,7 @@ protected: // ^CharacterDevice virtual StringView class_name() const override { return "MouseDevice"sv; } - mutable Spinlock m_queue_lock; + mutable Spinlock m_queue_lock { LockRank::None }; CircularQueue m_queue; }; diff --git a/Kernel/Devices/KCOVInstance.h b/Kernel/Devices/KCOVInstance.h index 3cfc9c7ab2029d939a57eeaed25f3c75e4113852..b6b5ccd35ed6dadde9672f4a794eaabe31693ffe 100644 --- a/Kernel/Devices/KCOVInstance.h +++ b/Kernel/Devices/KCOVInstance.h @@ -58,7 +58,7 @@ private: // Here to ensure it's not garbage collected at the end of open() OwnPtr m_kernel_region; - Spinlock m_lock; + Spinlock m_lock { LockRank::None }; }; } diff --git a/Kernel/Devices/SerialDevice.h b/Kernel/Devices/SerialDevice.h index 5827e17e852bdf19f5966354f79e79102f306146..85755e8d99dbb1c4f50fcaaad18a7feb0e364e4f 100644 --- a/Kernel/Devices/SerialDevice.h +++ b/Kernel/Devices/SerialDevice.h @@ -130,7 +130,7 @@ private: bool m_break_enable { false }; u8 m_modem_control { 0 }; bool m_last_put_char_was_carriage_return { false }; - Spinlock m_serial_lock; + Spinlock m_serial_lock { LockRank::None }; }; } diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index de22fa74ee030ebe20fc3942bd34b3742ae497f5..945ef1b23b61a5e2d5e68624f11b920261d6c253 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -127,7 +127,7 @@ private: InodeIndex m_index { 0 }; WeakPtr m_shared_vmobject; RefPtr m_bound_socket; - SpinlockProtected> m_watchers; + SpinlockProtected> m_watchers { LockRank::None }; bool m_metadata_dirty { false }; RefPtr m_fifo; IntrusiveListNode m_inode_list_node; @@ -141,7 +141,7 @@ private: }; Thread::FlockBlockerSet m_flock_blocker_set; - SpinlockProtected> m_flocks; + SpinlockProtected> m_flocks { LockRank::None }; public: using AllInstancesList = IntrusiveList<&Inode::m_inode_list_node>; diff --git a/Kernel/FileSystem/OpenFileDescription.h b/Kernel/FileSystem/OpenFileDescription.h index 829a3a9e9f2d639458aa6e349eab253b51c19c2e..a1315f907c0f74a7e3eed8d69bf174dcc642f181 100644 --- a/Kernel/FileSystem/OpenFileDescription.h +++ b/Kernel/FileSystem/OpenFileDescription.h @@ -155,6 +155,6 @@ private: FIFO::Direction fifo_direction : 2 { FIFO::Direction::Neither }; }; - SpinlockProtected m_state; + SpinlockProtected m_state { LockRank::None }; }; } diff --git a/Kernel/FileSystem/Plan9FileSystem.h b/Kernel/FileSystem/Plan9FileSystem.h index cae3edb872fab068b0cb6a4c710cb2ca8d9bb3b0..78af118ff5c22a0c8ef6cd0ba140f223ac147c6a 100644 --- a/Kernel/FileSystem/Plan9FileSystem.h +++ b/Kernel/FileSystem/Plan9FileSystem.h @@ -66,11 +66,11 @@ private: private: Plan9FS& m_fs; - mutable Spinlock m_lock; + mutable Spinlock m_lock { LockRank::None }; }; struct ReceiveCompletion : public RefCounted { - mutable Spinlock lock; + mutable Spinlock lock { LockRank::None }; bool completed { false }; const u16 tag; OwnPtr message; @@ -139,7 +139,7 @@ private: Plan9FSBlockerSet m_completion_blocker; HashMap> m_completions; - Spinlock m_thread_lock; + Spinlock m_thread_lock { LockRank::None }; RefPtr m_thread; Atomic m_thread_running { false }; Atomic m_thread_shutdown { false }; diff --git a/Kernel/FileSystem/SysFS/Component.cpp b/Kernel/FileSystem/SysFS/Component.cpp index 615bbe8fdcad800380eacf8327f1a83b67fbfb96..d9a462b1772f65491551120b95e3400abe3c994d 100644 --- a/Kernel/FileSystem/SysFS/Component.cpp +++ b/Kernel/FileSystem/SysFS/Component.cpp @@ -11,7 +11,7 @@ namespace Kernel { -static Spinlock s_index_lock; +static Spinlock s_index_lock { LockRank::None }; static InodeIndex s_next_inode_index { 0 }; static size_t allocate_inode_index() diff --git a/Kernel/FileSystem/SysFS/Component.h b/Kernel/FileSystem/SysFS/Component.h index 825453ecdf5af066e28a2d77a427f8871799210e..6aee4a4e4ee51c52d0967784461769290e7774f3 100644 --- a/Kernel/FileSystem/SysFS/Component.h +++ b/Kernel/FileSystem/SysFS/Component.h @@ -88,7 +88,7 @@ protected: SysFSDirectory() {}; explicit SysFSDirectory(SysFSDirectory const& parent_directory); - ChildList m_child_components; + ChildList m_child_components { LockRank::None }; }; } diff --git a/Kernel/FileSystem/SysFS/Registry.h b/Kernel/FileSystem/SysFS/Registry.h index 6632fd81aa7f1e437c45878419b9f6d967a4b202..a560a9d62d3e5ad13cc718ab6b289323af5684c4 100644 --- a/Kernel/FileSystem/SysFS/Registry.h +++ b/Kernel/FileSystem/SysFS/Registry.h @@ -32,7 +32,7 @@ public: private: NonnullRefPtr m_root_directory; - Spinlock m_root_directory_lock; + Spinlock m_root_directory_lock { LockRank::None }; }; } diff --git a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h index 158a92a90abdc63e60a39cdf8565fa4eae794d0f..9a72bc0bee8caecbfb61768d92fd33bffbb8be01 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h +++ b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h @@ -27,7 +27,7 @@ public: private: explicit SysFSUSBBusDirectory(SysFSBusDirectory&); - mutable Spinlock m_lock; + mutable Spinlock m_lock { LockRank::None }; }; } diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index a164c97ab188e7cf950dae7fac02e0a7ef13fd33..f7c186b36ee874eef0fc63efb81c1761f59d7771 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -98,7 +98,7 @@ private: RefPtr m_root_inode; RefPtr m_root_custody; - SpinlockProtected> m_mounts; + SpinlockProtected> m_mounts { LockRank::None }; }; } diff --git a/Kernel/Graphics/Console/BootFramebufferConsole.h b/Kernel/Graphics/Console/BootFramebufferConsole.h index 86e5bbdb67b9792efa5d33b852c31ab73ce19aef..690109ff4df4e3fc7623aa18a73d915f8a43f183 100644 --- a/Kernel/Graphics/Console/BootFramebufferConsole.h +++ b/Kernel/Graphics/Console/BootFramebufferConsole.h @@ -42,7 +42,7 @@ protected: OwnPtr m_framebuffer; #endif u8* m_framebuffer_data {}; - mutable Spinlock m_lock; + mutable Spinlock m_lock { LockRank::None }; }; } diff --git a/Kernel/Graphics/Console/GenericFramebufferConsole.h b/Kernel/Graphics/Console/GenericFramebufferConsole.h index e3eee8c715df0fe9c0ade9b2b3c09c654f10906a..533e64a6b6e143a88ccb41fc1df210e4069e6b77 100644 --- a/Kernel/Graphics/Console/GenericFramebufferConsole.h +++ b/Kernel/Graphics/Console/GenericFramebufferConsole.h @@ -81,7 +81,7 @@ protected: virtual void clear_glyph(size_t x, size_t y) override; - mutable Spinlock m_lock; + mutable Spinlock m_lock { LockRank::None }; }; } diff --git a/Kernel/Graphics/Console/VGATextModeConsole.h b/Kernel/Graphics/Console/VGATextModeConsole.h index 12666e309f63f09b9b2f0f69253fc6fdcb15c3ad..cb5671da46a634873ad30bf4b7cb58effca77b50 100644 --- a/Kernel/Graphics/Console/VGATextModeConsole.h +++ b/Kernel/Graphics/Console/VGATextModeConsole.h @@ -38,7 +38,7 @@ private: explicit VGATextModeConsole(NonnullOwnPtr); - mutable Spinlock m_vga_lock; + mutable Spinlock m_vga_lock { LockRank::None }; NonnullOwnPtr m_vga_window_region; VirtualAddress m_current_vga_window; diff --git a/Kernel/Graphics/DisplayConnector.h b/Kernel/Graphics/DisplayConnector.h index d486b40f0cdd932615d50341b7e168d936ee0461..763e45176aa1cbdf3d86e1010639d915563e68d0 100644 --- a/Kernel/Graphics/DisplayConnector.h +++ b/Kernel/Graphics/DisplayConnector.h @@ -114,14 +114,14 @@ protected: ErrorOr initialize_edid_for_generic_monitor(Optional> manufacturer_id_string); - mutable Spinlock m_control_lock; + mutable Spinlock m_control_lock { LockRank::None }; mutable Mutex m_flushing_lock; bool m_console_mode { false }; bool m_vertical_offsetted { false }; - mutable Spinlock m_modeset_lock; + mutable Spinlock m_modeset_lock { LockRank::None }; ModeSetting m_current_mode_setting {}; Optional m_edid_parser; @@ -165,7 +165,7 @@ private: RefPtr m_shared_framebuffer_vmobject; WeakPtr m_responsible_process; - Spinlock m_responsible_process_lock; + Spinlock m_responsible_process_lock { LockRank::None }; IntrusiveListNode> m_list_node; }; diff --git a/Kernel/Graphics/GraphicsManagement.h b/Kernel/Graphics/GraphicsManagement.h index d45108f10665a388ee5f17fe88f22fe7d4c2a360..33c015efecc06438f50852572eed0e1133cc7b4b 100644 --- a/Kernel/Graphics/GraphicsManagement.h +++ b/Kernel/Graphics/GraphicsManagement.h @@ -58,9 +58,9 @@ private: unsigned m_current_minor_number { 0 }; - SpinlockProtected> m_display_connector_nodes; + SpinlockProtected> m_display_connector_nodes { LockRank::None }; - RecursiveSpinlock m_main_vga_lock; + RecursiveSpinlock m_main_vga_lock { LockRank::None }; bool m_vga_access_is_disabled { false }; }; diff --git a/Kernel/Graphics/Intel/NativeDisplayConnector.h b/Kernel/Graphics/Intel/NativeDisplayConnector.h index 84e2ef0dbaf7435ec064b10a4a63104d57e5247a..b71995dbb92e28bb2bd27689b68016270af7067a 100644 --- a/Kernel/Graphics/Intel/NativeDisplayConnector.h +++ b/Kernel/Graphics/Intel/NativeDisplayConnector.h @@ -154,7 +154,7 @@ private: Optional create_pll_settings(u64 target_frequency, u64 reference_clock, IntelGraphics::PLLMaxSettings const&); - mutable Spinlock m_registers_lock; + mutable Spinlock m_registers_lock { LockRank::None }; RefPtr m_framebuffer_console; const PhysicalAddress m_registers; diff --git a/Kernel/Graphics/VMWare/GraphicsAdapter.h b/Kernel/Graphics/VMWare/GraphicsAdapter.h index 212298d975c9c44a85ac4b811aa7e2f48f63d1f0..9ef605c6d90abba01351435282d17acec5a80219 100644 --- a/Kernel/Graphics/VMWare/GraphicsAdapter.h +++ b/Kernel/Graphics/VMWare/GraphicsAdapter.h @@ -51,8 +51,8 @@ private: Memory::TypedMapping m_fifo_registers; RefPtr m_display_connector; const IOAddress m_io_registers_base; - mutable Spinlock m_io_access_lock; - mutable RecursiveSpinlock m_operation_lock; + mutable Spinlock m_io_access_lock { LockRank::None }; + mutable RecursiveSpinlock m_operation_lock { LockRank::None }; }; } diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h index fbaa5d85212f7f0fd4bd67a3c6503c0610259d84..1659b9036ad82a5e9cb9b3120e3d9416ba7f4436 100644 --- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h +++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h @@ -124,7 +124,7 @@ private: // Synchronous commands WaitQueue m_outstanding_request; - Spinlock m_operation_lock; + Spinlock m_operation_lock { LockRank::None }; NonnullOwnPtr m_scratch_space; }; } diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index 22681b985ffdb867ff366c8b02fb03e70c8bd36d..5172d2ee130ed1d9bc4557d75da11611bea175ac 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -36,7 +36,8 @@ namespace std { const nothrow_t nothrow; } -static RecursiveSpinlock s_lock; // needs to be recursive because of dump_backtrace() +// FIXME: Figure out whether this can be MemoryManager. +static RecursiveSpinlock s_lock { LockRank::None }; // needs to be recursive because of dump_backtrace() struct KmallocSubheap { KmallocSubheap(u8* base, size_t size) diff --git a/Kernel/Locking/Mutex.h b/Kernel/Locking/Mutex.h index 37769ce79dd1e24f67dca431c11736b2873de71a..92ec8326f93d08333cc1a3e41da530ed24be92c5 100644 --- a/Kernel/Locking/Mutex.h +++ b/Kernel/Locking/Mutex.h @@ -116,9 +116,11 @@ private: return mode == Mode::Exclusive ? exclusive : shared; } }; - SpinlockProtected m_blocked_thread_lists; + // FIXME: Use a specific lock rank passed by constructor. + SpinlockProtected m_blocked_thread_lists { LockRank::None }; - mutable Spinlock m_lock; + // FIXME: See above. + mutable Spinlock m_lock { LockRank::None }; #if LOCK_SHARED_UPGRADE_DEBUG HashMap m_shared_holders_map; diff --git a/Kernel/Locking/SpinlockProtected.h b/Kernel/Locking/SpinlockProtected.h index 1072c425cc9d72a797c29c19cc96cdad6ddf81e1..e40248b7fdb227c51e8c72a03a89495abb1884a9 100644 --- a/Kernel/Locking/SpinlockProtected.h +++ b/Kernel/Locking/SpinlockProtected.h @@ -47,8 +47,9 @@ private: public: template - SpinlockProtected(Args&&... args) + SpinlockProtected(LockRank rank, Args&&... args) : m_value(forward(args)...) + , m_spinlock(rank) { } diff --git a/Kernel/Memory/AddressSpace.h b/Kernel/Memory/AddressSpace.h index f32e260c8bc7188302da1e12939beccbda134d9c..12b2212659f80bce5745fbb7194b6a7ebc89d11a 100644 --- a/Kernel/Memory/AddressSpace.h +++ b/Kernel/Memory/AddressSpace.h @@ -67,7 +67,7 @@ public: private: AddressSpace(NonnullRefPtr, VirtualRange total_range); - mutable RecursiveSpinlock m_lock; + mutable RecursiveSpinlock m_lock { LockRank::None }; RefPtr m_page_directory; diff --git a/Kernel/Memory/AnonymousVMObject.h b/Kernel/Memory/AnonymousVMObject.h index 562b8caa7634134b25ff2c9791ec94be1f629006..5733235ce90ab2fc60d4f2128a163ae4ffb19a2b 100644 --- a/Kernel/Memory/AnonymousVMObject.h +++ b/Kernel/Memory/AnonymousVMObject.h @@ -78,7 +78,7 @@ private: void uncommit_one(); private: - Spinlock m_lock; + Spinlock m_lock { LockRank::None }; CommittedPhysicalPageSet m_committed_pages; }; diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h index 4828f9b15956c500117e67043ed4e1ea6bf717c3..010fae183b5b5803a1269d6c0587a0842a50f10a 100644 --- a/Kernel/Memory/MemoryManager.h +++ b/Kernel/Memory/MemoryManager.h @@ -89,7 +89,7 @@ struct PhysicalMemoryRange { struct MemoryManagerData { static ProcessorSpecificDataID processor_specific_data_id() { return ProcessorSpecificDataID::MemoryManager; } - Spinlock m_quickmap_in_use; + Spinlock m_quickmap_in_use { LockRank::None }; u32 m_quickmap_prev_flags; PhysicalAddress m_last_quickmap_pd; diff --git a/Kernel/Memory/PageDirectory.h b/Kernel/Memory/PageDirectory.h index 8aecc3c0493d05321edd5d93a128385530ada5c6..842519dd0fd536c7076e0362b4caae39c65dd0ec 100644 --- a/Kernel/Memory/PageDirectory.h +++ b/Kernel/Memory/PageDirectory.h @@ -72,7 +72,7 @@ private: #else RefPtr m_directory_pages[4]; #endif - RecursiveSpinlock m_lock; + RecursiveSpinlock m_lock { LockRank::None }; }; void activate_kernel_page_directory(PageDirectory const& pgd); diff --git a/Kernel/Memory/RegionTree.h b/Kernel/Memory/RegionTree.h index 93f6047bfbb73f5be60a72f4aa0bc7b1dfbf1126..aa5226d44808fa82bbf06122100f83558fe6049d 100644 --- a/Kernel/Memory/RegionTree.h +++ b/Kernel/Memory/RegionTree.h @@ -58,7 +58,8 @@ private: ErrorOr allocate_range_specific(VirtualAddress base, size_t size); ErrorOr allocate_range_randomized(size_t size, size_t alignment = PAGE_SIZE); - RecursiveSpinlock mutable m_lock; + // FIXME: We need a Region rank, but we don't know where to put it. + RecursiveSpinlock mutable m_lock { LockRank::None }; IntrusiveRedBlackTree<&Region::m_tree_node> m_regions; VirtualRange const m_total_range; diff --git a/Kernel/Memory/RingBuffer.h b/Kernel/Memory/RingBuffer.h index eb97c532534f91fb9d3405fc9a0941433c376d04..2ea0811e3ab3beb6a1b1dc5b614089883407880f 100644 --- a/Kernel/Memory/RingBuffer.h +++ b/Kernel/Memory/RingBuffer.h @@ -32,7 +32,7 @@ private: RingBuffer(NonnullOwnPtr region, size_t capacity); NonnullOwnPtr m_region; - Spinlock m_lock; + Spinlock m_lock { LockRank::None }; size_t m_start_of_used {}; size_t m_num_used_bytes {}; size_t m_capacity_in_bytes {}; diff --git a/Kernel/Memory/SharedFramebufferVMObject.h b/Kernel/Memory/SharedFramebufferVMObject.h index 90e195aa34b9e75cc19785499d2073897d52c836..5fb43b196073340d18dd78c39bf9185da8b6ee84 100644 --- a/Kernel/Memory/SharedFramebufferVMObject.h +++ b/Kernel/Memory/SharedFramebufferVMObject.h @@ -87,7 +87,7 @@ private: RefPtr m_fake_writes_framebuffer_vmobject; RefPtr m_real_writes_framebuffer_vmobject; bool m_writes_are_faked { false }; - mutable RecursiveSpinlock m_writes_state_lock; + mutable RecursiveSpinlock m_writes_state_lock { LockRank::None }; CommittedPhysicalPageSet m_committed_pages; }; diff --git a/Kernel/Memory/VMObject.h b/Kernel/Memory/VMObject.h index 557c107d54d225d610b78da43cac5cada9f3fb0c..186e2998f69f7761f2086acac3c75458be15e91b 100644 --- a/Kernel/Memory/VMObject.h +++ b/Kernel/Memory/VMObject.h @@ -65,7 +65,7 @@ protected: IntrusiveListNode m_list_node; FixedArray> m_physical_pages; - mutable RecursiveSpinlock m_lock; + mutable RecursiveSpinlock m_lock { LockRank::None }; private: VMObject& operator=(VMObject const&) = delete; diff --git a/Kernel/Net/NetworkingManagement.h b/Kernel/Net/NetworkingManagement.h index 00015d47a2f753156b7f42c29daeb1c92e9fa9f6..1d145f8503ebdef7e81b2c2a35f8d6265282909d 100644 --- a/Kernel/Net/NetworkingManagement.h +++ b/Kernel/Net/NetworkingManagement.h @@ -14,6 +14,7 @@ #include #include #include +#include namespace Kernel { @@ -41,7 +42,7 @@ public: private: RefPtr determine_network_device(PCI::DeviceIdentifier const&) const; - SpinlockProtected> m_adapters; + SpinlockProtected> m_adapters { LockRank::None }; RefPtr m_loopback_adapter; }; diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 38b82655ffdc518bc32393fbd3c5bf809791afa8..99fddecda9dcb823eca451ba3bc78be93d8a3eb0 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -45,7 +45,7 @@ static void create_signal_trampoline(); extern ProcessID g_init_pid; -RecursiveSpinlock g_profiling_lock; +RecursiveSpinlock g_profiling_lock { LockRank::None }; static Atomic next_pid; static Singleton> s_all_instances; READONLY_AFTER_INIT Memory::Region* g_signal_trampoline_region; @@ -233,9 +233,9 @@ Process::Process(NonnullOwnPtr name, UserID uid, GroupID gid, ProcessID : m_name(move(name)) , m_is_kernel_process(is_kernel_process) , m_executable(move(executable)) - , m_current_directory(move(current_directory)) + , m_current_directory(LockRank::None, move(current_directory)) , m_tty(tty) - , m_unveil_data(move(unveil_tree)) + , m_unveil_data(LockRank::None, move(unveil_tree)) , m_wait_blocker_set(*this) { // Ensure that we protect the process data when exiting the constructor. diff --git a/Kernel/Process.h b/Kernel/Process.h index f9ed74368fe7ffba07c3bd98037d64011fb5ea50..940fe4ffa991dd4739aa5ba520d9a6e5417ad3b9 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -815,7 +815,7 @@ private: SpinlockProtected& thread_list() { return m_thread_list; } SpinlockProtected const& thread_list() const { return m_thread_list; } - SpinlockProtected m_thread_list; + SpinlockProtected m_thread_list { LockRank::None }; MutexProtected m_fds; @@ -859,7 +859,7 @@ private: OwnPtr value; }; - SpinlockProtected> m_coredump_properties; + SpinlockProtected> m_coredump_properties { LockRank::None }; NonnullRefPtrVector m_threads_for_coredump; mutable RefPtr m_procfs_traits; diff --git a/Kernel/ProcessExposed.cpp b/Kernel/ProcessExposed.cpp index e553103b37d6a2ad671b2790d1b23dc92a8825ca..d3e883b1e2651958c3f904a92bcc0799b8278205 100644 --- a/Kernel/ProcessExposed.cpp +++ b/Kernel/ProcessExposed.cpp @@ -15,7 +15,7 @@ namespace Kernel { -static Spinlock s_index_lock; +static Spinlock s_index_lock { LockRank::None }; static InodeIndex s_next_inode_index = 0; namespace SegmentedProcFSIndex { diff --git a/Kernel/Random.h b/Kernel/Random.h index 0213b83c9d06fb59786f7c159b0c2bebfa6be610..1fd2b0e3d7f819a6b047e5121038fd6ac2673d78 100644 --- a/Kernel/Random.h +++ b/Kernel/Random.h @@ -117,7 +117,7 @@ private: size_t m_p0_len { 0 }; ByteBuffer m_key; HashType m_pools[pool_count]; - Spinlock m_lock; + Spinlock m_lock { LockRank::None }; }; class KernelRng : public FortunaPRNG { diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 6fef23d6202d1cf80494b8da3e4f6ac64bd6ee88..4fb95329ebb7b97cba00659dffdeda84e11d2236 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -22,7 +22,7 @@ namespace Kernel { -RecursiveSpinlock g_scheduler_lock; +RecursiveSpinlock g_scheduler_lock { LockRank::None }; static u32 time_slice_for(Thread const& thread) { @@ -49,7 +49,7 @@ struct ThreadReadyQueues { static Singleton> g_ready_queues; -static SpinlockProtected g_total_time_scheduled; +static SpinlockProtected g_total_time_scheduled { LockRank::None }; // The Scheduler::current_time function provides a current time for scheduling purposes, // which may not necessarily relate to wall time diff --git a/Kernel/Storage/ATA/AHCI/Controller.h b/Kernel/Storage/ATA/AHCI/Controller.h index a2cdc24498ef33c8ab92317b21ed848ed0248e03..10dfda9508544821fc9084fc7027056529b2bb13 100644 --- a/Kernel/Storage/ATA/AHCI/Controller.h +++ b/Kernel/Storage/ATA/AHCI/Controller.h @@ -60,6 +60,6 @@ private: // Note: This lock is intended to be locked when doing changes to HBA registers // that affect its core functionality in a manner that controls all attached storage devices // to the HBA SATA ports. - mutable Spinlock m_hba_control_lock; + mutable Spinlock m_hba_control_lock { LockRank::None }; }; } diff --git a/Kernel/Storage/ATA/AHCI/Port.h b/Kernel/Storage/ATA/AHCI/Port.h index b2a38dd1f41f9576a5e5fe65ba346a55127b5354..f551fb13c4b3086c66c9b6e80a376de0ab16f73e 100644 --- a/Kernel/Storage/ATA/AHCI/Port.h +++ b/Kernel/Storage/ATA/AHCI/Port.h @@ -106,7 +106,7 @@ private: EntropySource m_entropy_source; RefPtr m_current_request; - Spinlock m_hard_lock; + Spinlock m_hard_lock { LockRank::None }; Mutex m_lock { "AHCIPort"sv }; mutable bool m_wait_for_completion { false }; diff --git a/Kernel/Storage/ATA/ATAPort.h b/Kernel/Storage/ATA/ATAPort.h index 272307502c95f9c9db0009edeae337f191f9fb77..c8d9db28826f835ae6f15415d5456ad13977f743 100644 --- a/Kernel/Storage/ATA/ATAPort.h +++ b/Kernel/Storage/ATA/ATAPort.h @@ -135,7 +135,7 @@ protected: } mutable Mutex m_lock; - Spinlock m_hard_lock; + Spinlock m_hard_lock { LockRank::None }; EntropySource m_entropy_source; diff --git a/Kernel/Storage/NVMe/NVMeQueue.h b/Kernel/Storage/NVMe/NVMeQueue.h index 66ca555da71e4e056fea23874464db8cb6bd4bef..49c2e9ec9aec99d20fdea74e7343e6d105df0f5a 100644 --- a/Kernel/Storage/NVMe/NVMeQueue.h +++ b/Kernel/Storage/NVMe/NVMeQueue.h @@ -58,7 +58,7 @@ protected: Spinlock m_cq_lock { LockRank::Interrupts }; RefPtr m_current_request; NonnullOwnPtr m_rw_dma_region; - Spinlock m_request_lock; + Spinlock m_request_lock { LockRank::None }; private: u16 m_qid {}; diff --git a/Kernel/TTY/ConsoleManagement.h b/Kernel/TTY/ConsoleManagement.h index 66afefa5420f9526f785ece8c0f59bafea222f63..c2a79176a7ddd0fc3fb475362e74f85bbf7063f9 100644 --- a/Kernel/TTY/ConsoleManagement.h +++ b/Kernel/TTY/ConsoleManagement.h @@ -39,8 +39,8 @@ public: private: NonnullRefPtrVector m_consoles; VirtualConsole* m_active_console { nullptr }; - Spinlock m_lock; - RecursiveSpinlock m_tty_write_lock; + Spinlock m_lock { LockRank::None }; + RecursiveSpinlock m_tty_write_lock { LockRank::None }; }; }; diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index 7ae972a601f6c7a3434f690086a63f2fb3f22a3c..0955fd68dc322d907547748609a3eb67167ecce1 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -35,7 +35,7 @@ private: virtual StringView class_name() const override { return "PTYMultiplexer"sv; } static constexpr size_t max_pty_pairs = 64; - SpinlockProtected> m_freelist; + SpinlockProtected> m_freelist { LockRank::None }; }; } diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 09a6f2f6b4d1e488f7e58634d2f9b985db908374..9166c9e1d68075bef75f833144d7ebe62ecff172 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -382,7 +382,8 @@ public: bool add_to_blocker_set(BlockerSet&, void* = nullptr); void set_blocker_set_raw_locked(BlockerSet* blocker_set) { m_blocker_set = blocker_set; } - mutable RecursiveSpinlock m_lock; + // FIXME: Figure out whether this can be Thread. + mutable RecursiveSpinlock m_lock { LockRank::None }; private: BlockerSet* m_blocker_set { nullptr }; @@ -500,7 +501,8 @@ public: blockers_to_append.clear(); } - mutable Spinlock m_lock; + // FIXME: Check whether this can be Thread. + mutable Spinlock m_lock { LockRank::None }; private: Vector m_blockers; @@ -1227,7 +1229,7 @@ private: void reset_fpu_state(); mutable RecursiveSpinlock m_lock { LockRank::Thread }; - mutable RecursiveSpinlock m_block_lock; + mutable RecursiveSpinlock m_block_lock { LockRank::None }; NonnullRefPtr m_process; ThreadID m_tid { -1 }; ThreadRegisters m_regs {}; @@ -1274,7 +1276,7 @@ private: unsigned count; }; Atomic m_holding_locks { 0 }; - Spinlock m_holding_locks_lock; + Spinlock m_holding_locks_lock { LockRank::None }; Vector m_holding_locks_list; #endif diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp index 3291f0db5d24393e9dbb801ab462b1818dea3041..63492e2fe04ef68923bd3389b10612bfaa28ae13 100644 --- a/Kernel/TimerQueue.cpp +++ b/Kernel/TimerQueue.cpp @@ -14,7 +14,7 @@ namespace Kernel { static Singleton s_the; -static Spinlock g_timerqueue_lock; +static Spinlock g_timerqueue_lock { LockRank::None }; Time Timer::remaining() const { diff --git a/Kernel/WorkQueue.h b/Kernel/WorkQueue.h index af72199e02c9d23106407ada107d7593c7e27ffa..e795b9d4825f2cf8ee9f02d607b00784acdaa335 100644 --- a/Kernel/WorkQueue.h +++ b/Kernel/WorkQueue.h @@ -63,7 +63,7 @@ private: RefPtr m_thread; WaitQueue m_wait_queue; - SpinlockProtected> m_items; + SpinlockProtected> m_items { LockRank::None }; }; } diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index 0b8f7360e9a6edd5e1afd88d92905b35c9fccb7f..b42888e19eaa5f938e129c8d9e5c53009ae3a46f 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -26,7 +26,7 @@ extern Atomic g_boot_console; static bool serial_debug; // A recursive spinlock allows us to keep writing in the case where a // page fault happens in the middle of a dbgln(), etc -static RecursiveSpinlock s_log_lock; +static RecursiveSpinlock s_log_lock { LockRank::None }; void set_serial_debug(bool on_or_off) {