Use lockdep instead of asserting spin_is_locked() for v4.21/v5.0
Subsystems (11)
PATCH 7/7 KVM: arm/arm64: vgic: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- virt/kvm/arm/vgic/vgic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
virt/kvm/arm/vgic/vgic.c +6 -6
@@ -196,7 +196,7 @@ void vgic_irq_set_phys_active(struct vgic_irq *irq, bool active)*/ static struct kvm_vcpu *vgic_target_oracle (struct vgic_irq *irq) { -DEBUG_SPINLOCK_BUG_ON (!spin_is_locked (&irq->irq_lock)); +lockdep_assert_held (&irq->irq_lock);/* If the interrupt is active, it must stay on the current vcpu */ if (irq->active)
@@ -273,7 +273,7 @@ static void vgic_sort_ap_list(struct kvm_vcpu *vcpu) {struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; -DEBUG_SPINLOCK_BUG_ON (!spin_is_locked (&vgic_cpu->ap_list_lock)); +lockdep_assert_held (&vgic_cpu->ap_list_lock);list_sort (NULL , &vgic_cpu->ap_list_head, vgic_irq_cmp); }
@@ -311,7 +311,7 @@ bool vgic_queue_irq_unlock(struct kvm *kvm, struct vgic_irq *irq, {struct kvm_vcpu *vcpu; -DEBUG_SPINLOCK_BUG_ON (!spin_is_locked (&irq->irq_lock)); +lockdep_assert_held (&irq->irq_lock); retry: vcpu =vgic_target_oracle (irq);
@@ -702,7 +702,7 @@ static inline void vgic_fold_lr_state(struct kvm_vcpu *vcpu)static inline void vgic_populate_lr (struct kvm_vcpu *vcpu,struct vgic_irq *irq,int lr) { -DEBUG_SPINLOCK_BUG_ON (!spin_is_locked (&irq->irq_lock)); +lockdep_assert_held (&irq->irq_lock);if (kvm_vgic_global_state.type ==VGIC_V2 )vgic_v2_populate_lr (vcpu, irq, lr);
@@ -736,7 +736,7 @@ static int compute_ap_list_depth(struct kvm_vcpu *vcpu, *multi_sgi = false; -DEBUG_SPINLOCK_BUG_ON (!spin_is_locked (&vgic_cpu->ap_list_lock)); +lockdep_assert_held (&vgic_cpu->ap_list_lock);list_for_each_entry (irq, &vgic_cpu->ap_list_head, ap_list) {int w;
@@ -761,7 +761,7 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu)bool multi_sgi;u8 prio =0xff ; -DEBUG_SPINLOCK_BUG_ON (!spin_is_locked (&vgic_cpu->ap_list_lock)); +lockdep_assert_held (&vgic_cpu->ap_list_lock); count =compute_ap_list_depth (vcpu, &multi_sgi);if (count > kvm_vgic_global_state.nr_lr || multi_sgi)
Signature · 1 line
2.17.1
PATCH 4/7 userfaultfd: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- fs/userfaultfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/userfaultfd.c +1 -1
@@ -926,7 +926,7 @@ static inline struct userfaultfd_wait_queue *find_userfault_in(wait_queue_entry_t *wq;struct userfaultfd_wait_queue *uwq; -VM_BUG_ON (!spin_is_locked (&wqh->lock)); +lockdep_assert_held (&wqh->lock); uwq =NULL ;if (!waitqueue_active (wqh))
Signature · 1 line
2.17.1
PATCH 6/7 mm: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- mm/khugepaged.c | 4 ++-- mm/swap.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
mm/khugepaged.c +2 -2
@@ -1225,7 +1225,7 @@ static void collect_mm_slot(struct mm_slot *mm_slot) {struct mm_struct *mm = mm_slot->mm; -VM_BUG_ON (NR_CPUS !=1 && !spin_is_locked (&khugepaged_mm_lock)); +lockdep_assert_held (&khugepaged_mm_lock);if (khugepaged_test_exit (mm)) {/* free mm_slot */
@@ -1631,7 +1631,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,int progress =0 ;VM_BUG_ON (!pages); -VM_BUG_ON (NR_CPUS !=1 && !spin_is_locked (&khugepaged_mm_lock)); +lockdep_assert_held (&khugepaged_mm_lock);if (khugepaged_scan.mm_slot) mm_slot = khugepaged_scan.mm_slot;
mm/swap.c +1 -2
@@ -823,8 +823,7 @@ void lru_add_page_tail(struct page *page, struct page *page_tail,VM_BUG_ON_PAGE (!PageHead (page), page);VM_BUG_ON_PAGE (PageCompound (page_tail), page);VM_BUG_ON_PAGE (PageLRU (page_tail), page); -VM_BUG_ON (NR_CPUS !=1 && - !spin_is_locked (&lruvec_pgdat (lruvec)->lru_lock)); +lockdep_assert_held (&lruvec_pgdat (lruvec)->lru_lock);if (!list)SetPageLRU (page_tail);
Signature · 1 line
2.17.1
PATCH 3/7 smsc: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- drivers/net/ethernet/smsc/smsc911x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/smsc/smsc911x.h +1 -1
@@ -67,7 +67,7 @@#ifdef CONFIG_DEBUG_SPINLOCK #define SMSC_ASSERT_MAC_LOCK (pdata) \ - WARN_ON_SMP(!spin_is_locked(&pdata->mac_lock)) + lockdep_assert_held(&pdata->mac_lock)#else #define SMSC_ASSERT_MAC_LOCK (pdata) do {} while (0)#endif /* CONFIG_DEBUG_SPINLOCK */
Signature · 1 line
2.17.1
PATCH 1/7 x86/PCI: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- arch/x86/pci/i386.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/pci/i386.c +1 -1
@@ -59,7 +59,7 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev) {struct pcibios_fwaddrmap *map; -WARN_ON_SMP (!spin_is_locked (&pcibios_fwaddrmap_lock)); +lockdep_assert_held (&pcibios_fwaddrmap_lock);list_for_each_entry (map, &pcibios_fwaddrmappings, list)if (map->dev == dev)
Signature · 1 line
2.17.1
PATCH 2/7 sfc: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- drivers/net/ethernet/sfc/efx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sfc/efx.c +1 -1
@@ -3167,7 +3167,7 @@ struct hlist_head *efx_rps_hash_bucket(struct efx_nic *efx, {u32 hash =efx_filter_spec_hash (spec); -WARN_ON (!spin_is_locked (&efx->rps_hash_lock)); +lockdep_assert_held (&efx->rps_hash_lock);if (!efx->rps_hash_table)return NULL ;return &efx->rps_hash_table[hash %EFX_ARFS_HASH_TABLE_SIZE ];
Signature · 1 line
2.17.1
PATCH 5/7 locking/mutex: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyFrom: Lance Roy <[email protected]>
lockdep_assert_held() is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removing spin_is_locked().
--- kernel/locking/mutex-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/locking/mutex-debug.c +2 -2
@@ -36,7 +36,7 @@ void debug_mutex_lock_common(struct mutex *lock, struct mutex_waiter *waiter)void debug_mutex_wake_waiter (struct mutex *lock,struct mutex_waiter *waiter) { -SMP_DEBUG_LOCKS_WARN_ON (!spin_is_locked (&lock->wait_lock)); +lockdep_assert_held (&lock->wait_lock);DEBUG_LOCKS_WARN_ON (list_empty (&lock->wait_list));DEBUG_LOCKS_WARN_ON (waiter->magic != waiter);DEBUG_LOCKS_WARN_ON (list_empty (&waiter->list));
@@ -51,7 +51,7 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)void debug_mutex_add_waiter (struct mutex *lock,struct mutex_waiter *waiter,struct task_struct *task) { -SMP_DEBUG_LOCKS_WARN_ON (!spin_is_locked (&lock->wait_lock)); +lockdep_assert_held (&lock->wait_lock);/* Mark the current thread as blocked on the lock: */ task->blocked_on = waiter;
Signature · 1 line
2.17.1
cover Use lockdep instead of asserting spin_is_locked() for v4.21/v5.0
Hello!
This series converts assertions of spin_is_locked() into lockdep_assert_held(), all courtesy of Lance Roy.
Thanx, Paul
------------------------------------------------------------------------
arch/x86/pci/i386.c | 2 +- drivers/net/ethernet/sfc/efx.c | 2 +- drivers/net/ethernet/smsc/smsc911x.h | 2 +- fs/userfaultfd.c | 2 +- kernel/locking/mutex-debug.c | 4 ++-- mm/khugepaged.c | 4 ++-- mm/swap.c | 3 +-- virt/kvm/arm/vgic/vgic.c | 12 ++++++------ 8 files changed, 15 insertions(+), 16 deletions(-)
Re: [PATCH tip/core/rcu 2/7] sfc: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyQuoted 7 lines · Paul E. McKenney
From: Lance Roy <[email protected]>
lockdep_assert_held()is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removingspin_is_locked().
Quoted 8 lines
Signed-off-by Lance Roy <[email protected]>Cc Solarflare linux maintainers <[email protected]>Cc Edward Cree <[email protected]>Cc Bert Kenward <[email protected]>Cc "David S. Miller" <[email protected]>Cc <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>---
Quoted 16 lines
drivers/net/ethernet/sfc/efx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/sfc/efx.c +1
-1@@ -3167,7 +3167,7 @@ struct hlist_head *efx_rps_hash_bucket(struct efx_nic *efx, {u32 hash =efx_filter_spec_hash (spec); -WARN_ON (!spin_is_locked (&efx->rps_hash_lock)); +lockdep_assert_held (&efx->rps_hash_lock);if (!efx->rps_hash_table)return NULL ;return &efx->rps_hash_table[hash %EFX_ARFS_HASH_TABLE_SIZE ];
Paul E. McKenney
AppliedRe: [PATCH tip/core/rcu 2/7] sfc: Replace spin_is_locked() with lockdep
Quoted 16 lines · Edward Cree
Quoted 7 lines · Paul E. McKenney
From: Lance Roy <[email protected]>
lockdep_assert_held()is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removingspin_is_locked().Quoted 8 lines
Signed-off-by Lance Roy <[email protected]>Cc Solarflare linux maintainers <[email protected]>Cc Edward Cree <[email protected]>Cc Bert Kenward <[email protected]>Cc "David S. Miller" <[email protected]>Cc <[email protected]>Signed-off-by Paul E. McKenney <[email protected]>---
Quoted 1 line
Acked-by Edward Cree <[email protected]>
Applied, thank you!
Thanx, Paul
Quoted 18 lines
Quoted 16 lines
drivers/net/ethernet/sfc/efx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/sfc/efx.c +1
-1@@ -3167,7 +3167,7 @@ struct hlist_head *efx_rps_hash_bucket(struct efx_nic *efx, {u32 hash =efx_filter_spec_hash (spec); -WARN_ON (!spin_is_locked (&efx->rps_hash_lock)); +lockdep_assert_held (&efx->rps_hash_lock);if (!efx->rps_hash_table)return NULL ;return &efx->rps_hash_table[hash %EFX_ARFS_HASH_TABLE_SIZE ];
Re: [PATCH tip/core/rcu 6/7] mm: Replace spin_is_locked() with lockdep
In reply to Paul E. McKenneyQuoted 6 lines · Paul E. McKenney
From: Lance Roy <[email protected]>
lockdep_assert_held()is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removingspin_is_locked().
So fyi I'm not crazy about these kind of patches simply because lockdep is a lot less used out of anything that's not a lab, and we can be missing potential offenders. There's obviously nothing wrong about what you describe above perse, just my two cents.
Thansk,
Davidlohr
Re: [PATCH tip/core/rcu 6/7] mm: Replace spin_is_locked() with lockdep
Quoted 9 lines · Davidlohr Bueso
Quoted 6 lines · Paul E. McKenney
From: Lance Roy <[email protected]>
lockdep_assert_held()is better suited to checking locking requirements, since it only checks if the current thread holds the lock regardless of whether someone else does. This is also a step towards possibly removingspin_is_locked().
Quoted 4 lines
So fyi I'm not crazy about these kind of patches simply because lockdep is a lot less used out of anything that's not a lab, and we can be missing potential offenders. There's obviously nothing wrong about what you describe above perse, just my two cents.
Fair point!
One countervailing advantage of lockdep is that it is not subject to the false negatives that can happen if someone else happens to be currently holding the lock. But what would you suggest instead?
Thanx, Paul