This patch series adds missing annotations to various functions that register warnings of context imbalance when built with Sparse tool. The adds fix the warnings and give better insight or directive on what the function are actually doing.
Jules Irenge (30):
x86/apic/vector: Add missing annotation to lock_vector_lock(void)
x86/apic/vector: Add missing annotation to lock_vector_lock(void)
mm/memcontrol: Add missing annotation for unlock_page_lru()
mm/memcontrol: Add missing annotation for lock_page_lru()
mm/compaction: Add missing annotation for compact_lock_irqsave
mm/hugetlb: Add missing annotation for gather_surplus_pages()
mm/mempolicy: Add missing annotation for queue_pages_pmd()
mm/slub: Add missing annotation for get_map()
mm/slub: Add missing annotation for put_map()
mm/zsmalloc: Add missing annotation for migrate_read_lock()
mm/zsmalloc: Add missing annotation for migrate_read_unlock()
mm/zsmalloc: Add missing annotation for pin_tag()
mm/zsmalloc: Add missing annotation for unpin_tag()
x86/xen: Add missing annotation for xen_pte_lock()
x86/xen: Add missing annotation for xen_pte_unlock()
drm/vkms: Add missing annotation for vkms_crtc_atomic_begin()
drm/vkms: Add missing annotation for vkms_crtc_atomic_flush()
driver core: Add missing annotation for device_links_write_lock()
driver core: Add missing annotation for device_links_read_lock()
pcnet32: Add missing annotation for pcnet32_suspend()
sfc: Add missing annotation for efx_ef10_try_update_nic_stats_vf()
xhci: Add missing annotation for xhci_set_port_power()
xhci: Add missing annotation for xhci_enter_test_mode
tipc: Add missing annotation for tipc_node_read_lock()
tipc: Add missing annotation for tipc_node_read_unlock()
tipc: Add missing annotation for tipc_node_write_lock()
tipc: Add missing annotation for tipc_node_write_unlock_fast()
tipc: Add missing annotation for tipc_node_write_unlock()
net: Add missing annotation for netlink_walk_start()
net: Add missing annotation for netlink_walk_stop()
arch/x86/kernel/apic/vector.c | 4 ++--
arch/x86/xen/mmu_pv.c | 3 ++-
drivers/base/core.c | 4 ++--
drivers/gpu/drm/vkms/vkms_crtc.c | 2 ++
drivers/net/ethernet/amd/pcnet32.c | 2 +-
drivers/net/ethernet/sfc/ef10.c | 1 +
drivers/usb/host/xhci-hub.c | 2 ++
mm/compaction.c | 1 +
mm/hugetlb.c | 1 +
mm/memcontrol.c | 2 ++
mm/mempolicy.c | 1 +
mm/slub.c | 3 ++-
mm/zsmalloc.c | 8 ++++----
net/netlink/af_netlink.c | 4 ++--
net/tipc/node.c | 9 +++++----
15 files changed, 30 insertions(+), 17 deletions(-)
--
2.24.1
Sparse reports a warning at unlock_vector_lock()
warning: context imbalance in unlock_vector_lock() - unexpected unlock
The root cause is the missing annotation at unlock_vector_lock()
Add the missing __releases(&vector_lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
arch/x86/kernel/apic/vector.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index d7556939c6cf..8ee7848a355b 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -55,7 +55,7 @@ void lock_vector_lock(void) __acquires(&vector_lock)
raw_spin_lock(&vector_lock);
}
-void unlock_vector_lock(void)
+void unlock_vector_lock(void) __releases(&vector_lock)
{
raw_spin_unlock(&vector_lock);
}
--
2.24.1
Sparse reports warning at unlock_page_lry()
warning: context imbalance in unlock_page_lru() - unexpected unlock
The root cause is the missing annotation at unlock_page_lru()
Add the missing __releases(&pgdat->lru_lock)
Signed-off-by: Jules Irenge <[email protected]>
---
mm/memcontrol.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6f6dc8712e39..22ddd557a69b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2587,6 +2587,7 @@ static void lock_page_lru(struct page *page, int *isolated)
}
static void unlock_page_lru(struct page *page, int isolated)
+ __releases(&pgdat->lru_lock)
{
pg_data_t *pgdat = page_pgdat(page);
--
2.24.1
Sparse reports warning at lock_page_lry()
warning: context imbalance in lock_page_lru() - wrong count at exit
The root cause is the missing annotation at lock_page_lru()
Add the missing __acquires(&pgdat->lru_lock)
Signed-off-by: Jules Irenge <[email protected]>
---
mm/memcontrol.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 22ddd557a69b..67dc9f1af0bf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2571,6 +2571,7 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
}
static void lock_page_lru(struct page *page, int *isolated)
+ __acquires(&pgdat->lru_lock)
{
pg_data_t *pgdat = page_pgdat(page);
--
2.24.1
Sparse reports a warning at compact_lock_irqsave()
warning: context imbalance in compact_lock_irqsave() - wrong count at exit
The root cause is the missing annotation at compact_lock_irqsave()
Add the missing __acquires(lock) annotation.
Signed-off-by: Jules Irenge <[email protected]>
---
mm/compaction.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/compaction.c b/mm/compaction.c
index 672d3c78c6ab..81190fe22200 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -481,6 +481,7 @@ static bool test_and_set_skip(struct compact_control *cc, struct page *page,
*/
static bool compact_lock_irqsave(spinlock_t *lock, unsigned long *flags,
struct compact_control *cc)
+ __acquires(lock)
{
/* Track if the lock is contended in async mode */
if (cc->mode == MIGRATE_ASYNC && !cc->contended) {
--
2.24.1
Sparse reports a warning at gather_surplus_pages()
warning: context imbalance in hugetlb_cow() - unexpected unlock
The root cause is the missing annotation at gather_surplus_pages()
Add the missing __must_hold(&hugetlb_lock)
Signed-off-by: Jules Irenge <[email protected]>
---
mm/hugetlb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index dd8737a94bec..ff7dda27b33f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1695,6 +1695,7 @@ struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
* of size 'delta'.
*/
static int gather_surplus_pages(struct hstate *h, int delta)
+ __must_hold(&hugetlb_lock)
{
struct list_head surplus_list;
struct page *page, *tmp;
--
2.24.1
Sparse reports a warning at migrate_read_unlock()()
warning: context imbalance in migrate_read_unlock() - unexpected unlock
The root cause is the missing annotation at migrate_read_unlock()
Add the missing __releases(&zspage->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
mm/zsmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index da70817b4ed8..2eab424c8c67 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1838,7 +1838,7 @@ static void migrate_read_lock(struct zspage *zspage) __acquires(&zspage->lock)
read_lock(&zspage->lock);
}
-static void migrate_read_unlock(struct zspage *zspage)
+static void migrate_read_unlock(struct zspage *zspage) __releases(&zspage->lock)
{
read_unlock(&zspage->lock);
}
--
2.24.1
Sparse reports a warning at vkms_crtc_atomic_begin()
warning: context imbalance in vkms_crtc_atomic_begin()
- wrong count at exit
The root cause is the missing annotation at vkms_crtc_atomic_begin()
Add the missing __acquires(&vkms_output->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/gpu/drm/vkms/vkms_crtc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 74f703b8d22a..7513be6444ae 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -219,6 +219,7 @@ static void vkms_crtc_atomic_disable(struct drm_crtc *crtc,
static void vkms_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state)
+ __acquires(&vkms_output->lock)
{
struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
--
2.24.1
Sparse reports a warning at efx_ef10_try_update_nic_stats_vf()
warning: context imbalance in efx_ef10_try_update_nic_stats_vf()
- unexpected unlock
The root cause is the missing annotation at
efx_ef10_try_update_nic_stats_vf()
Add the missing __must_hold(&efx->stats_lock) annotattion
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/net/ethernet/sfc/ef10.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 52113b7529d6..b1102c7e814d 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -1820,6 +1820,7 @@ static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats,
}
static int efx_ef10_try_update_nic_stats_vf(struct efx_nic *efx)
+ __must_hold(&efx->stats_lock)
{
MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
struct efx_ef10_nic_data *nic_data = efx->nic_data;
--
2.24.1
Sparse reports a warning at netlink_walk_stop()
warning: context imbalance in netlink_walk_stop()
- unexpected unlock
The root cause is the missing annotation at netlink_walk_stop()
A close look at rhashtable_walk_stop()
shows that an __releases(RCU) is needed here
Add the missing __releases(RCU) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/netlink/af_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index a3fddc845538..7a287dc73f63 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2545,7 +2545,7 @@ static void netlink_walk_start(struct nl_seq_iter *iter) __acquires(RCU)
rhashtable_walk_start(&iter->hti);
}
-static void netlink_walk_stop(struct nl_seq_iter *iter)
+static void netlink_walk_stop(struct nl_seq_iter *iter) __releases(RCU)
{
rhashtable_walk_stop(&iter->hti);
rhashtable_walk_exit(&iter->hti);
--
2.24.1
Sparse reports a warning at tipc_node_write_unlock_fast()
warning: context imbalance in tipc_node_write_unlock_fast
- unexpected unlock
The root cause is the missing annotation at tipc_node_write_unlock_fast()
Add the missing __releases(&n->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/tipc/node.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index d8401789fa23..cc656b2205db 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -367,6 +367,7 @@ static void tipc_node_write_lock(struct tipc_node *n) __acquires(&n->lock)
}
static void tipc_node_write_unlock_fast(struct tipc_node *n)
+ __releases(&n->lock)
{
write_unlock_bh(&n->lock);
}
--
2.24.1
Sparse reports a warning at tipc_node_read_unlock()
warning: context imbalance in tipc_node_read_unlock - unexpected unlock
The root cause is the missing annotation at tipc_node_read_unlock()
Add the missing __releases(&n->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/tipc/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 4e267ed94a2a..eafa38896e3a 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -356,7 +356,7 @@ static void tipc_node_read_lock(struct tipc_node *n) __acquires(&n->lock)
read_lock_bh(&n->lock);
}
-static void tipc_node_read_unlock(struct tipc_node *n)
+static void tipc_node_read_unlock(struct tipc_node *n) __releases(&n->lock)
{
read_unlock_bh(&n->lock);
}
--
2.24.1
Sparse reports a warning at lock_vector_lock(void)
warning: context imbalance in lock_vector_lock() - wrong count at exit
The root cause is the missing annotation at lock_vector_lock(void)
Add the missing __acquires(&vector_lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
arch/x86/kernel/apic/vector.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 2c5676b0a6e7..d7556939c6cf 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -47,7 +47,7 @@ static struct irq_matrix *vector_matrix;
static DEFINE_PER_CPU(struct hlist_head, cleanup_list);
#endif
-void lock_vector_lock(void)
+void lock_vector_lock(void) __acquires(&vector_lock)
{
/* Used to the online set of cpus does not change
* during assign_irq_vector.
--
2.24.1
Sparse reports a warning at device_links_read_unlock()
warning: warning: context imbalance in device_links_read_unlock()
- unexpected unlock
The root cause is the missing annotation at device_links_read_unlock()
Add the missing __releases(&device_links_srcu) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/base/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index fc7f1b8746da..3a7e72840740 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -69,7 +69,7 @@ int device_links_read_lock(void) __acquires(&device_links_srcu)
return srcu_read_lock(&device_links_srcu);
}
-void device_links_read_unlock(int idx)
+void device_links_read_unlock(int idx) __releases(&device_links_srcu)
{
srcu_read_unlock(&device_links_srcu, idx);
}
--
2.24.1
Sparse reports a warning at tipc_node_write_unlock()
warning: context imbalance in tipc_node_write_unlock
- unexpected unlock
The root cause is the missing annotation at tipc_node_write_unlock()
Add the missing __releases(&n->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/tipc/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index cc656b2205db..c3b810427d24 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -372,7 +372,7 @@ static void tipc_node_write_unlock_fast(struct tipc_node *n)
write_unlock_bh(&n->lock);
}
-static void tipc_node_write_unlock(struct tipc_node *n)
+static void tipc_node_write_unlock(struct tipc_node *n) __releases(&n->lock)
{
struct net *net = n->net;
u32 addr = 0;
--
2.24.1
Sparse reports a warning at device_links_write_lock()
warning: context imbalance in evice_links_write_lock()
- wrong count at exit
The root cause is the missing annotation at device_links_write_lock()
Add the missing __acquires(&device_links_srcu) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/base/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 42a672456432..fc7f1b8746da 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -64,7 +64,7 @@ static inline void device_links_write_unlock(void)
mutex_unlock(&device_links_lock);
}
-int device_links_read_lock(void)
+int device_links_read_lock(void) __acquires(&device_links_srcu)
{
return srcu_read_lock(&device_links_srcu);
}
--
2.24.1
Sparse reports a warning at vkms_crtc_atomic_flush()
warning: context imbalance in vkms_crtc_atomic_flush()
- unexpected unlock
The root cause is the missing annotation at vkms_crtc_atomic_flush()
Add the missing __releases(&vkms_output->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/gpu/drm/vkms/vkms_crtc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 7513be6444ae..bc0ac2641220 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -231,6 +231,7 @@ static void vkms_crtc_atomic_begin(struct drm_crtc *crtc,
static void vkms_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state)
+ __releases(&vkms_output->lock)
{
struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc);
--
2.24.1
Sparse reports a warning at tipc_node_read_lock()
warning: context imbalance in tipc_node_read_lock - wrong count at exit
The root cause is the missing annotation at tipc_node_read_lock()
Add the missing __acquires(&n->lock) annotattion
Signed-off-by: Jules Irenge <[email protected]>
---
net/tipc/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 99b28b69fc17..4e267ed94a2a 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -351,7 +351,7 @@ static struct tipc_node *tipc_node_find_by_id(struct net *net, u8 *id)
return found ? n : NULL;
}
-static void tipc_node_read_lock(struct tipc_node *n)
+static void tipc_node_read_lock(struct tipc_node *n) __acquires(&n->lock)
{
read_lock_bh(&n->lock);
}
--
2.24.1
Sparse reports warning at xen_pte_lock()
warning: context imbalance in xen_pte_lock() - wrong count at exit
The root cause is the missing annotation at xen_pte_lock()
Add the missing __acquires(ptl) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
arch/x86/xen/mmu_pv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index bbba8b17829a..352f0c80cfcf 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -695,6 +695,7 @@ static int xen_pgd_walk(struct mm_struct *mm,
/* If we're using split pte locks, then take the page's lock and
return a pointer to it. Otherwise return NULL. */
static spinlock_t *xen_pte_lock(struct page *page, struct mm_struct *mm)
+ __acquires(ptl)
{
spinlock_t *ptl = NULL;
--
2.24.1
Sparse reports a warning at tipc_node_write_lock()
warning: context imbalance in tipc_node_write_lock - wrong count at exit
The root cause is the missing annotation at tipc_node_write_lock()
Add the missing __acquires(&n->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/tipc/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index eafa38896e3a..d8401789fa23 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -361,7 +361,7 @@ static void tipc_node_read_unlock(struct tipc_node *n) __releases(&n->lock)
read_unlock_bh(&n->lock);
}
-static void tipc_node_write_lock(struct tipc_node *n)
+static void tipc_node_write_lock(struct tipc_node *n) __acquires(&n->lock)
{
write_lock_bh(&n->lock);
}
--
2.24.1
Sparse reports a warning at netlink_walk_start()
warning: context imbalance in netlink_walk_start()
- wrong count at exit
The root cause is the missing annotation at netlink_walk_start()
A close look at rhashtable_walk_start_check()
shows that an __acquires(RCU) is needed here.
Add the missing __acquires(RCU) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/netlink/af_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 4e31721e7293..a3fddc845538 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2539,7 +2539,7 @@ struct nl_seq_iter {
int link;
};
-static void netlink_walk_start(struct nl_seq_iter *iter)
+static void netlink_walk_start(struct nl_seq_iter *iter) __acquires(RCU)
{
rhashtable_walk_enter(&nl_table[iter->link].hash, &iter->hti);
rhashtable_walk_start(&iter->hti);
--
2.24.1
Sparse reports a warning at xhci_enter_test_mode()
warning: context imbalance in xhci_enter_test_mode - unexpected unlock
The root cause is the missing annotation at xhci_enter_test_mode()
Add the missing __must_hold(&xhci->lock) annotattion
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/usb/host/xhci-hub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 57e3f2c5475a..38839308557e 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -609,6 +609,7 @@ static void xhci_port_set_test_mode(struct xhci_hcd *xhci,
static int xhci_enter_test_mode(struct xhci_hcd *xhci,
u16 test_mode, u16 wIndex, unsigned long *flags)
+ __must_hold(&xhci->lock)
{
int i, retval;
--
2.24.1
Sparse reports warning at xen_pte_unlock()
warning: context imbalance in xen_pte_unlock() - unexpected unlock
The root cause is the missing annotation at xen_pte_unlock()
Add the missing __releases(ptl) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
arch/x86/xen/mmu_pv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index 352f0c80cfcf..777008f8c668 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -707,7 +707,7 @@ static spinlock_t *xen_pte_lock(struct page *page, struct mm_struct *mm)
return ptl;
}
-static void xen_pte_unlock(void *v)
+static void xen_pte_unlock(void *v) __releases(ptl)
{
spinlock_t *ptl = v;
spin_unlock(ptl);
--
2.24.1
Sparse reports a warning at pcnet32_suspend()
warning: context imbalance in pcnet32_suspend() - unexpected unlock
The root cause is the missing annotation at pcnet32_suspend()
Add the missing __must_hold(&lp->lock) annotattion
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/net/ethernet/amd/pcnet32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c
index dc7d88227e76..ac6c19441932 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -684,7 +684,7 @@ static void pcnet32_poll_controller(struct net_device *dev)
* lp->lock must be held.
*/
static int pcnet32_suspend(struct net_device *dev, unsigned long *flags,
- int can_sleep)
+ int can_sleep) __must_hold(&lp->lock)
{
int csr5;
struct pcnet32_private *lp = netdev_priv(dev);
--
2.24.1
Sparse reports a warning at unpin_tag()()
warning: context imbalance in unpin_tag() - unexpected unlock
The root cause is the missing annotation at unpin_tag()
Add the missing __releases(bitlock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
mm/zsmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 7bac76ae11b3..2aa2d524a343 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -896,7 +896,7 @@ static void pin_tag(unsigned long handle) __acquires(bitlock)
bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle);
}
-static void unpin_tag(unsigned long handle)
+static void unpin_tag(unsigned long handle) __releases(bitlock)
{
bit_spin_unlock(HANDLE_PIN_BIT, (unsigned long *)handle);
}
--
2.24.1
Sparse reports a warning at pin_tag()()
warning: context imbalance in pin_tag() - wrong count at exit
The root cause is the missing annotation at pin_tag()
Add the missing __acquires(bitlock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
mm/zsmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 2eab424c8c67..7bac76ae11b3 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -891,7 +891,7 @@ static inline int trypin_tag(unsigned long handle)
return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle);
}
-static void pin_tag(unsigned long handle)
+static void pin_tag(unsigned long handle) __acquires(bitlock)
{
bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle);
}
--
2.24.1
Sparse reports a warning at xhci_set_port_power()
warning: context imbalance in xhci_set_port_power - unexpected unlock
The root cause is the missing annotation at xhci_set_port_power()
Add the missing __must_hold(&xhci->lock) annotattion
Signed-off-by: Jules Irenge <[email protected]>
---
drivers/usb/host/xhci-hub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 7a3a29e5e9d2..57e3f2c5475a 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -558,6 +558,7 @@ struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd)
*/
static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
u16 index, bool on, unsigned long *flags)
+ __must_hold(&xhci->lock)
{
struct xhci_hub *rhub;
struct xhci_port *port;
--
2.24.1
Sparse reports a warning at put_map()()
warning: context imbalance in put_map() - unexpected unlock
The root cause is the missing annotation at put_map()
Add the missing __releases(&object_map_lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
mm/slub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slub.c b/mm/slub.c
index 3c6d348afcf9..c273d0f32b8f 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -466,7 +466,7 @@ static unsigned long *get_map(struct kmem_cache *s, struct page *page)
return object_map;
}
-static void put_map(unsigned long *map)
+static void put_map(unsigned long *map) __releases(&object_map_lock)
{
VM_BUG_ON(map != object_map);
lockdep_assert_held(&object_map_lock);
--
2.24.1
Sparse reports a warning at get_map()()
warning: context imbalance in get_map() - wrong count at exit
The root cause is the missing annotation at get_map()
Add the missing __acquires(&object_map_lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
mm/slub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/slub.c b/mm/slub.c
index 17dc00e33115..3c6d348afcf9 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -449,6 +449,7 @@ static DEFINE_SPINLOCK(object_map_lock);
* not vanish from under us.
*/
static unsigned long *get_map(struct kmem_cache *s, struct page *page)
+ __acquires(&object_map_lock)
{
void *p;
void *addr = page_address(page);
--
2.24.1
Sparse reports a warning at migrate_read_lock()()
warning: context imbalance in migrate_read_lock() - wrong count at exit
The root cause is the missing annotation at migrate_read_lock()
Add the missing __acquires(&zspage->lock) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
mm/zsmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 22d17ecfe7df..da70817b4ed8 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1833,7 +1833,7 @@ static void migrate_lock_init(struct zspage *zspage)
rwlock_init(&zspage->lock);
}
-static void migrate_read_lock(struct zspage *zspage)
+static void migrate_read_lock(struct zspage *zspage) __acquires(&zspage->lock)
{
read_lock(&zspage->lock);
}
--
2.24.1
Sparse reports a warning at queue_pages_pmd()
context imbalance in queue_pages_pmd() - unexpected unlock
The root cause is the missing annotation at queue_pages_pmd()
Add the missing __releases(ptl)
Signed-off-by: Jules Irenge <[email protected]>
---
mm/mempolicy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 977c641f78cf..bb0755228150 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -442,6 +442,7 @@ static inline bool queue_pages_required(struct page *page,
*/
static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,
unsigned long end, struct mm_walk *walk)
+ __releases(ptl)
{
int ret = 0;
struct page *page;
--
2.24.1
On 2/14/20 3:47 PM, Jules Irenge wrote:
> Sparse reports warning at xen_pte_lock()
>
> warning: context imbalance in xen_pte_lock() - wrong count at exit
>
> The root cause is the missing annotation at xen_pte_lock()
> Add the missing __acquires(ptl) annotation
>
> Signed-off-by: Jules Irenge <[email protected]>
Reviewed-by: Boris Ostrovsky <[email protected]>
although I'd prefer this and the next patch to be merged into a single one.
On 2/14/20 12:47 PM, Jules Irenge wrote:
> Sparse reports a warning at gather_surplus_pages()
>
> warning: context imbalance in hugetlb_cow() - unexpected unlock
>
> The root cause is the missing annotation at gather_surplus_pages()
> Add the missing __must_hold(&hugetlb_lock)
>
> Signed-off-by: Jules Irenge <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
--
Mike Kravetz
Thanks for the feedback. I will send the merged version then if it s fine
with you.
Regards,
Jules
On Fri, 14 Feb 2020, Boris Ostrovsky wrote:
>
>
> On 2/14/20 3:47 PM, Jules Irenge wrote:
> > Sparse reports warning at xen_pte_lock()
> >
> > warning: context imbalance in xen_pte_lock() - wrong count at exit
> >
> > The root cause is the missing annotation at xen_pte_lock()
> > Add the missing __acquires(ptl) annotation
> >
> > Signed-off-by: Jules Irenge <[email protected]>
>
> Reviewed-by: Boris Ostrovsky <[email protected]>
>
> although I'd prefer this and the next patch to be merged into a single one.
>
>
>
On 14/02/2020 20:47, Jules Irenge wrote:
> Sparse reports a warning at efx_ef10_try_update_nic_stats_vf()
>
> warning: context imbalance in efx_ef10_try_update_nic_stats_vf()
> - unexpected unlock
>
> The root cause is the missing annotation at
> efx_ef10_try_update_nic_stats_vf()
> Add the missing __must_hold(&efx->stats_lock) annotattion
>
> Signed-off-by: Jules Irenge <[email protected]>
Thanks
Acked-by: Martin Habets <[email protected]>
> ---
> drivers/net/ethernet/sfc/ef10.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
> index 52113b7529d6..b1102c7e814d 100644
> --- a/drivers/net/ethernet/sfc/ef10.c
> +++ b/drivers/net/ethernet/sfc/ef10.c
> @@ -1820,6 +1820,7 @@ static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats,
> }
>
> static int efx_ef10_try_update_nic_stats_vf(struct efx_nic *efx)
> + __must_hold(&efx->stats_lock)
> {
> MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
> struct efx_ef10_nic_data *nic_data = efx->nic_data;
>
On Fri, Feb 14, 2020 at 08:47:21PM +0000, Jules Irenge wrote:
> Sparse reports a warning at migrate_read_lock()()
>
> warning: context imbalance in migrate_read_lock() - wrong count at exit
>
> The root cause is the missing annotation at migrate_read_lock()
> Add the missing __acquires(&zspage->lock) annotation
>
> Signed-off-by: Jules Irenge <[email protected]>
Acked-by: Minchan Kim <[email protected]>
On Fri, Feb 14, 2020 at 08:47:21PM +0000, Jules Irenge wrote:
> Sparse reports a warning at migrate_read_lock()()
>
> warning: context imbalance in migrate_read_lock() - wrong count at exit
>
> The root cause is the missing annotation at migrate_read_lock()
> Add the missing __acquires(&zspage->lock) annotation
>
> Signed-off-by: Jules Irenge <[email protected]>
Acked-by: Minchan Kim <[email protected]>
On Fri, Feb 14, 2020 at 08:47:24PM +0000, Jules Irenge wrote:
> Sparse reports a warning at unpin_tag()()
>
> warning: context imbalance in unpin_tag() - unexpected unlock
>
> The root cause is the missing annotation at unpin_tag()
> Add the missing __releases(bitlock) annotation
>
> Signed-off-by: Jules Irenge <[email protected]>
Acked-by: Minchan Kim <[email protected]>
On Fri, Feb 14, 2020 at 08:47:23PM +0000, Jules Irenge wrote:
> Sparse reports a warning at pin_tag()()
>
> warning: context imbalance in pin_tag() - wrong count at exit
>
> The root cause is the missing annotation at pin_tag()
> Add the missing __acquires(bitlock) annotation
>
> Signed-off-by: Jules Irenge <[email protected]>
Acked-by: Minchan Kim <[email protected]>
On Fri, Feb 14, 2020 at 08:47:22PM +0000, Jules Irenge wrote:
> Sparse reports a warning at migrate_read_unlock()()
>
> warning: context imbalance in migrate_read_unlock() - unexpected unlock
>
> The root cause is the missing annotation at migrate_read_unlock()
> Add the missing __releases(&zspage->lock) annotation
>
> Signed-off-by: Jules Irenge <[email protected]>
Acked-by: Minchan Kim <[email protected]>