* [PATCH 2/6] udp: Add missing annotations for busylock_acquire() and busylock_release()
[not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
@ 2020-04-29 10:05 ` Jules Irenge
2020-04-29 10:05 ` [PATCH 3/6] udp: Add annotations for udp_rmem_release() Jules Irenge
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Jules Irenge @ 2020-04-29 10:05 UTC (permalink / raw)
To: linux-kernel
Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
Jakub Kicinski, open list:NETWORKING [IPv4/IPv6]
Sparse reports warnings
warning: context imbalance in busylock_acquire() - wrong count at exit
warning: context imbalance in busylock_release() - unexpected unlock
The root cause is the missing annotations at
busylock_acquire() and busylock_release()
The __release(busy) annotation inside busylock_release()
tells Sparse and not GCC to shutdown the warning
in case the condition is not satisfied.
Add the missing __acquires(busy) annotation
Add the missing __releases(busy) annotation
Add the __release(busy) annotation
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
net/ipv4/udp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index db76b9609299..5ca12a945ac3 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1430,6 +1430,7 @@ static int udp_busylocks_log __read_mostly;
static spinlock_t *udp_busylocks __read_mostly;
static spinlock_t *busylock_acquire(void *ptr)
+ __acquires(busy)
{
spinlock_t *busy;
@@ -1439,9 +1440,13 @@ static spinlock_t *busylock_acquire(void *ptr)
}
static void busylock_release(spinlock_t *busy)
+ __releases(busy)
{
if (busy)
spin_unlock(busy);
+ else
+ /* annotation for sparse */
+ __release(busy);
}
int __udp_enqueue_schedule_skb(struct sock *sk, struct sk_buff *skb)
--
2.25.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/6] udp: Add annotations for udp_rmem_release()
[not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
2020-04-29 10:05 ` [PATCH 2/6] udp: Add missing annotations for busylock_acquire() and busylock_release() Jules Irenge
@ 2020-04-29 10:05 ` Jules Irenge
2020-04-29 10:05 ` [PATCH 4/6] net: atm: Add missing annotation for lec_seq_stop() Jules Irenge
2020-04-29 10:05 ` [PATCH 6/6] net: atm: Add annotation for lec_priv_walk() Jules Irenge
3 siblings, 0 replies; 6+ messages in thread
From: Jules Irenge @ 2020-04-29 10:05 UTC (permalink / raw)
To: linux-kernel
Cc: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
Jakub Kicinski, open list:NETWORKING [IPv4/IPv6]
Sparse reports a warning
warning: context imbalance in udp_rmem_release() - unexpected unlock
To fix this,
__acquire(&sk_queue->lock) and __release(&sk_queue->lock) annotations
are added in case the condition is not met.
This add basically tell Sparse and not GCC to shutdown the warning
Add __acquire(&sk_queue->lock) annotation
Add the __release(&sk_queue->lock) annotation
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
net/ipv4/udp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5ca12a945ac3..175bd14bfac8 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1382,6 +1382,9 @@ static void udp_rmem_release(struct sock *sk, int size, int partial,
sk_queue = &sk->sk_receive_queue;
if (!rx_queue_lock_held)
spin_lock(&sk_queue->lock);
+ else
+ /* annotation for sparse */
+ __acquire(&sk_queue->lock);
sk->sk_forward_alloc += size;
@@ -1398,6 +1401,9 @@ static void udp_rmem_release(struct sock *sk, int size, int partial,
if (!rx_queue_lock_held)
spin_unlock(&sk_queue->lock);
+ else
+ /* annotation for sparse */
+ __release(&sk_queue->lock);
}
/* Note: called with reader_queue.lock held.
--
2.25.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/6] net: atm: Add missing annotation for lec_seq_stop()
[not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
2020-04-29 10:05 ` [PATCH 2/6] udp: Add missing annotations for busylock_acquire() and busylock_release() Jules Irenge
2020-04-29 10:05 ` [PATCH 3/6] udp: Add annotations for udp_rmem_release() Jules Irenge
@ 2020-04-29 10:05 ` Jules Irenge
2020-04-29 10:05 ` [PATCH 6/6] net: atm: Add annotation for lec_priv_walk() Jules Irenge
3 siblings, 0 replies; 6+ messages in thread
From: Jules Irenge @ 2020-04-29 10:05 UTC (permalink / raw)
To: linux-kernel
Cc: David S. Miller, Jakub Kicinski, Andy Shevchenko, Dan Carpenter,
Heiner Kallweit, Michael S. Tsirkin, Thomas Gleixner,
open list:NETWORKING [GENERAL]
Sparse reports a warning at lec_seq_stop()
warning: context imbalance in lec_seq_stop() - unexpected unlock
The root cause is the missing annotation at lec_seq_stop()
The __release() annotation inside lec_seq_stop()
tells only Sparse to shutdown the warning
Add the missing __releases(&state->locked->lec_arp_lock)
Add __release(&state->locked->lec_arp_lock) annotation
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
net/atm/lec.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 25fa3a7b72bd..22415bc11878 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -940,6 +940,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
}
static void lec_seq_stop(struct seq_file *seq, void *v)
+ __releases(&state->locked->lec_arp_lock)
{
struct lec_state *state = seq->private;
@@ -947,7 +948,9 @@ static void lec_seq_stop(struct seq_file *seq, void *v)
spin_unlock_irqrestore(&state->locked->lec_arp_lock,
state->flags);
dev_put(state->dev);
- }
+ } else
+ /* annotation for sparse */
+ __release(&state->locked->lec_arp_lock);
}
static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
--
2.25.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6/6] net: atm: Add annotation for lec_priv_walk()
[not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
` (2 preceding siblings ...)
2020-04-29 10:05 ` [PATCH 4/6] net: atm: Add missing annotation for lec_seq_stop() Jules Irenge
@ 2020-04-29 10:05 ` Jules Irenge
2020-04-29 10:22 ` Andy Shevchenko
3 siblings, 1 reply; 6+ messages in thread
From: Jules Irenge @ 2020-04-29 10:05 UTC (permalink / raw)
To: linux-kernel
Cc: David S. Miller, Jakub Kicinski, Andy Shevchenko, Dan Carpenter,
Shannon Nelson, Thomas Gleixner, Michael S. Tsirkin,
open list:NETWORKING [GENERAL]
Sparse reports a warning at lec_priv_walk()
warning: context imbalance in lec_priv_walk() - unexpected unlock
The root cause is the missing annotation at lec_priv_walk()
To fix this, __acquire() and __release() annotations
are added in case conditions are not met.
This only instruct Sparse to shutdown the warning
Add the __acquire(&priv->lec_arp_lock)
Add __release(&priv->lec_arp_lock) annotation
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
net/atm/lec.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 22415bc11878..6070acaa3d5c 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -886,12 +886,18 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l,
if (!state->locked) {
state->locked = priv;
spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
+ } else {
+ /* annotation for sparse */
+ __acquire(&priv->lec_arp_lock);
}
if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) {
spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
state->locked = NULL;
/* Partial state reset for the next time we get called */
state->arp_table = state->misc_table = 0;
+ } else {
+ /* annotation for sparse */
+ __release(&priv->lec_arp_lock);
}
return state->locked;
}
--
2.25.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 6/6] net: atm: Add annotation for lec_priv_walk()
2020-04-29 10:05 ` [PATCH 6/6] net: atm: Add annotation for lec_priv_walk() Jules Irenge
@ 2020-04-29 10:22 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2020-04-29 10:22 UTC (permalink / raw)
To: Jules Irenge
Cc: linux-kernel, David S. Miller, Jakub Kicinski, Dan Carpenter,
Shannon Nelson, Thomas Gleixner, Michael S. Tsirkin,
open list:NETWORKING [GENERAL]
On Wed, Apr 29, 2020 at 11:05:28AM +0100, Jules Irenge wrote:
> Sparse reports a warning at lec_priv_walk()
> warning: context imbalance in lec_priv_walk() - unexpected unlock
>
> The root cause is the missing annotation at lec_priv_walk()
> To fix this, __acquire() and __release() annotations
> are added in case conditions are not met.
> This only instruct Sparse to shutdown the warning
>
> Add the __acquire(&priv->lec_arp_lock)
> Add __release(&priv->lec_arp_lock) annotation
At least those two I got should be in one patch. Simple fix all same sparse
issues at once.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] net: atm: Add annotation for lec_priv_walk() and lec_seq_stop()
[not found] <0/6>
[not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
@ 2020-04-29 14:58 ` Jules Irenge
1 sibling, 0 replies; 6+ messages in thread
From: Jules Irenge @ 2020-04-29 14:58 UTC (permalink / raw)
To: linux-kernel
Cc: David S. Miller, Jakub Kicinski, Andy Shevchenko,
Michael S. Tsirkin, Greg Kroah-Hartman, Thomas Gleixner,
Dan Carpenter, open list:NETWORKING [GENERAL]
Sparse reports a warning at lec_priv_walk() and lec_seq_stop()
warning: context imbalance in lec_priv_walk() - unexpected unlock
warning: context imbalance in lec_seq_stop() - unexpected unlock
The root cause is the missing annotation at lec_priv_walk()
and lec_seq_stop()
To fix this, __acquire() and __release() annotations
are added in case conditions are not met.
This only instruct Sparse to shutdown the warning
Add the __acquire(&priv->lec_arp_lock)
Add __release(&priv->lec_arp_lock) annotation
Add __releases(&state->locked->lec_arp_lock) annotation
Add __release(&state->locked->lec_arp_lock) annotation
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
Changes since v2
- merge patch No 6 and No 4 into one
net/atm/lec.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 25fa3a7b72bd..7947abb17af2 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -886,12 +886,18 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l,
if (!state->locked) {
state->locked = priv;
spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
+ } else {
+ /* annotation for sparse */
+ __acquire(&priv->lec_arp_lock);
}
if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) {
spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
state->locked = NULL;
/* Partial state reset for the next time we get called */
state->arp_table = state->misc_table = 0;
+ } else {
+ /* annotation for sparse */
+ __release(&priv->lec_arp_lock);
}
return state->locked;
}
@@ -940,6 +946,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
}
static void lec_seq_stop(struct seq_file *seq, void *v)
+ __releases(&state->locked->lec_arp_lock)
{
struct lec_state *state = seq->private;
@@ -947,6 +954,9 @@ static void lec_seq_stop(struct seq_file *seq, void *v)
spin_unlock_irqrestore(&state->locked->lec_arp_lock,
state->flags);
dev_put(state->dev);
+ } else {
+ /* annotation for sparse */
+ __release(&state->locked->lec_arp_lock);
}
}
--
2.25.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-29 15:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <0/6>
[not found] ` <20200429100529.19645-1-jbi.octave@gmail.com>
2020-04-29 10:05 ` [PATCH 2/6] udp: Add missing annotations for busylock_acquire() and busylock_release() Jules Irenge
2020-04-29 10:05 ` [PATCH 3/6] udp: Add annotations for udp_rmem_release() Jules Irenge
2020-04-29 10:05 ` [PATCH 4/6] net: atm: Add missing annotation for lec_seq_stop() Jules Irenge
2020-04-29 10:05 ` [PATCH 6/6] net: atm: Add annotation for lec_priv_walk() Jules Irenge
2020-04-29 10:22 ` Andy Shevchenko
2020-04-29 14:58 ` [PATCH v2] net: atm: Add annotation for lec_priv_walk() and lec_seq_stop() Jules Irenge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).