diff --git a/AK/Singleton.h b/AK/Singleton.h index ed104befd0..626ba07b91 100644 --- a/AK/Singleton.h +++ b/AK/Singleton.h @@ -39,12 +39,11 @@ struct SingletonInstanceCreator { #ifdef KERNEL -// FIXME: Find a nice way of injecting the lock rank into the singleton. -template -struct SingletonInstanceCreator> { - static Kernel::SpinlockProtected* create() +template +struct SingletonInstanceCreator> { + static Kernel::SpinlockProtected* create() { - return new Kernel::SpinlockProtected { Kernel::LockRank::None }; + return new Kernel::SpinlockProtected {}; } }; #endif diff --git a/Kernel/Arch/x86_64/ISABus/I8042Controller.h b/Kernel/Arch/x86_64/ISABus/I8042Controller.h index 997cf4517d..e62b5517a3 100644 --- a/Kernel/Arch/x86_64/ISABus/I8042Controller.h +++ b/Kernel/Arch/x86_64/ISABus/I8042Controller.h @@ -153,7 +153,7 @@ private: void do_write(u8 port, u8 data); u8 do_read(u8 port); - Spinlock m_lock { LockRank::None }; + Spinlock m_lock {}; bool m_first_port_available { false }; bool m_second_port_available { false }; bool m_is_dual_channel { false }; diff --git a/Kernel/Arch/x86_64/PageDirectory.cpp b/Kernel/Arch/x86_64/PageDirectory.cpp index 1efe016508..89bfc63813 100644 --- a/Kernel/Arch/x86_64/PageDirectory.cpp +++ b/Kernel/Arch/x86_64/PageDirectory.cpp @@ -12,7 +12,7 @@ namespace Kernel::Memory { struct CR3Map { - SpinlockProtected> map { LockRank::None }; + SpinlockProtected, LockRank::None> map {}; }; static Singleton s_cr3_map; diff --git a/Kernel/Arch/x86_64/VGA/IOArbiter.h b/Kernel/Arch/x86_64/VGA/IOArbiter.h index 711f8324d8..70bcf4dc78 100644 --- a/Kernel/Arch/x86_64/VGA/IOArbiter.h +++ b/Kernel/Arch/x86_64/VGA/IOArbiter.h @@ -33,7 +33,7 @@ private: void disable_vga_text_mode_console_cursor(); void enable_vga_text_mode_console_cursor(); - RecursiveSpinlock m_main_vga_lock { LockRank::None }; + RecursiveSpinlock m_main_vga_lock {}; bool m_vga_access_is_disabled { false }; }; diff --git a/Kernel/Bus/PCI/Access.h b/Kernel/Bus/PCI/Access.h index 81959c8750..e0fd8a924b 100644 --- a/Kernel/Bus/PCI/Access.h +++ b/Kernel/Bus/PCI/Access.h @@ -41,8 +41,8 @@ public: u32 read32_field(Address address, u32 field); DeviceIdentifier get_device_identifier(Address address) const; - Spinlock const& scan_lock() const { return m_scan_lock; } - RecursiveSpinlock const& access_lock() const { return m_access_lock; } + Spinlock const& scan_lock() const { return m_scan_lock; } + RecursiveSpinlock const& access_lock() const { return m_access_lock; } ErrorOr add_host_controller_and_enumerate_attached_devices(NonnullOwnPtr, Function callback); @@ -57,8 +57,8 @@ private: Vector get_capabilities(Address); Optional get_capabilities_pointer(Address address); - mutable RecursiveSpinlock m_access_lock { LockRank::None }; - mutable Spinlock m_scan_lock { LockRank::None }; + mutable RecursiveSpinlock m_access_lock {}; + mutable Spinlock m_scan_lock {}; 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 a5baad70d7..5e016601ff 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 { LockRank::None }; + Spinlock m_config_lock {}; }; } diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp index 17e0df4344..d9867968de 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.cpp +++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp @@ -90,8 +90,6 @@ UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::DeviceIdentifier const& pci : PCI::Device(pci_device_identifier.address()) , IRQHandler(pci_device_identifier.interrupt_line().value()) , m_registers_io_window(move(registers_io_window)) - , m_async_lock(LockRank::None) - , m_schedule_lock(LockRank::None) { } diff --git a/Kernel/Bus/USB/UHCI/UHCIController.h b/Kernel/Bus/USB/UHCI/UHCIController.h index ccbd218e6f..1b45461cd5 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.h +++ b/Kernel/Bus/USB/UHCI/UHCIController.h @@ -100,8 +100,8 @@ private: NonnullOwnPtr m_registers_io_window; - Spinlock m_async_lock; - Spinlock m_schedule_lock; + Spinlock m_async_lock {}; + Spinlock m_schedule_lock {}; OwnPtr m_root_hub; OwnPtr> m_queue_head_pool; diff --git a/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h b/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h index dc9b5d87de..e1dbb41e57 100644 --- a/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h +++ b/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h @@ -70,7 +70,6 @@ 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++) { @@ -84,7 +83,7 @@ private: StringView m_pool_name; // Name of this pool NonnullOwnPtr m_pool_region; // Memory region where descriptors actually reside Stack m_free_descriptor_stack; // Stack of currently free descriptor pointers - Spinlock m_pool_lock; + Spinlock m_pool_lock; }; } diff --git a/Kernel/Bus/VirtIO/Queue.h b/Kernel/Bus/VirtIO/Queue.h index 6563779866..26edc622f3 100644 --- a/Kernel/Bus/VirtIO/Queue.h +++ b/Kernel/Bus/VirtIO/Queue.h @@ -47,7 +47,7 @@ public: QueueChain pop_used_buffer_chain(size_t& used); void discard_used_buffers(); - Spinlock& lock() { return m_lock; } + Spinlock& lock() { return m_lock; } bool should_notify() const; @@ -96,7 +96,7 @@ private: QueueDriver* m_driver { nullptr }; QueueDevice* m_device { nullptr }; NonnullOwnPtr m_queue_region; - Spinlock m_lock { LockRank::None }; + Spinlock m_lock {}; friend class QueueChain; }; diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index a14c4cc833..fc1ff6795c 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -236,7 +236,6 @@ set(KERNEL_SOURCES MiniStdLib.cpp Locking/LockRank.cpp Locking/Mutex.cpp - Locking/Spinlock.cpp Net/Intel/E1000ENetworkAdapter.cpp Net/Intel/E1000NetworkAdapter.cpp Net/NE2000/NetworkAdapter.cpp diff --git a/Kernel/Coredump.cpp b/Kernel/Coredump.cpp index 3ffd60b133..ea36e60270 100644 --- a/Kernel/Coredump.cpp +++ b/Kernel/Coredump.cpp @@ -23,11 +23,11 @@ #define INCLUDE_USERSPACE_HEAP_MEMORY_IN_COREDUMPS 0 -static Singleton>> s_coredump_directory_path; +static Singleton, LockRank::None>> s_coredump_directory_path; namespace Kernel { -SpinlockProtected>& Coredump::directory_path() +SpinlockProtected, LockRank::None>& Coredump::directory_path() { return s_coredump_directory_path; } diff --git a/Kernel/Coredump.h b/Kernel/Coredump.h index d1acea68d8..2b9f7127f7 100644 --- a/Kernel/Coredump.h +++ b/Kernel/Coredump.h @@ -19,7 +19,7 @@ namespace Kernel { class Coredump { public: static ErrorOr> try_create(NonnullLockRefPtr, StringView output_path); - static SpinlockProtected>& directory_path(); + static SpinlockProtected, LockRank::None>& directory_path(); ~Coredump() = default; ErrorOr write(); diff --git a/Kernel/Devices/AsyncDeviceRequest.h b/Kernel/Devices/AsyncDeviceRequest.h index 79c94f2e86..449b2f9d84 100644 --- a/Kernel/Devices/AsyncDeviceRequest.h +++ b/Kernel/Devices/AsyncDeviceRequest.h @@ -62,7 +62,7 @@ public: [[nodiscard]] RequestWaitResult wait(Time* = nullptr); - void do_start(SpinlockLocker&& requests_lock) + void do_start(SpinlockLocker>&& requests_lock) { if (is_completed_result(m_result)) return; @@ -151,7 +151,7 @@ private: WaitQueue m_queue; NonnullLockRefPtr m_process; void* m_private { nullptr }; - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; }; } diff --git a/Kernel/Devices/Audio/AC97.h b/Kernel/Devices/Audio/AC97.h index 9ad53a8d18..092b9115ba 100644 --- a/Kernel/Devices/Audio/AC97.h +++ b/Kernel/Devices/Audio/AC97.h @@ -147,7 +147,7 @@ private: NonnullOwnPtr m_channel_io_window; PCI::Address m_device_pci_address; - SpinlockProtected m_dma_running { LockRank::None, false }; + SpinlockProtected m_dma_running { false }; StringView m_name; }; diff --git a/Kernel/Devices/ConsoleDevice.cpp b/Kernel/Devices/ConsoleDevice.cpp index 92044f852b..c68c8fe1ff 100644 --- a/Kernel/Devices/ConsoleDevice.cpp +++ b/Kernel/Devices/ConsoleDevice.cpp @@ -16,7 +16,7 @@ namespace Kernel { -Spinlock g_console_lock { LockRank::None }; +Spinlock g_console_lock {}; UNMAP_AFTER_INIT NonnullLockRefPtr ConsoleDevice::must_create() { diff --git a/Kernel/Devices/ConsoleDevice.h b/Kernel/Devices/ConsoleDevice.h index 3800a58baa..d9eb6377f7 100644 --- a/Kernel/Devices/ConsoleDevice.h +++ b/Kernel/Devices/ConsoleDevice.h @@ -12,7 +12,7 @@ namespace Kernel { -extern Spinlock g_console_lock; +extern Spinlock g_console_lock; class ConsoleDevice final : public CharacterDevice { friend class DeviceManagement; diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index dcfb263fd7..4a1e51c219 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -90,7 +90,7 @@ private: State m_state { State::Normal }; - Spinlock m_requests_lock { LockRank::None }; + Spinlock m_requests_lock {}; DoublyLinkedList> m_requests; protected: diff --git a/Kernel/Devices/DeviceManagement.h b/Kernel/Devices/DeviceManagement.h index 4d4d71cca9..d96a4d2a93 100644 --- a/Kernel/Devices/DeviceManagement.h +++ b/Kernel/Devices/DeviceManagement.h @@ -74,9 +74,9 @@ private: LockRefPtr m_console_device; LockRefPtr m_device_control_device; // FIXME: Once we have a singleton for managing many sound cards, remove this from here - SpinlockProtected> m_devices { LockRank::None }; + SpinlockProtected, LockRank::None> m_devices {}; - mutable Spinlock m_event_queue_lock { LockRank::None }; + mutable Spinlock m_event_queue_lock {}; CircularQueue m_event_queue; }; diff --git a/Kernel/Devices/HID/HIDManagement.h b/Kernel/Devices/HID/HIDManagement.h index c63c868cc4..bf1d17f5b1 100644 --- a/Kernel/Devices/HID/HIDManagement.h +++ b/Kernel/Devices/HID/HIDManagement.h @@ -47,7 +47,7 @@ public: Keyboard::CharacterMapData character_map; }; - SpinlockProtected& keymap_data() { return m_keymap_data; } + SpinlockProtected& keymap_data() { return m_keymap_data; } u32 get_char_from_character_map(KeyEvent) const; @@ -58,7 +58,7 @@ private: size_t generate_minor_device_number_for_mouse(); size_t generate_minor_device_number_for_keyboard(); - SpinlockProtected m_keymap_data { LockRank::None }; + SpinlockProtected m_keymap_data {}; size_t m_mouse_minor_number { 0 }; size_t m_keyboard_minor_number { 0 }; KeyboardClient* m_client { nullptr }; @@ -66,7 +66,7 @@ private: LockRefPtr m_i8042_controller; #endif NonnullLockRefPtrVector m_hid_devices; - Spinlock m_client_lock { LockRank::None }; + Spinlock m_client_lock {}; }; class KeyboardClient { diff --git a/Kernel/Devices/HID/KeyboardDevice.h b/Kernel/Devices/HID/KeyboardDevice.h index 95152f4252..85896e9bf1 100644 --- a/Kernel/Devices/HID/KeyboardDevice.h +++ b/Kernel/Devices/HID/KeyboardDevice.h @@ -45,7 +45,7 @@ public: protected: KeyboardDevice(); - mutable Spinlock m_queue_lock { LockRank::None }; + mutable Spinlock m_queue_lock {}; 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 68f57c66dc..f32fa11d9f 100644 --- a/Kernel/Devices/HID/MouseDevice.h +++ b/Kernel/Devices/HID/MouseDevice.h @@ -35,7 +35,7 @@ protected: // ^CharacterDevice virtual StringView class_name() const override { return "MouseDevice"sv; } - mutable Spinlock m_queue_lock { LockRank::None }; + mutable Spinlock m_queue_lock {}; CircularQueue m_queue; }; diff --git a/Kernel/Devices/KCOVInstance.h b/Kernel/Devices/KCOVInstance.h index 6958de0b8a..a5c97cca08 100644 --- a/Kernel/Devices/KCOVInstance.h +++ b/Kernel/Devices/KCOVInstance.h @@ -46,7 +46,7 @@ public: Memory::VMObject* vmobject() { return m_vmobject; } - Spinlock& spinlock() { return m_lock; } + Spinlock& spinlock() { return m_lock; } private: ProcessID m_pid { 0 }; @@ -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 { LockRank::None }; + Spinlock m_lock {}; }; } diff --git a/Kernel/Devices/SerialDevice.h b/Kernel/Devices/SerialDevice.h index 11448aca61..3d1866dd95 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 { LockRank::None }; + Spinlock m_serial_lock {}; }; } diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index 0c40a26197..bf94934413 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -14,9 +14,9 @@ namespace Kernel { -static Singleton> s_all_instances; +static Singleton> s_all_instances; -SpinlockProtected& Custody::all_instances() +SpinlockProtected& Custody::all_instances() { return s_all_instances; } diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index f72cf071c6..8d6edba176 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -44,7 +44,7 @@ private: public: using AllCustodiesList = IntrusiveList<&Custody::m_all_custodies_list_node>; - static SpinlockProtected& all_instances(); + static SpinlockProtected& all_instances(); }; } diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 39ae416ca6..4c6c1253c7 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -61,7 +61,7 @@ public: // Converts file types that are used internally by the filesystem to DT_* types virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const { return entry.file_type; } - SpinlockProtected& mounted_count(Badge) { return m_attach_count; } + SpinlockProtected& mounted_count(Badge) { return m_attach_count; } protected: FileSystem(); @@ -79,7 +79,7 @@ private: size_t m_fragment_size { 0 }; bool m_readonly { false }; - SpinlockProtected m_attach_count { LockRank::FileSystem, 0 }; + SpinlockProtected m_attach_count { 0 }; IntrusiveListNode m_file_system_node; }; diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index a5581b323d..e6b8f1ef14 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -22,9 +22,9 @@ namespace Kernel { -static Singleton> s_all_instances; +static Singleton> s_all_instances; -SpinlockProtected& Inode::all_instances() +SpinlockProtected& Inode::all_instances() { return s_all_instances; } diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index cafa6630d4..c954de927a 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -132,7 +132,7 @@ private: InodeIndex m_index { 0 }; LockWeakPtr m_shared_vmobject; LockRefPtr m_bound_socket; - SpinlockProtected> m_watchers { LockRank::None }; + SpinlockProtected, LockRank::None> m_watchers {}; bool m_metadata_dirty { false }; LockRefPtr m_fifo; IntrusiveListNode m_inode_list_node; @@ -146,11 +146,11 @@ private: }; Thread::FlockBlockerSet m_flock_blocker_set; - SpinlockProtected> m_flocks { LockRank::None }; + SpinlockProtected, LockRank::None> m_flocks {}; public: using AllInstancesList = IntrusiveList<&Inode::m_inode_list_node>; - static SpinlockProtected& all_instances(); + static SpinlockProtected& all_instances(); }; } diff --git a/Kernel/FileSystem/Mount.cpp b/Kernel/FileSystem/Mount.cpp index 733147d746..b123b78ddc 100644 --- a/Kernel/FileSystem/Mount.cpp +++ b/Kernel/FileSystem/Mount.cpp @@ -14,7 +14,7 @@ namespace Kernel { Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags) : m_guest(guest_fs.root_inode()) , m_guest_fs(guest_fs) - , m_host_custody(LockRank::None, host_custody) + , m_host_custody(host_custody) , m_flags(flags) { } @@ -22,7 +22,7 @@ Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags) Mount::Mount(Inode& source, Custody& host_custody, int flags) : m_guest(source) , m_guest_fs(source.fs()) - , m_host_custody(LockRank::None, host_custody) + , m_host_custody(host_custody) , m_flags(flags) { } diff --git a/Kernel/FileSystem/Mount.h b/Kernel/FileSystem/Mount.h index 6d4dc6c608..d0676a797e 100644 --- a/Kernel/FileSystem/Mount.h +++ b/Kernel/FileSystem/Mount.h @@ -40,7 +40,7 @@ public: private: NonnullLockRefPtr m_guest; NonnullLockRefPtr m_guest_fs; - SpinlockProtected> m_host_custody; + SpinlockProtected, LockRank::None> m_host_custody; int m_flags; IntrusiveListNode m_vfs_list_node; diff --git a/Kernel/FileSystem/OpenFileDescription.h b/Kernel/FileSystem/OpenFileDescription.h index bb6edce3d9..c7972c1d3f 100644 --- a/Kernel/FileSystem/OpenFileDescription.h +++ b/Kernel/FileSystem/OpenFileDescription.h @@ -157,6 +157,6 @@ private: FIFO::Direction fifo_direction : 2 { FIFO::Direction::Neither }; }; - SpinlockProtected m_state { LockRank::None }; + SpinlockProtected m_state {}; }; } diff --git a/Kernel/FileSystem/Plan9FS/FileSystem.h b/Kernel/FileSystem/Plan9FS/FileSystem.h index 1f5c4af322..3b4ee0c0cc 100644 --- a/Kernel/FileSystem/Plan9FS/FileSystem.h +++ b/Kernel/FileSystem/Plan9FS/FileSystem.h @@ -63,11 +63,11 @@ private: private: Plan9FS& m_fs; - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; }; struct ReceiveCompletion final : public AtomicRefCounted { - mutable Spinlock lock { LockRank::None }; + mutable Spinlock lock {}; bool completed { false }; const u16 tag; OwnPtr message; @@ -136,7 +136,7 @@ private: Plan9FSBlockerSet m_completion_blocker; HashMap> m_completions; - Spinlock m_thread_lock { LockRank::None }; + Spinlock m_thread_lock {}; LockRefPtr 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 a79bf06200..274216718f 100644 --- a/Kernel/FileSystem/SysFS/Component.cpp +++ b/Kernel/FileSystem/SysFS/Component.cpp @@ -13,7 +13,7 @@ namespace Kernel { -static Spinlock s_index_lock { LockRank::None }; +static Spinlock s_index_lock {}; 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 4b18eeaf88..3f9b5643f5 100644 --- a/Kernel/FileSystem/SysFS/Component.h +++ b/Kernel/FileSystem/SysFS/Component.h @@ -80,14 +80,14 @@ public: virtual ErrorOr> to_inode(SysFS const& sysfs_instance) const override final; - using ChildList = SpinlockProtected>; + using ChildList = SpinlockProtected, LockRank::None>; protected: virtual bool is_root_directory() const { return false; } SysFSDirectory() {}; explicit SysFSDirectory(SysFSDirectory const& parent_directory); - ChildList m_child_components { LockRank::None }; + ChildList m_child_components {}; }; } diff --git a/Kernel/FileSystem/SysFS/Registry.h b/Kernel/FileSystem/SysFS/Registry.h index c0113eb29d..360e29a5a5 100644 --- a/Kernel/FileSystem/SysFS/Registry.h +++ b/Kernel/FileSystem/SysFS/Registry.h @@ -32,7 +32,7 @@ public: private: NonnullLockRefPtr m_root_directory; - Spinlock m_root_directory_lock { LockRank::None }; + Spinlock m_root_directory_lock {}; }; } diff --git a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.h index 9a72bc0bee..36761345b9 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 { LockRank::None }; + mutable Spinlock m_lock {}; }; } diff --git a/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/CapsLockRemap.h b/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/CapsLockRemap.h index f0bd11bf9f..a4b18c8f49 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/CapsLockRemap.h +++ b/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/CapsLockRemap.h @@ -25,7 +25,7 @@ private: explicit SysFSCapsLockRemap(SysFSDirectory const&); - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; }; } diff --git a/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.h b/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.h index 1bc2ad995e..8b8ab77f0d 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.h +++ b/Kernel/FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.h @@ -25,7 +25,7 @@ private: explicit SysFSDumpKmallocStacks(SysFSDirectory const&); - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; }; } diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 98621c85ec..fb45580216 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -39,7 +39,6 @@ VirtualFileSystem& VirtualFileSystem::the() } UNMAP_AFTER_INIT VirtualFileSystem::VirtualFileSystem() - : m_root_custody(LockRank::None) { } diff --git a/Kernel/FileSystem/VirtualFileSystem.h b/Kernel/FileSystem/VirtualFileSystem.h index 07c5af9055..06a8b7abc8 100644 --- a/Kernel/FileSystem/VirtualFileSystem.h +++ b/Kernel/FileSystem/VirtualFileSystem.h @@ -113,11 +113,11 @@ private: LockRefPtr m_root_inode; - SpinlockProtected> m_root_custody; + SpinlockProtected, LockRank::None> m_root_custody {}; - SpinlockProtected> m_mounts { LockRank::None }; - SpinlockProtected> m_file_backed_file_systems_list { LockRank::None }; - SpinlockProtected> m_file_systems_list { LockRank::FileSystem }; + SpinlockProtected, LockRank::None> m_mounts {}; + SpinlockProtected, LockRank::None> m_file_backed_file_systems_list {}; + SpinlockProtected, LockRank::FileSystem> m_file_systems_list {}; }; } diff --git a/Kernel/Forward.h b/Kernel/Forward.h index 279abeae1d..88f53b2fda 100644 --- a/Kernel/Forward.h +++ b/Kernel/Forward.h @@ -11,6 +11,8 @@ namespace Kernel { +enum class LockRank; + class BlockDevice; class CharacterDevice; class Coredump; @@ -48,6 +50,7 @@ class ProcFSSystemBoolean; class ProcFSSystemDirectory; class Process; class ProcessGroup; +template class RecursiveSpinlock; class Scheduler; class Socket; @@ -85,6 +88,7 @@ class VMObject; class VirtualRange; } +template class Spinlock; template class SpinlockLocker; diff --git a/Kernel/Graphics/Console/BootFramebufferConsole.h b/Kernel/Graphics/Console/BootFramebufferConsole.h index b9819f5e12..1236656b50 100644 --- a/Kernel/Graphics/Console/BootFramebufferConsole.h +++ b/Kernel/Graphics/Console/BootFramebufferConsole.h @@ -39,7 +39,7 @@ protected: OwnPtr m_framebuffer; u8* m_framebuffer_data {}; - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; }; } diff --git a/Kernel/Graphics/Console/GenericFramebufferConsole.h b/Kernel/Graphics/Console/GenericFramebufferConsole.h index 0b38e43097..88ace335bd 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 { LockRank::None }; + mutable Spinlock m_lock {}; }; } diff --git a/Kernel/Graphics/Console/VGATextModeConsole.h b/Kernel/Graphics/Console/VGATextModeConsole.h index e67125b2dc..f487b1bfae 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 { LockRank::None }; + mutable Spinlock m_vga_lock {}; NonnullOwnPtr m_vga_window_region; VirtualAddress m_current_vga_window; diff --git a/Kernel/Graphics/DisplayConnector.h b/Kernel/Graphics/DisplayConnector.h index fd7e883070..157dffcbb0 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 { LockRank::None }; + mutable Spinlock m_control_lock {}; mutable Mutex m_flushing_lock; bool m_console_mode { false }; bool m_vertical_offsetted { false }; - mutable Spinlock m_modeset_lock { LockRank::None }; + mutable Spinlock m_modeset_lock {}; ModeSetting m_current_mode_setting {}; Optional m_edid_parser; @@ -165,7 +165,7 @@ private: LockRefPtr m_shared_framebuffer_vmobject; LockWeakPtr m_responsible_process; - Spinlock m_responsible_process_lock { LockRank::None }; + Spinlock m_responsible_process_lock {}; IntrusiveListNode> m_list_node; }; diff --git a/Kernel/Graphics/GraphicsManagement.h b/Kernel/Graphics/GraphicsManagement.h index 17e17bd06b..ec771c6528 100644 --- a/Kernel/Graphics/GraphicsManagement.h +++ b/Kernel/Graphics/GraphicsManagement.h @@ -64,7 +64,7 @@ private: unsigned m_current_minor_number { 0 }; - SpinlockProtected> m_display_connector_nodes { LockRank::None }; + SpinlockProtected, LockRank::None> m_display_connector_nodes {}; #if ARCH(X86_64) OwnPtr m_vga_arbiter; #endif diff --git a/Kernel/Graphics/Intel/NativeDisplayConnector.h b/Kernel/Graphics/Intel/NativeDisplayConnector.h index a5d77a20b1..0cd60a4358 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 { LockRank::None }; + mutable Spinlock m_registers_lock {}; LockRefPtr m_framebuffer_console; const PhysicalAddress m_registers; diff --git a/Kernel/Graphics/VMWare/GraphicsAdapter.h b/Kernel/Graphics/VMWare/GraphicsAdapter.h index 9f414dadb8..705b60865e 100644 --- a/Kernel/Graphics/VMWare/GraphicsAdapter.h +++ b/Kernel/Graphics/VMWare/GraphicsAdapter.h @@ -51,8 +51,8 @@ private: Memory::TypedMapping m_fifo_registers; LockRefPtr m_display_connector; mutable NonnullOwnPtr m_registers_io_window; - mutable Spinlock m_io_access_lock { LockRank::None }; - mutable RecursiveSpinlock m_operation_lock { LockRank::None }; + mutable Spinlock m_io_access_lock {}; + mutable RecursiveSpinlock m_operation_lock {}; }; } diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h index 2b5bedccb6..5b93a51820 100644 --- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h +++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h @@ -112,11 +112,11 @@ private: VirtIO::Configuration const* m_device_configuration { nullptr }; // Note: Resource ID 0 is invalid, and we must not allocate 0 as the first resource ID. Atomic m_resource_id_counter { 1 }; - SpinlockProtected m_active_context_ids { LockRank::None }; + SpinlockProtected m_active_context_ids {}; LockRefPtr m_3d_device; bool m_has_virgl_support { false }; - Spinlock m_operation_lock { LockRank::None }; + Spinlock m_operation_lock {}; NonnullOwnPtr m_scratch_space; }; } diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index de4a192399..6330550570 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -36,7 +36,7 @@ const nothrow_t nothrow; } // FIXME: Figure out whether this can be MemoryManager. -static RecursiveSpinlock s_lock { LockRank::None }; // needs to be recursive because of dump_backtrace() +static RecursiveSpinlock s_lock {}; // needs to be recursive because of dump_backtrace() struct KmallocSubheap { KmallocSubheap(u8* base, size_t size) diff --git a/Kernel/Jail.h b/Kernel/Jail.h index 8dc623193a..bfbc6c833a 100644 --- a/Kernel/Jail.h +++ b/Kernel/Jail.h @@ -34,7 +34,7 @@ public: JailIndex index() const { return m_index; } void detach(Badge); - SpinlockProtected& attach_count() { return m_attach_count; } + SpinlockProtected& attach_count() { return m_attach_count; } private: Jail(NonnullOwnPtr, JailIndex); @@ -43,7 +43,7 @@ private: JailIndex const m_index; IntrusiveListNode> m_jail_list_node; - SpinlockProtected m_attach_count { LockRank::None, 0 }; + SpinlockProtected m_attach_count { 0 }; }; } diff --git a/Kernel/JailManagement.h b/Kernel/JailManagement.h index 9f363bed66..76fe91cf82 100644 --- a/Kernel/JailManagement.h +++ b/Kernel/JailManagement.h @@ -36,7 +36,7 @@ public: private: JailIndex generate_jail_id(); - SpinlockProtected> m_jails { LockRank::None }; + SpinlockProtected, LockRank::None> m_jails {}; }; } diff --git a/Kernel/Locking/Mutex.cpp b/Kernel/Locking/Mutex.cpp index 99f836a077..5e4606add4 100644 --- a/Kernel/Locking/Mutex.cpp +++ b/Kernel/Locking/Mutex.cpp @@ -211,7 +211,7 @@ void Mutex::unlock() } } -void Mutex::block(Thread& current_thread, Mode mode, SpinlockLocker& lock, u32 requested_locks) +void Mutex::block(Thread& current_thread, Mode mode, SpinlockLocker>& lock, u32 requested_locks) { if constexpr (LOCK_IN_CRITICAL_DEBUG) { // There are no interrupts enabled in early boot. diff --git a/Kernel/Locking/Mutex.h b/Kernel/Locking/Mutex.h index beba56f8a0..17d59925ec 100644 --- a/Kernel/Locking/Mutex.h +++ b/Kernel/Locking/Mutex.h @@ -82,7 +82,8 @@ private: // FIXME: remove this after annihilating Process::m_big_lock using BigLockBlockedThreadList = IntrusiveList<&Thread::m_big_lock_blocked_threads_list_node>; - void block(Thread&, Mode, SpinlockLocker&, u32); + // FIXME: Allow any lock rank. + void block(Thread&, Mode, SpinlockLocker>&, u32); void unblock_waiters(Mode); StringView m_name; @@ -117,10 +118,10 @@ private: } }; // FIXME: Use a specific lock rank passed by constructor. - SpinlockProtected m_blocked_thread_lists { LockRank::None }; + SpinlockProtected m_blocked_thread_lists {}; // FIXME: See above. - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; #if LOCK_SHARED_UPGRADE_DEBUG HashMap m_shared_holders_map; diff --git a/Kernel/Locking/Spinlock.cpp b/Kernel/Locking/Spinlock.cpp deleted file mode 100644 index 7c1f57a2a1..0000000000 --- a/Kernel/Locking/Spinlock.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2020-2022, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -namespace Kernel { - -InterruptsState Spinlock::lock() -{ - InterruptsState previous_interrupts_state = processor_interrupts_state(); - Processor::enter_critical(); - Processor::disable_interrupts(); - while (m_lock.exchange(1, AK::memory_order_acquire) != 0) - Processor::wait_check(); - track_lock_acquire(m_rank); - return previous_interrupts_state; -} - -void Spinlock::unlock(InterruptsState previous_interrupts_state) -{ - VERIFY(is_locked()); - track_lock_release(m_rank); - m_lock.store(0, AK::memory_order_release); - - Processor::leave_critical(); - restore_processor_interrupts_state(previous_interrupts_state); -} - -InterruptsState RecursiveSpinlock::lock() -{ - InterruptsState previous_interrupts_state = processor_interrupts_state(); - Processor::disable_interrupts(); - Processor::enter_critical(); - auto& proc = Processor::current(); - FlatPtr cpu = FlatPtr(&proc); - FlatPtr expected = 0; - while (!m_lock.compare_exchange_strong(expected, cpu, AK::memory_order_acq_rel)) { - if (expected == cpu) - break; - Processor::wait_check(); - expected = 0; - } - if (m_recursions == 0) - track_lock_acquire(m_rank); - m_recursions++; - return previous_interrupts_state; -} - -void RecursiveSpinlock::unlock(InterruptsState previous_interrupts_state) -{ - VERIFY_INTERRUPTS_DISABLED(); - VERIFY(m_recursions > 0); - VERIFY(m_lock.load(AK::memory_order_relaxed) == FlatPtr(&Processor::current())); - if (--m_recursions == 0) { - track_lock_release(m_rank); - m_lock.store(0, AK::memory_order_release); - } - - Processor::leave_critical(); - restore_processor_interrupts_state(previous_interrupts_state); -} - -} diff --git a/Kernel/Locking/Spinlock.h b/Kernel/Locking/Spinlock.h index a7177d4209..fea5836b9e 100644 --- a/Kernel/Locking/Spinlock.h +++ b/Kernel/Locking/Spinlock.h @@ -13,18 +13,34 @@ namespace Kernel { +template class Spinlock { AK_MAKE_NONCOPYABLE(Spinlock); AK_MAKE_NONMOVABLE(Spinlock); public: - Spinlock(LockRank rank) - : m_rank(rank) + Spinlock() = default; + + InterruptsState lock() { + InterruptsState previous_interrupts_state = processor_interrupts_state(); + Processor::enter_critical(); + Processor::disable_interrupts(); + while (m_lock.exchange(1, AK::memory_order_acquire) != 0) + Processor::wait_check(); + track_lock_acquire(m_rank); + return previous_interrupts_state; } - InterruptsState lock(); - void unlock(InterruptsState); + void unlock(InterruptsState previous_interrupts_state) + { + VERIFY(is_locked()); + track_lock_release(m_rank); + m_lock.store(0, AK::memory_order_release); + + Processor::leave_critical(); + restore_processor_interrupts_state(previous_interrupts_state); + } [[nodiscard]] ALWAYS_INLINE bool is_locked() const { @@ -38,21 +54,50 @@ public: private: Atomic m_lock { 0 }; - const LockRank m_rank; + static constexpr LockRank const m_rank { Rank }; }; +template class RecursiveSpinlock { AK_MAKE_NONCOPYABLE(RecursiveSpinlock); AK_MAKE_NONMOVABLE(RecursiveSpinlock); public: - RecursiveSpinlock(LockRank rank) - : m_rank(rank) + RecursiveSpinlock() = default; + + InterruptsState lock() { + InterruptsState previous_interrupts_state = processor_interrupts_state(); + Processor::disable_interrupts(); + Processor::enter_critical(); + auto& proc = Processor::current(); + FlatPtr cpu = FlatPtr(&proc); + FlatPtr expected = 0; + while (!m_lock.compare_exchange_strong(expected, cpu, AK::memory_order_acq_rel)) { + if (expected == cpu) + break; + Processor::wait_check(); + expected = 0; + } + if (m_recursions == 0) + track_lock_acquire(m_rank); + m_recursions++; + return previous_interrupts_state; } - InterruptsState lock(); - void unlock(InterruptsState); + void unlock(InterruptsState previous_interrupts_state) + { + VERIFY_INTERRUPTS_DISABLED(); + VERIFY(m_recursions > 0); + VERIFY(m_lock.load(AK::memory_order_relaxed) == FlatPtr(&Processor::current())); + if (--m_recursions == 0) { + track_lock_release(m_rank); + m_lock.store(0, AK::memory_order_release); + } + + Processor::leave_critical(); + restore_processor_interrupts_state(previous_interrupts_state); + } [[nodiscard]] ALWAYS_INLINE bool is_locked() const { @@ -72,7 +117,7 @@ public: private: Atomic m_lock { 0 }; u32 m_recursions { 0 }; - const LockRank m_rank; + static constexpr LockRank const m_rank { Rank }; }; template diff --git a/Kernel/Locking/SpinlockProtected.h b/Kernel/Locking/SpinlockProtected.h index e40248b7fd..ced5e941cb 100644 --- a/Kernel/Locking/SpinlockProtected.h +++ b/Kernel/Locking/SpinlockProtected.h @@ -10,7 +10,7 @@ namespace Kernel { -template +template class SpinlockProtected { AK_MAKE_NONCOPYABLE(SpinlockProtected); AK_MAKE_NONMOVABLE(SpinlockProtected); @@ -22,7 +22,7 @@ private: AK_MAKE_NONMOVABLE(Locked); public: - Locked(U& value, RecursiveSpinlock& spinlock) + Locked(U& value, RecursiveSpinlock& spinlock) : m_value(value) , m_locker(spinlock) { @@ -39,7 +39,7 @@ private: private: U& m_value; - SpinlockLocker m_locker; + SpinlockLocker> m_locker; }; auto lock_const() const { return Locked(m_value, m_spinlock); } @@ -47,9 +47,8 @@ private: public: template - SpinlockProtected(LockRank rank, Args&&... args) + SpinlockProtected(Args&&... args) : m_value(forward(args)...) - , m_spinlock(rank) { } @@ -87,7 +86,8 @@ public: private: T m_value; - RecursiveSpinlock mutable m_spinlock; + RecursiveSpinlock mutable m_spinlock; + static constexpr LockRank const m_rank { Rank }; }; } diff --git a/Kernel/Memory/AnonymousVMObject.h b/Kernel/Memory/AnonymousVMObject.h index d880dd8b87..6bee370e4c 100644 --- a/Kernel/Memory/AnonymousVMObject.h +++ b/Kernel/Memory/AnonymousVMObject.h @@ -78,7 +78,7 @@ private: void uncommit_one(); private: - Spinlock m_lock { LockRank::None }; + Spinlock m_lock {}; CommittedPhysicalPageSet m_committed_pages; }; diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index 5e80e9cbc1..a0d4af14c1 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -88,7 +88,6 @@ MemoryManager::GlobalData::GlobalData() } UNMAP_AFTER_INIT MemoryManager::MemoryManager() - : m_global_data(LockRank::None) { s_the = this; diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h index 484a645acc..e4b0b57954 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 { LockRank::None }; + Spinlock m_quickmap_in_use {}; InterruptsState m_quickmap_previous_interrupts_state; }; @@ -304,7 +304,7 @@ private: Vector reserved_memory_ranges; }; - SpinlockProtected m_global_data; + SpinlockProtected m_global_data; }; inline bool is_user_address(VirtualAddress vaddr) diff --git a/Kernel/Memory/PageDirectory.h b/Kernel/Memory/PageDirectory.h index e5e3f8d043..5ae014464c 100644 --- a/Kernel/Memory/PageDirectory.h +++ b/Kernel/Memory/PageDirectory.h @@ -52,7 +52,7 @@ public: void set_space(Badge, AddressSpace& space) { m_space = &space; } - RecursiveSpinlock& get_lock() { return m_lock; } + RecursiveSpinlock& get_lock() { return m_lock; } // This has to be public to let the global singleton access the member pointer IntrusiveRedBlackTreeNode> m_tree_node; @@ -72,7 +72,7 @@ private: #else RefPtr m_directory_pages[4]; #endif - RecursiveSpinlock m_lock { LockRank::None }; + RecursiveSpinlock m_lock {}; }; void activate_kernel_page_directory(PageDirectory const& pgd); diff --git a/Kernel/Memory/Region.cpp b/Kernel/Memory/Region.cpp index 4dd3e6c102..2c4d0f7ed2 100644 --- a/Kernel/Memory/Region.cpp +++ b/Kernel/Memory/Region.cpp @@ -270,7 +270,7 @@ void Region::unmap(ShouldFlushTLB should_flush_tlb) unmap_with_locks_held(should_flush_tlb, pd_locker); } -void Region::unmap_with_locks_held(ShouldFlushTLB should_flush_tlb, SpinlockLocker&) +void Region::unmap_with_locks_held(ShouldFlushTLB should_flush_tlb, SpinlockLocker>&) { if (!m_page_directory) return; diff --git a/Kernel/Memory/Region.h b/Kernel/Memory/Region.h index bc435e3841..3955c01bca 100644 --- a/Kernel/Memory/Region.h +++ b/Kernel/Memory/Region.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -192,7 +193,7 @@ public: void set_page_directory(PageDirectory&); ErrorOr map(PageDirectory&, ShouldFlushTLB = ShouldFlushTLB::Yes); void unmap(ShouldFlushTLB = ShouldFlushTLB::Yes); - void unmap_with_locks_held(ShouldFlushTLB, SpinlockLocker& pd_locker); + void unmap_with_locks_held(ShouldFlushTLB, SpinlockLocker>& pd_locker); void remap(); diff --git a/Kernel/Memory/RingBuffer.h b/Kernel/Memory/RingBuffer.h index 2ea0811e3a..74ff355b29 100644 --- a/Kernel/Memory/RingBuffer.h +++ b/Kernel/Memory/RingBuffer.h @@ -22,7 +22,7 @@ public: void reclaim_space(PhysicalAddress chunk_start, size_t chunk_size); PhysicalAddress start_of_used() const; - Spinlock& lock() { return m_lock; } + Spinlock& lock() { return m_lock; } size_t used_bytes() const { return m_num_used_bytes; } PhysicalAddress start_of_region() const { return m_region->physical_page(0)->paddr(); } VirtualAddress vaddr() const { return m_region->vaddr(); } @@ -32,7 +32,7 @@ private: RingBuffer(NonnullOwnPtr region, size_t capacity); NonnullOwnPtr m_region; - Spinlock m_lock { LockRank::None }; + Spinlock m_lock {}; 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 2c95d4eb6d..a43144c19a 100644 --- a/Kernel/Memory/SharedFramebufferVMObject.h +++ b/Kernel/Memory/SharedFramebufferVMObject.h @@ -87,7 +87,7 @@ private: LockRefPtr m_fake_writes_framebuffer_vmobject; LockRefPtr m_real_writes_framebuffer_vmobject; bool m_writes_are_faked { false }; - mutable RecursiveSpinlock m_writes_state_lock { LockRank::None }; + mutable RecursiveSpinlock m_writes_state_lock {}; CommittedPhysicalPageSet m_committed_pages; }; diff --git a/Kernel/Memory/VMObject.cpp b/Kernel/Memory/VMObject.cpp index d6d09c888b..3d241a6606 100644 --- a/Kernel/Memory/VMObject.cpp +++ b/Kernel/Memory/VMObject.cpp @@ -10,9 +10,9 @@ namespace Kernel::Memory { -static Singleton> s_all_instances; +static Singleton> s_all_instances; -SpinlockProtected& VMObject::all_instances() +SpinlockProtected& VMObject::all_instances() { return s_all_instances; } diff --git a/Kernel/Memory/VMObject.h b/Kernel/Memory/VMObject.h index d6cc4ecce4..8dcdf7e098 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 { LockRank::None }; + mutable RecursiveSpinlock m_lock {}; private: VMObject& operator=(VMObject const&) = delete; @@ -76,7 +76,7 @@ private: public: using AllInstancesList = IntrusiveList<&VMObject::m_list_node>; - static SpinlockProtected& all_instances(); + static SpinlockProtected& all_instances(); }; template diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h index 0b0ac82a63..6e8bdd1782 100644 --- a/Kernel/Net/NetworkAdapter.h +++ b/Kernel/Net/NetworkAdapter.h @@ -111,7 +111,7 @@ private: PacketList m_packet_queue; size_t m_packet_queue_size { 0 }; - SpinlockProtected m_unused_packets { LockRank::None }; + SpinlockProtected m_unused_packets {}; NonnullOwnPtr m_name; u32 m_packets_in { 0 }; u32 m_bytes_in { 0 }; diff --git a/Kernel/Net/NetworkingManagement.h b/Kernel/Net/NetworkingManagement.h index 8b8955e919..ab4f3bc25f 100644 --- a/Kernel/Net/NetworkingManagement.h +++ b/Kernel/Net/NetworkingManagement.h @@ -42,7 +42,7 @@ public: private: ErrorOr> determine_network_device(PCI::DeviceIdentifier const&) const; - SpinlockProtected> m_adapters { LockRank::None }; + SpinlockProtected, LockRank::None> m_adapters {}; LockRefPtr m_loopback_adapter; }; diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp index 5711cd1359..81ca0b000c 100644 --- a/Kernel/Net/Routing.cpp +++ b/Kernel/Net/Routing.cpp @@ -16,8 +16,8 @@ namespace Kernel { -static Singleton>> s_arp_table; -static Singleton> s_routing_table; +static Singleton, LockRank::None>> s_arp_table; +static Singleton> s_routing_table; class ARPTableBlocker final : public Thread::Blocker { public: @@ -106,7 +106,7 @@ void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediate } } -SpinlockProtected>& arp_table() +SpinlockProtected, LockRank::None>& arp_table() { return *s_arp_table; } @@ -130,7 +130,7 @@ void update_arp_table(IPv4Address const& ip_addr, MACAddress const& addr, Update } } -SpinlockProtected& routing_table() +SpinlockProtected& routing_table() { return *s_routing_table; } diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h index b1cd26b4d6..8732184901 100644 --- a/Kernel/Net/Routing.h +++ b/Kernel/Net/Routing.h @@ -66,7 +66,7 @@ enum class AllowUsingGateway { RoutingDecision route_to(IPv4Address const& target, IPv4Address const& source, LockRefPtr const through = nullptr, AllowUsingGateway = AllowUsingGateway::Yes); -SpinlockProtected>& arp_table(); -SpinlockProtected& routing_table(); +SpinlockProtected, LockRank::None>& arp_table(); +SpinlockProtected& routing_table(); } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 51bb92217d..d2fbf3f3f3 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -46,9 +46,9 @@ static void create_signal_trampoline(); extern ProcessID g_init_pid; -RecursiveSpinlock g_profiling_lock { LockRank::None }; +RecursiveSpinlock g_profiling_lock {}; static Atomic next_pid; -static Singleton> s_all_instances; +static Singleton> s_all_instances; READONLY_AFTER_INIT Memory::Region* g_signal_trampoline_region; static Singleton>> s_hostname; @@ -58,7 +58,7 @@ MutexProtected>& hostname() return *s_hostname; } -SpinlockProtected& Process::all_instances() +SpinlockProtected& Process::all_instances() { return *s_all_instances; } @@ -319,14 +319,12 @@ ErrorOr> Process::try_create(LockRefPtr& firs Process::Process(NonnullOwnPtr name, NonnullRefPtr credentials, ProcessID ppid, bool is_kernel_process, RefPtr current_directory, RefPtr executable, TTY* tty, UnveilNode unveil_tree, UnveilNode exec_unveil_tree) : m_name(move(name)) - , m_space(LockRank::None) - , m_protected_data_lock(LockRank::None) , m_is_kernel_process(is_kernel_process) - , m_executable(LockRank::None, move(executable)) - , m_current_directory(LockRank::None, move(current_directory)) + , m_executable(move(executable)) + , m_current_directory(move(current_directory)) , m_tty(tty) - , m_unveil_data(LockRank::None, move(unveil_tree)) - , m_exec_unveil_data(LockRank::None, move(exec_unveil_tree)) + , m_unveil_data(move(unveil_tree)) + , m_exec_unveil_data(move(exec_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 c897d4f962..c7613f3e1c 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -238,7 +238,7 @@ public: return with_protected_data([](auto& protected_data) { return protected_data.ppid; }); } - SpinlockProtected>& jail() { return m_attached_jail; } + SpinlockProtected, LockRank::Process>& jail() { return m_attached_jail; } NonnullRefPtr credentials() const; @@ -568,8 +568,8 @@ public: PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; } PerformanceEventBuffer const* perf_events() const { return m_perf_event_buffer; } - SpinlockProtected>& address_space() { return m_space; } - SpinlockProtected> const& address_space() const { return m_space; } + SpinlockProtected, LockRank::None>& address_space() { return m_space; } + SpinlockProtected, LockRank::None> const& address_space() const { return m_space; } VirtualAddress signal_trampoline() const { @@ -666,11 +666,11 @@ private: NonnullOwnPtr m_name; - SpinlockProtected> m_space; + SpinlockProtected, LockRank::None> m_space; LockRefPtr m_pg; - RecursiveSpinlock mutable m_protected_data_lock; + RecursiveSpinlock mutable m_protected_data_lock; AtomicEdgeAction m_protected_data_refs; void protect_data(); void unprotect_data(); @@ -849,12 +849,12 @@ public: private: ErrorOr> custody_for_dirfd(int dirfd); - SpinlockProtected& thread_list() { return m_thread_list; } - SpinlockProtected const& thread_list() const { return m_thread_list; } + SpinlockProtected& thread_list() { return m_thread_list; } + SpinlockProtected const& thread_list() const { return m_thread_list; } ErrorOr> get_thread_from_pid_or_tid(pid_t pid_or_tid, Syscall::SchedulerParametersMode mode); - SpinlockProtected m_thread_list { LockRank::None }; + SpinlockProtected m_thread_list {}; MutexProtected m_fds; @@ -864,9 +864,9 @@ private: Atomic m_is_stopped { false }; bool m_should_generate_coredump { false }; - SpinlockProtected> m_executable; + SpinlockProtected, LockRank::None> m_executable; - SpinlockProtected> m_current_directory; + SpinlockProtected, LockRank::None> m_current_directory; NonnullOwnPtrVector m_arguments; NonnullOwnPtrVector m_environment; @@ -876,7 +876,7 @@ private: LockWeakPtr m_master_tls_region; IntrusiveListNode m_jail_list_node; - SpinlockProtected> m_attached_jail { LockRank::Process }; + SpinlockProtected, LockRank::Process> m_attached_jail {}; size_t m_master_tls_size { 0 }; size_t m_master_tls_alignment { 0 }; @@ -886,8 +886,8 @@ private: LockRefPtr m_alarm_timer; - SpinlockProtected m_unveil_data; - SpinlockProtected m_exec_unveil_data; + SpinlockProtected m_unveil_data; + SpinlockProtected m_exec_unveil_data; OwnPtr m_perf_event_buffer; @@ -903,7 +903,7 @@ private: OwnPtr value; }; - SpinlockProtected> m_coredump_properties { LockRank::None }; + SpinlockProtected, LockRank::None> m_coredump_properties {}; NonnullLockRefPtrVector m_threads_for_coredump; mutable LockRefPtr m_procfs_traits; @@ -920,7 +920,7 @@ private: public: using List = IntrusiveListRelaxedConst<&Process::m_list_node>; - static SpinlockProtected& all_instances(); + static SpinlockProtected& all_instances(); }; // Note: Process object should be 2 pages of 4096 bytes each. @@ -929,7 +929,7 @@ public: // The second page is being used exclusively for write-protected values. static_assert(AssertSize()); -extern RecursiveSpinlock g_profiling_lock; +extern RecursiveSpinlock g_profiling_lock; template Callback> inline IterationDecision Process::for_each_thread(Callback callback) diff --git a/Kernel/ProcessExposed.cpp b/Kernel/ProcessExposed.cpp index d9f9315f48..80b091e0a3 100644 --- a/Kernel/ProcessExposed.cpp +++ b/Kernel/ProcessExposed.cpp @@ -14,7 +14,7 @@ namespace Kernel { -static Spinlock s_index_lock { LockRank::None }; +static Spinlock s_index_lock {}; static InodeIndex s_next_inode_index = 0; namespace SegmentedProcFSIndex { diff --git a/Kernel/ProcessGroup.cpp b/Kernel/ProcessGroup.cpp index 7463ed41a6..f86b7c1473 100644 --- a/Kernel/ProcessGroup.cpp +++ b/Kernel/ProcessGroup.cpp @@ -10,9 +10,9 @@ namespace Kernel { -static Singleton> s_process_groups; +static Singleton> s_process_groups; -SpinlockProtected& process_groups() +SpinlockProtected& process_groups() { return *s_process_groups; } diff --git a/Kernel/ProcessGroup.h b/Kernel/ProcessGroup.h index 8ab9b55134..69a52d2cb3 100644 --- a/Kernel/ProcessGroup.h +++ b/Kernel/ProcessGroup.h @@ -44,6 +44,6 @@ public: using List = IntrusiveList<&ProcessGroup::m_list_node>; }; -SpinlockProtected& process_groups(); +SpinlockProtected& process_groups(); } diff --git a/Kernel/Random.h b/Kernel/Random.h index b5cb9f087d..2ae6bd91f1 100644 --- a/Kernel/Random.h +++ b/Kernel/Random.h @@ -82,7 +82,7 @@ public: return is_seeded() || m_p0_len >= reseed_threshold; } - Spinlock& get_lock() { return m_lock; } + Spinlock& get_lock() { return m_lock; } private: void reseed() @@ -117,7 +117,7 @@ private: size_t m_p0_len { 0 }; ByteBuffer m_key; HashType m_pools[pool_count]; - Spinlock m_lock { LockRank::None }; + Spinlock m_lock {}; }; class KernelRng : public FortunaPRNG { diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 817e02288b..15c3d110f0 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -21,7 +21,7 @@ namespace Kernel { -RecursiveSpinlock g_scheduler_lock { LockRank::None }; +RecursiveSpinlock g_scheduler_lock {}; static u32 time_slice_for(Thread const& thread) { @@ -46,9 +46,9 @@ struct ThreadReadyQueues { Array queues; }; -static Singleton> g_ready_queues; +static Singleton> g_ready_queues; -static SpinlockProtected g_total_time_scheduled { LockRank::None }; +static SpinlockProtected g_total_time_scheduled {}; static void dump_thread_list(bool = false); diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index ef15c3eb85..ae7b6a5783 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -22,7 +22,7 @@ struct RegisterState; extern Thread* g_finalizer; extern WaitQueue* g_finalizer_wait_queue; extern Atomic g_finalizer_has_work; -extern RecursiveSpinlock g_scheduler_lock; +extern RecursiveSpinlock g_scheduler_lock; struct TotalTimeScheduled { u64 total { 0 }; diff --git a/Kernel/Storage/ATA/AHCI/Controller.h b/Kernel/Storage/ATA/AHCI/Controller.h index aacd58d181..b4916b197d 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 { LockRank::None }; + mutable Spinlock m_hba_control_lock {}; }; } diff --git a/Kernel/Storage/ATA/AHCI/Port.h b/Kernel/Storage/ATA/AHCI/Port.h index 5c3f91df39..21df462b6a 100644 --- a/Kernel/Storage/ATA/AHCI/Port.h +++ b/Kernel/Storage/ATA/AHCI/Port.h @@ -107,7 +107,7 @@ private: EntropySource m_entropy_source; LockRefPtr m_current_request; - Spinlock m_hard_lock { LockRank::None }; + Spinlock m_hard_lock {}; 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 0b576f403d..bb876cad7f 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 { LockRank::None }; + Spinlock m_hard_lock {}; EntropySource m_entropy_source; diff --git a/Kernel/Storage/NVMe/NVMeQueue.h b/Kernel/Storage/NVMe/NVMeQueue.h index e58a06765e..2c1afddf53 100644 --- a/Kernel/Storage/NVMe/NVMeQueue.h +++ b/Kernel/Storage/NVMe/NVMeQueue.h @@ -56,10 +56,10 @@ private: } protected: - Spinlock m_cq_lock { LockRank::Interrupts }; + Spinlock m_cq_lock {}; LockRefPtr m_current_request; NonnullOwnPtr m_rw_dma_region; - Spinlock m_request_lock { LockRank::None }; + Spinlock m_request_lock {}; private: u16 m_qid {}; @@ -69,7 +69,7 @@ private: u16 m_cq_head {}; bool m_admin_queue { false }; u32 m_qdepth {}; - Spinlock m_sq_lock { LockRank::Interrupts }; + Spinlock m_sq_lock {}; OwnPtr m_cq_dma_region; NonnullRefPtrVector m_cq_dma_page; Span m_sqe_array; diff --git a/Kernel/Syscalls/futex.cpp b/Kernel/Syscalls/futex.cpp index 6b12bd584a..b88ed5deaa 100644 --- a/Kernel/Syscalls/futex.cpp +++ b/Kernel/Syscalls/futex.cpp @@ -13,7 +13,7 @@ namespace Kernel { -static Singleton>>> s_global_futex_queues; +static Singleton>, LockRank::None>> s_global_futex_queues; void Process::clear_futex_queues_on_exec() { diff --git a/Kernel/TTY/ConsoleManagement.h b/Kernel/TTY/ConsoleManagement.h index ed890d85a9..675c931228 100644 --- a/Kernel/TTY/ConsoleManagement.h +++ b/Kernel/TTY/ConsoleManagement.h @@ -34,13 +34,13 @@ public: NonnullLockRefPtr first_tty() const { return m_consoles[0]; } NonnullLockRefPtr debug_tty() const { return m_consoles[1]; } - RecursiveSpinlock& tty_write_lock() { return m_tty_write_lock; } + RecursiveSpinlock& tty_write_lock() { return m_tty_write_lock; } private: NonnullLockRefPtrVector m_consoles; VirtualConsole* m_active_console { nullptr }; - Spinlock m_lock { LockRank::None }; - RecursiveSpinlock m_tty_write_lock { LockRank::None }; + Spinlock m_lock {}; + RecursiveSpinlock m_tty_write_lock {}; }; }; diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index 18c21e1000..c9da6ddbe0 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 { LockRank::None }; + SpinlockProtected, LockRank::None> m_freelist {}; }; } diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index c3865dbb05..e2b0921d51 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -12,9 +12,9 @@ namespace Kernel { -static Singleton> s_all_instances; +static Singleton> s_all_instances; -SpinlockProtected& SlavePTY::all_instances() +SpinlockProtected& SlavePTY::all_instances() { return s_all_instances; } diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index c576e0a72a..585c2f11a2 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -52,7 +52,7 @@ private: public: using List = IntrusiveList<&SlavePTY::m_list_node>; - static SpinlockProtected& all_instances(); + static SpinlockProtected& all_instances(); }; } diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index a9f2b79481..f7fcf51fbd 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -33,9 +33,9 @@ namespace Kernel { -static Singleton> s_list; +static Singleton> s_list; -SpinlockProtected& Thread::all_instances() +SpinlockProtected& Thread::all_instances() { return *s_list; } @@ -215,7 +215,7 @@ Thread::BlockResult Thread::block_impl(BlockTimeout const& timeout, Blocker& blo return result; } -void Thread::block(Kernel::Mutex& lock, SpinlockLocker& lock_lock, u32 lock_count) +void Thread::block(Kernel::Mutex& lock, SpinlockLocker>& lock_lock, u32 lock_count) { VERIFY(!Processor::current_in_irq()); VERIFY(this == Thread::current()); diff --git a/Kernel/Thread.h b/Kernel/Thread.h index ab4f59fa0c..6652094cd0 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -298,7 +298,7 @@ public: void set_blocker_set_raw_locked(BlockerSet* blocker_set) { m_blocker_set = blocker_set; } // FIXME: Figure out whether this can be Thread. - mutable RecursiveSpinlock m_lock { LockRank::None }; + mutable RecursiveSpinlock m_lock {}; private: BlockerSet* m_blocker_set { nullptr }; @@ -417,7 +417,7 @@ public: } // FIXME: Check whether this can be Thread. - mutable Spinlock m_lock { LockRank::None }; + mutable Spinlock m_lock {}; private: Vector m_blockers; @@ -812,7 +812,7 @@ public: } } - void block(Kernel::Mutex&, SpinlockLocker&, u32); + void block(Kernel::Mutex&, SpinlockLocker>&, u32); template BlockResult block(BlockTimeout const& timeout, Args&&... args) @@ -1003,7 +1003,7 @@ public: TrapFrame*& current_trap() { return m_current_trap; } TrapFrame const* const& current_trap() const { return m_current_trap; } - RecursiveSpinlock& get_lock() const { return m_lock; } + RecursiveSpinlock& get_lock() const { return m_lock; } #if LOCK_DEBUG void holding_lock(Mutex& lock, int refs_delta, LockLocation const& location) @@ -1164,8 +1164,8 @@ private: void relock_process(LockMode, u32); void reset_fpu_state(); - mutable RecursiveSpinlock m_lock { LockRank::Thread }; - mutable RecursiveSpinlock m_block_lock { LockRank::None }; + mutable RecursiveSpinlock m_lock {}; + mutable RecursiveSpinlock m_block_lock {}; NonnullLockRefPtr m_process; ThreadID m_tid { -1 }; ThreadRegisters m_regs {}; @@ -1199,7 +1199,7 @@ private: Kernel::Mutex* m_blocking_mutex { nullptr }; u32 m_lock_requested_count { 0 }; IntrusiveListNode m_blocked_threads_list_node; - LockRank m_lock_rank_mask { LockRank::None }; + LockRank m_lock_rank_mask {}; bool m_allocation_enabled { true }; // FIXME: remove this after annihilating Process::m_big_lock @@ -1207,7 +1207,7 @@ private: #if LOCK_DEBUG Atomic m_holding_locks { 0 }; - Spinlock m_holding_locks_lock { LockRank::None }; + Spinlock m_holding_locks_lock {}; Vector m_holding_locks_list; #endif @@ -1267,7 +1267,7 @@ public: using ListInProcess = IntrusiveList<&Thread::m_process_thread_list_node>; using GlobalList = IntrusiveList<&Thread::m_global_thread_list_node>; - static SpinlockProtected& all_instances(); + static SpinlockProtected& all_instances(); }; AK_ENUM_BITWISE_OPERATORS(Thread::FileBlocker::BlockFlags); diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp index 9b788331ef..157af5c6d0 100644 --- a/Kernel/TimerQueue.cpp +++ b/Kernel/TimerQueue.cpp @@ -14,7 +14,7 @@ namespace Kernel { static Singleton s_the; -static Spinlock g_timerqueue_lock { LockRank::None }; +static Spinlock g_timerqueue_lock {}; Time Timer::remaining() const { diff --git a/Kernel/WorkQueue.h b/Kernel/WorkQueue.h index 932d434ff6..ab35824666 100644 --- a/Kernel/WorkQueue.h +++ b/Kernel/WorkQueue.h @@ -63,7 +63,7 @@ private: LockRefPtr m_thread; WaitQueue m_wait_queue; - SpinlockProtected> m_items { LockRank::None }; + SpinlockProtected, LockRank::None> m_items {}; }; } diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp index ce21cd6952..6fe2d22a1f 100644 --- a/Kernel/kprintf.cpp +++ b/Kernel/kprintf.cpp @@ -29,7 +29,7 @@ extern Atomic g_boot_console; static bool s_serial_debug_enabled; // 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 { LockRank::None }; +static RecursiveSpinlock s_log_lock {}; void set_serial_debug_enabled(bool desired_state) {