1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

Kernel: Rename ScopedSpinlock => SpinlockLocker

This matches MutexLocker, and doesn't sound like it's a lock itself.
This commit is contained in:
Andreas Kling 2021-08-22 01:49:22 +02:00
parent 55adace359
commit c922a7da09
78 changed files with 365 additions and 366 deletions

View file

@ -223,7 +223,7 @@ void AddressSpace::deallocate_region(Region& region)
NonnullOwnPtr<Region> AddressSpace::take_region(Region& region)
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
if (m_region_lookup_cache.region.unsafe_ptr() == &region)
m_region_lookup_cache.region = nullptr;
@ -235,7 +235,7 @@ NonnullOwnPtr<Region> AddressSpace::take_region(Region& region)
Region* AddressSpace::find_region_from_range(VirtualRange const& range)
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
if (m_region_lookup_cache.range.has_value() && m_region_lookup_cache.range.value() == range && m_region_lookup_cache.region)
return m_region_lookup_cache.region.unsafe_ptr();
@ -253,7 +253,7 @@ Region* AddressSpace::find_region_from_range(VirtualRange const& range)
Region* AddressSpace::find_region_containing(VirtualRange const& range)
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
auto candidate = m_regions.find_largest_not_above(range.base().get());
if (!candidate)
return nullptr;
@ -265,7 +265,7 @@ Vector<Region*> AddressSpace::find_regions_intersecting(VirtualRange const& rang
Vector<Region*> regions = {};
size_t total_size_collected = 0;
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
auto found_region = m_regions.find_largest_not_above(range.base().get());
if (!found_region)
@ -286,7 +286,7 @@ Vector<Region*> AddressSpace::find_regions_intersecting(VirtualRange const& rang
Region* AddressSpace::add_region(NonnullOwnPtr<Region> region)
{
auto* ptr = region.ptr();
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
auto success = m_regions.try_insert(region->vaddr().get(), move(region));
return success ? ptr : nullptr;
}
@ -324,7 +324,7 @@ void AddressSpace::dump_regions()
dbgln("BEGIN{} END{} SIZE{} ACCESS NAME",
addr_padding, addr_padding, addr_padding);
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
for (auto& sorted_region : m_regions) {
auto& region = *sorted_region;
@ -342,13 +342,13 @@ void AddressSpace::dump_regions()
void AddressSpace::remove_all_regions(Badge<Process>)
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
m_regions.clear();
}
size_t AddressSpace::amount_dirty_private() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
// FIXME: This gets a bit more complicated for Regions sharing the same underlying VMObject.
// The main issue I'm thinking of is when the VMObject has physical pages that none of the Regions are mapping.
// That's probably a situation that needs to be looked at in general.
@ -362,7 +362,7 @@ size_t AddressSpace::amount_dirty_private() const
size_t AddressSpace::amount_clean_inode() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
HashTable<const InodeVMObject*> vmobjects;
for (auto& region : m_regions) {
if (region->vmobject().is_inode())
@ -376,7 +376,7 @@ size_t AddressSpace::amount_clean_inode() const
size_t AddressSpace::amount_virtual() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
size_t amount = 0;
for (auto& region : m_regions) {
amount += region->size();
@ -386,7 +386,7 @@ size_t AddressSpace::amount_virtual() const
size_t AddressSpace::amount_resident() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
// FIXME: This will double count if multiple regions use the same physical page.
size_t amount = 0;
for (auto& region : m_regions) {
@ -397,7 +397,7 @@ size_t AddressSpace::amount_resident() const
size_t AddressSpace::amount_shared() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
// FIXME: This will double count if multiple regions use the same physical page.
// FIXME: It doesn't work at the moment, since it relies on PhysicalPage ref counts,
// and each PhysicalPage is only reffed by its VMObject. This needs to be refactored
@ -411,7 +411,7 @@ size_t AddressSpace::amount_shared() const
size_t AddressSpace::amount_purgeable_volatile() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
size_t amount = 0;
for (auto& region : m_regions) {
if (!region->vmobject().is_anonymous())
@ -425,7 +425,7 @@ size_t AddressSpace::amount_purgeable_volatile() const
size_t AddressSpace::amount_purgeable_nonvolatile() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
size_t amount = 0;
for (auto& region : m_regions) {
if (!region->vmobject().is_anonymous())

View file

@ -16,7 +16,7 @@ namespace Kernel::Memory {
KResultOr<NonnullRefPtr<VMObject>> AnonymousVMObject::try_clone()
{
// We need to acquire our lock so we copy a sane state
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
if (is_purgeable() && is_volatile()) {
// If this object is purgeable+volatile, create a new zero-filled purgeable+volatile
@ -178,7 +178,7 @@ AnonymousVMObject::~AnonymousVMObject()
size_t AnonymousVMObject::purge()
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
if (!is_purgeable() || !is_volatile())
return 0;
@ -206,7 +206,7 @@ KResult AnonymousVMObject::set_volatile(bool is_volatile, bool& was_purged)
{
VERIFY(is_purgeable());
ScopedSpinlock locker(m_lock);
SpinlockLocker locker(m_lock);
was_purged = m_was_purged;
if (m_volatile == is_volatile)
@ -306,7 +306,7 @@ size_t AnonymousVMObject::cow_pages() const
PageFaultResponse AnonymousVMObject::handle_cow_fault(size_t page_index, VirtualAddress vaddr)
{
VERIFY_INTERRUPTS_DISABLED();
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
if (is_volatile()) {
// A COW fault in a volatile region? Userspace is writing to volatile memory, this is a bug. Crash.
@ -379,13 +379,13 @@ AnonymousVMObject::SharedCommittedCowPages::~SharedCommittedCowPages()
NonnullRefPtr<PhysicalPage> AnonymousVMObject::SharedCommittedCowPages::take_one()
{
ScopedSpinlock locker(m_lock);
SpinlockLocker locker(m_lock);
return m_committed_pages.take_one();
}
void AnonymousVMObject::SharedCommittedCowPages::uncommit_one()
{
ScopedSpinlock locker(m_lock);
SpinlockLocker locker(m_lock);
m_committed_pages.uncommit_one();
}

View file

@ -52,7 +52,7 @@ size_t InodeVMObject::amount_dirty() const
int InodeVMObject::release_all_clean_pages()
{
ScopedSpinlock locker(m_lock);
SpinlockLocker locker(m_lock);
int count = 0;
for (size_t i = 0; i < page_count(); ++i) {

View file

@ -63,7 +63,7 @@ UNMAP_AFTER_INIT MemoryManager::MemoryManager()
{
s_the = this;
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
parse_memory_map();
write_cr3(kernel_page_directory().cr3());
protect_kernel_image();
@ -88,7 +88,7 @@ UNMAP_AFTER_INIT MemoryManager::~MemoryManager()
UNMAP_AFTER_INIT void MemoryManager::protect_kernel_image()
{
ScopedSpinlock page_lock(kernel_page_directory().get_lock());
SpinlockLocker page_lock(kernel_page_directory().get_lock());
// Disable writing to the kernel text and rodata segments.
for (auto i = start_of_kernel_text; i < start_of_kernel_data; i += PAGE_SIZE) {
auto& pte = *ensure_pte(kernel_page_directory(), VirtualAddress(i));
@ -105,8 +105,8 @@ UNMAP_AFTER_INIT void MemoryManager::protect_kernel_image()
UNMAP_AFTER_INIT void MemoryManager::protect_readonly_after_init_memory()
{
ScopedSpinlock page_lock(kernel_page_directory().get_lock());
ScopedSpinlock mm_lock(s_mm_lock);
SpinlockLocker page_lock(kernel_page_directory().get_lock());
SpinlockLocker mm_lock(s_mm_lock);
// Disable writing to the .ro_after_init section
for (auto i = (FlatPtr)&start_of_ro_after_init; i < (FlatPtr)&end_of_ro_after_init; i += PAGE_SIZE) {
auto& pte = *ensure_pte(kernel_page_directory(), VirtualAddress(i));
@ -117,8 +117,8 @@ UNMAP_AFTER_INIT void MemoryManager::protect_readonly_after_init_memory()
void MemoryManager::unmap_text_after_init()
{
ScopedSpinlock page_lock(kernel_page_directory().get_lock());
ScopedSpinlock mm_lock(s_mm_lock);
SpinlockLocker page_lock(kernel_page_directory().get_lock());
SpinlockLocker mm_lock(s_mm_lock);
auto start = page_round_down((FlatPtr)&start_of_unmap_after_init);
auto end = page_round_up((FlatPtr)&end_of_unmap_after_init);
@ -135,8 +135,8 @@ void MemoryManager::unmap_text_after_init()
void MemoryManager::unmap_ksyms_after_init()
{
ScopedSpinlock mm_lock(s_mm_lock);
ScopedSpinlock page_lock(kernel_page_directory().get_lock());
SpinlockLocker mm_lock(s_mm_lock);
SpinlockLocker page_lock(kernel_page_directory().get_lock());
auto start = page_round_down((FlatPtr)start_of_kernel_ksyms);
auto end = page_round_up((FlatPtr)end_of_kernel_ksyms);
@ -413,7 +413,7 @@ UNMAP_AFTER_INIT void MemoryManager::initialize_physical_pages()
// try to map the entire region into kernel space so we always have it
// We can't use ensure_pte here because it would try to allocate a PhysicalPage and we don't have the array
// mapped yet so we can't create them
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
// Create page tables at the beginning of m_physical_pages_region, followed by the PhysicalPageEntry array
auto page_tables_base = m_physical_pages_region->lower();
@ -612,7 +612,7 @@ UNMAP_AFTER_INIT void MemoryManager::initialize(u32 cpu)
Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
for (auto& region : MM.m_kernel_regions) {
if (region.contains(vaddr))
return &region;
@ -628,7 +628,7 @@ Region* MemoryManager::find_user_region_from_vaddr_no_lock(AddressSpace& space,
Region* MemoryManager::find_user_region_from_vaddr(AddressSpace& space, VirtualAddress vaddr)
{
ScopedSpinlock lock(space.get_lock());
SpinlockLocker lock(space.get_lock());
return find_user_region_from_vaddr_no_lock(space, vaddr);
}
@ -636,7 +636,7 @@ void MemoryManager::validate_syscall_preconditions(AddressSpace& space, Register
{
// We take the space lock once here and then use the no_lock variants
// to avoid excessive spinlock recursion in this extemely common path.
ScopedSpinlock lock(space.get_lock());
SpinlockLocker lock(space.get_lock());
auto unlock_and_handle_crash = [&lock, &regs](const char* description, int signal) {
lock.unlock();
@ -702,7 +702,7 @@ PageFaultResponse MemoryManager::handle_page_fault(PageFault const& fault)
OwnPtr<Region> MemoryManager::allocate_contiguous_kernel_region(size_t size, StringView name, Region::Access access, Region::Cacheable cacheable)
{
VERIFY(!(size % PAGE_SIZE));
ScopedSpinlock lock(kernel_page_directory().get_lock());
SpinlockLocker lock(kernel_page_directory().get_lock());
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.has_value())
return {};
@ -721,7 +721,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, StringView nam
auto maybe_vm_object = AnonymousVMObject::try_create_with_size(size, strategy);
if (maybe_vm_object.is_error())
return {};
ScopedSpinlock lock(kernel_page_directory().get_lock());
SpinlockLocker lock(kernel_page_directory().get_lock());
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.has_value())
return {};
@ -734,7 +734,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(PhysicalAddress paddr, size
if (maybe_vm_object.is_error())
return {};
VERIFY(!(size % PAGE_SIZE));
ScopedSpinlock lock(kernel_page_directory().get_lock());
SpinlockLocker lock(kernel_page_directory().get_lock());
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.has_value())
return {};
@ -755,7 +755,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region_with_vmobject(VirtualRange
OwnPtr<Region> MemoryManager::allocate_kernel_region_with_vmobject(VMObject& vmobject, size_t size, StringView name, Region::Access access, Region::Cacheable cacheable)
{
VERIFY(!(size % PAGE_SIZE));
ScopedSpinlock lock(kernel_page_directory().get_lock());
SpinlockLocker lock(kernel_page_directory().get_lock());
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
if (!range.has_value())
return {};
@ -765,7 +765,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region_with_vmobject(VMObject& vmo
Optional<CommittedPhysicalPageSet> MemoryManager::commit_user_physical_pages(size_t page_count)
{
VERIFY(page_count > 0);
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
if (m_system_memory_info.user_physical_pages_uncommitted < page_count)
return {};
@ -778,7 +778,7 @@ void MemoryManager::uncommit_user_physical_pages(Badge<CommittedPhysicalPageSet>
{
VERIFY(page_count > 0);
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
VERIFY(m_system_memory_info.user_physical_pages_committed >= page_count);
m_system_memory_info.user_physical_pages_uncommitted += page_count;
@ -787,7 +787,7 @@ void MemoryManager::uncommit_user_physical_pages(Badge<CommittedPhysicalPageSet>
void MemoryManager::deallocate_physical_page(PhysicalAddress paddr)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
// Are we returning a user page?
for (auto& region : m_user_physical_regions) {
@ -839,7 +839,7 @@ RefPtr<PhysicalPage> MemoryManager::find_free_user_physical_page(bool committed)
NonnullRefPtr<PhysicalPage> MemoryManager::allocate_committed_user_physical_page(Badge<CommittedPhysicalPageSet>, ShouldZeroFill should_zero_fill)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
auto page = find_free_user_physical_page(true);
if (should_zero_fill == ShouldZeroFill::Yes) {
auto* ptr = quickmap_page(*page);
@ -851,7 +851,7 @@ NonnullRefPtr<PhysicalPage> MemoryManager::allocate_committed_user_physical_page
RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill, bool* did_purge)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
auto page = find_free_user_physical_page(false);
bool purged_pages = false;
@ -893,7 +893,7 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s
NonnullRefPtrVector<PhysicalPage> MemoryManager::allocate_contiguous_supervisor_physical_pages(size_t size)
{
VERIFY(!(size % PAGE_SIZE));
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
size_t count = ceil_div(size, static_cast<size_t>(PAGE_SIZE));
auto physical_pages = m_super_physical_region->take_contiguous_free_pages(count);
@ -911,7 +911,7 @@ NonnullRefPtrVector<PhysicalPage> MemoryManager::allocate_contiguous_supervisor_
RefPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
auto page = m_super_physical_region->take_free_page();
if (!page) {
@ -934,7 +934,7 @@ void MemoryManager::enter_space(AddressSpace& space)
{
auto current_thread = Thread::current();
VERIFY(current_thread != nullptr);
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
current_thread->regs().cr3 = space.page_directory().cr3();
write_cr3(space.page_directory().cr3());
@ -1006,7 +1006,7 @@ u8* MemoryManager::quickmap_page(PhysicalAddress const& physical_address)
VERIFY_INTERRUPTS_DISABLED();
auto& mm_data = get_data();
mm_data.m_quickmap_prev_flags = mm_data.m_quickmap_in_use.lock();
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
VirtualAddress vaddr(KERNEL_QUICKMAP_PER_CPU_BASE + Processor::id() * PAGE_SIZE);
u32 pte_idx = (vaddr.get() - KERNEL_PT1024_BASE) / PAGE_SIZE;
@ -1025,7 +1025,7 @@ u8* MemoryManager::quickmap_page(PhysicalAddress const& physical_address)
void MemoryManager::unquickmap_page()
{
VERIFY_INTERRUPTS_DISABLED();
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
auto& mm_data = get_data();
VERIFY(mm_data.m_quickmap_in_use.is_locked());
VirtualAddress vaddr(KERNEL_QUICKMAP_PER_CPU_BASE + Processor::id() * PAGE_SIZE);
@ -1049,20 +1049,20 @@ bool MemoryManager::validate_user_stack_no_lock(AddressSpace& space, VirtualAddr
bool MemoryManager::validate_user_stack(AddressSpace& space, VirtualAddress vaddr) const
{
ScopedSpinlock lock(space.get_lock());
SpinlockLocker lock(space.get_lock());
return validate_user_stack_no_lock(space, vaddr);
}
void MemoryManager::register_region(Region& region)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
if (region.is_kernel())
m_kernel_regions.append(region);
}
void MemoryManager::unregister_region(Region& region)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
if (region.is_kernel())
m_kernel_regions.remove(region);
}
@ -1077,7 +1077,7 @@ void MemoryManager::dump_kernel_regions()
#endif
dbgln("BEGIN{} END{} SIZE{} ACCESS NAME",
addr_padding, addr_padding, addr_padding);
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
for (auto& region : m_kernel_regions) {
dbgln("{:p} -- {:p} {:p} {:c}{:c}{:c}{:c}{:c}{:c} {}",
region.vaddr().get(),
@ -1095,8 +1095,8 @@ void MemoryManager::dump_kernel_regions()
void MemoryManager::set_page_writable_direct(VirtualAddress vaddr, bool writable)
{
ScopedSpinlock page_lock(kernel_page_directory().get_lock());
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker page_lock(kernel_page_directory().get_lock());
SpinlockLocker lock(s_mm_lock);
auto* pte = ensure_pte(kernel_page_directory(), vaddr);
VERIFY(pte);
if (pte->is_writable() == writable)

View file

@ -197,7 +197,7 @@ public:
SystemMemoryInfo get_system_memory_info()
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
return m_system_memory_info;
}

View file

@ -27,7 +27,7 @@ static HashMap<FlatPtr, PageDirectory*>& cr3_map()
RefPtr<PageDirectory> PageDirectory::find_by_cr3(FlatPtr cr3)
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
return cr3_map().get(cr3).value_or({});
}
@ -60,7 +60,7 @@ RefPtr<PageDirectory> PageDirectory::try_create_for_userspace(VirtualRangeAlloca
}
// NOTE: Take the MM lock since we need it for quickmap.
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
#if ARCH(X86_64)
directory->m_pml4t = MM.allocate_user_physical_page();
@ -159,7 +159,7 @@ UNMAP_AFTER_INIT void PageDirectory::allocate_kernel_directory()
PageDirectory::~PageDirectory()
{
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker lock(s_mm_lock);
if (m_space)
cr3_map().remove(cr3());
}

View file

@ -43,8 +43,8 @@ Region::~Region()
MM.unregister_region(*this);
if (m_page_directory) {
ScopedSpinlock page_lock(m_page_directory->get_lock());
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker page_lock(m_page_directory->get_lock());
SpinlockLocker lock(s_mm_lock);
unmap(ShouldDeallocateVirtualRange::Yes);
VERIFY(!m_page_directory);
}
@ -183,7 +183,7 @@ bool Region::map_individual_page_impl(size_t page_index)
}
// NOTE: We have to take the MM lock for PTE's to stay valid while we use them.
ScopedSpinlock mm_locker(s_mm_lock);
SpinlockLocker mm_locker(s_mm_lock);
auto* pte = MM.ensure_pte(*m_page_directory, page_vaddr);
if (!pte)
@ -208,12 +208,12 @@ bool Region::map_individual_page_impl(size_t page_index)
bool Region::do_remap_vmobject_page(size_t page_index, bool with_flush)
{
ScopedSpinlock lock(vmobject().m_lock);
SpinlockLocker lock(vmobject().m_lock);
if (!m_page_directory)
return true; // not an error, region may have not yet mapped it
if (!translate_vmobject_page(page_index))
return true; // not an error, region doesn't map this page
ScopedSpinlock page_lock(m_page_directory->get_lock());
SpinlockLocker page_lock(m_page_directory->get_lock());
VERIFY(physical_page(page_index));
bool success = map_individual_page_impl(page_index);
if (with_flush)
@ -236,8 +236,8 @@ void Region::unmap(ShouldDeallocateVirtualRange deallocate_range)
{
if (!m_page_directory)
return;
ScopedSpinlock page_lock(m_page_directory->get_lock());
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker page_lock(m_page_directory->get_lock());
SpinlockLocker lock(s_mm_lock);
size_t count = page_count();
for (size_t i = 0; i < count; ++i) {
auto vaddr = vaddr_from_page_index(i);
@ -259,8 +259,8 @@ void Region::set_page_directory(PageDirectory& page_directory)
bool Region::map(PageDirectory& page_directory, ShouldFlushTLB should_flush_tlb)
{
ScopedSpinlock page_lock(page_directory.get_lock());
ScopedSpinlock lock(s_mm_lock);
SpinlockLocker page_lock(page_directory.get_lock());
SpinlockLocker lock(s_mm_lock);
// FIXME: Find a better place for this sanity check(?)
if (is_user() && !is_shared()) {
@ -338,7 +338,7 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
auto& page_slot = physical_page_slot(page_index_in_region);
auto page_index_in_vmobject = translate_to_vmobject_page(page_index_in_region);
ScopedSpinlock locker(vmobject().m_lock);
SpinlockLocker locker(vmobject().m_lock);
if (!page_slot.is_null() && !page_slot->is_shared_zero_page() && !page_slot->is_lazy_committed_page()) {
dbgln_if(PAGE_FAULT_DEBUG, "MM: zero_page() but page already present. Fine with me!");
@ -401,7 +401,7 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
auto& vmobject_physical_page_entry = inode_vmobject.physical_pages()[page_index_in_vmobject];
{
ScopedSpinlock locker(inode_vmobject.m_lock);
SpinlockLocker locker(inode_vmobject.m_lock);
if (!vmobject_physical_page_entry.is_null()) {
dbgln_if(PAGE_FAULT_DEBUG, "handle_inode_fault: Page faulted in by someone else before reading, remapping.");
if (!remap_vmobject_page(page_index_in_vmobject))
@ -433,7 +433,7 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
memset(page_buffer + nread, 0, PAGE_SIZE - nread);
}
ScopedSpinlock locker(inode_vmobject.m_lock);
SpinlockLocker locker(inode_vmobject.m_lock);
if (!vmobject_physical_page_entry.is_null()) {
// Someone else faulted in this page while we were reading from the inode.

View file

@ -43,13 +43,13 @@ public:
ALWAYS_INLINE void add_region(Region& region)
{
ScopedSpinlock locker(m_lock);
SpinlockLocker locker(m_lock);
m_regions.append(region);
}
ALWAYS_INLINE void remove_region(Region& region)
{
ScopedSpinlock locker(m_lock);
SpinlockLocker locker(m_lock);
m_regions.remove(region);
}
@ -80,7 +80,7 @@ public:
template<typename Callback>
inline void VMObject::for_each_region(Callback callback)
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
for (auto& region : m_regions) {
callback(region);
}

View file

@ -25,7 +25,7 @@ void VirtualRangeAllocator::initialize_with_range(VirtualAddress base, size_t si
void VirtualRangeAllocator::initialize_from_parent(VirtualRangeAllocator const& parent_allocator)
{
ScopedSpinlock lock(parent_allocator.m_lock);
SpinlockLocker lock(parent_allocator.m_lock);
m_total_range = parent_allocator.m_total_range;
m_available_ranges.clear();
for (auto it = parent_allocator.m_available_ranges.begin(); !it.is_end(); ++it) {
@ -103,7 +103,7 @@ Optional<VirtualRange> VirtualRangeAllocator::allocate_anywhere(size_t size, siz
if (Checked<size_t>::addition_would_overflow(effective_size, alignment))
return {};
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
for (auto it = m_available_ranges.begin(); !it.is_end(); ++it) {
auto& available_range = *it;
@ -142,7 +142,7 @@ Optional<VirtualRange> VirtualRangeAllocator::allocate_specific(VirtualAddress b
return {};
}
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
for (auto it = m_available_ranges.begin(); !it.is_end(); ++it) {
auto& available_range = *it;
if (!available_range.contains(base, size))
@ -159,7 +159,7 @@ Optional<VirtualRange> VirtualRangeAllocator::allocate_specific(VirtualAddress b
void VirtualRangeAllocator::deallocate(VirtualRange const& range)
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
VERIFY(m_total_range.contains(range));
VERIFY(range.size());
VERIFY((range.size() % PAGE_SIZE) == 0);