diff --git a/Kernel/Arch/Spinlock.h b/Kernel/Arch/Spinlock.h index 0575b400be5..084abb69ef8 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 fa1dc16fb28..14b0d401238 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 aa5a1e2849b..a5baad70d73 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 ad15ffd8c74..dc9b5d87de1 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 12a5940e15d..6563779866f 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 bc7376e55d6..47d5aacc931 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 c6c5dc158a3..f904d5b72cf 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 2d68440992e..228c7aba915 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 11e3a035a19..3c143f4c245 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 0b4f57ee7bc..d9146f95b46 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 8806fbe7d1b..49d45f4d260 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 658dfc9712f..c09a2a32c02 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 273fde66619..6bc31594254 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 d7317a6799a..8c9b0b56689 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 3cfc9c7ab20..b6b5ccd35ed 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 5827e17e852..85755e8d99d 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 de22fa74ee0..945ef1b23b6 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 829a3a9e9f2..a1315f907c0 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 cae3edb872f..78af118ff5c 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 615bbe8fdca..d9a462b1772 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 825453ecdf5..6aee4a4e4ee 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 6632fd81aa7..a560a9d62d3 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 158a92a90ab..9a72bc0bee8 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 a164c97ab18..f7c186b36ee 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 86e5bbdb67b..690109ff4df 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 e3eee8c715d..533e64a6b6e 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 12666e309f6..cb5671da46a 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 d486b40f0cd..763e45176aa 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 d45108f1066..33c015efecc 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 84e2ef0dbaf..b71995dbb92 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 212298d975c..9ef605c6d90 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 fbaa5d85212..1659b9036ad 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 22681b985ff..5172d2ee130 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 37769ce79dd..92ec8326f93 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 1072c425cc9..e40248b7fdb 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 f32e260c8bc..12b2212659f 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 562b8caa763..5733235ce90 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 4828f9b1595..010fae183b5 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 8aecc3c0493..842519dd0fd 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 93f6047bfbb..aa5226d4480 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 eb97c532534..2ea0811e3ab 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 90e195aa34b..5fb43b19607 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 557c107d54d..186e2998f69 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 00015d47a2f..1d145f8503e 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 38b82655ffd..99fddecda9d 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 f9ed74368fe..940fe4ffa99 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 e553103b37d..d3e883b1e26 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 0213b83c9d0..1fd2b0e3d7f 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 6fef23d6202..4fb95329ebb 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 a2cdc24498e..10dfda95085 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 b2a38dd1f41..f551fb13c4b 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 272307502c9..c8d9db28826 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 66ca555da71..49c2e9ec9ae 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 66afefa5420..c2a79176a7d 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 7ae972a601f..0955fd68dc3 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 09a6f2f6b4d..9166c9e1d68 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 3291f0db5d2..63492e2fe04 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 af72199e02c..e795b9d4825 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 0b8f7360e9a..b42888e19ea 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) {