Lock warnings cleanup
Subsystems (6)
cover Lock warnings cleanup
This patch serie propose a solution to functions that record context imbalance by adding annotations
Jules Irenge (6):
usb: gadget: Add missing annotation for xudc_handle_setup()
udp: Add missing annotations for busylock_acquire() and
busylock_release()
udp: Add annotations for udp_rmem_release()
net: atm: Add missing annotation for lec_seq_stop()
USB: dummy-hcd: Add missing annotation for set_link_state()
net: atm: Add annotation for lec_priv_walk()
drivers/usb/gadget/udc/dummy_hcd.c | 1 + drivers/usb/gadget/udc/udc-xilinx.c | 1 + net/atm/lec.c | 11 ++++++++++- net/ipv4/udp.c | 11 +++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.3
PATCH 1/6 usb: gadget: Add missing annotation for xudc_handle_setup()
Sparse reports a warning at xudc_handle_setup()
warning: context imbalance in xudc_handle_setup() - unexpected unlock
The root cause is the missing annotation at xudc_handle_setup()
Add the missing __must_hold(&udc->lock) annotation
--- drivers/usb/gadget/udc/udc-xilinx.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/udc-xilinx.c +1 -0
@@ -1733,6 +1733,7 @@ static void xudc_set_clear_feature(struct xusb_udc *udc)* Process setup packet and delegate to gadget layer. */ static void xudc_handle_setup (struct xusb_udc *udc) + __must_hold(&udc->lock) {struct xusb_ep *ep0 = &udc->ep[0 ];struct usb_ctrlrequest setup;
Signature · 7 lines
2.25.3 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/6 udp: Add missing annotations for busylock_acquire() and busylock_release()
In reply to Jules IrengeSparse 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 atbusylock_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
--- net/ipv4/udp.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv4/udp.c +5 -0
@@ -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)
Signature · 1 line
2.25.3
PATCH 3/6 udp: Add annotations for udp_rmem_release()
In reply to Jules IrengeSparse 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
--- net/ipv4/udp.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/udp.c +6 -0
@@ -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.
Signature · 1 line
2.25.3
PATCH 4/6 net: atm: Add missing annotation for lec_seq_stop()
In reply to Jules IrengeSparse 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
--- net/atm/lec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/atm/lec.c +4 -1
@@ -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)
Signature · 1 line
2.25.3
PATCH 5/6 USB: dummy-hcd: Add missing annotation for set_link_state()
In reply to Jules IrengeSparse reports a warning at set_link_state()
warning: context imbalance in set_link_state() - unexpected unlock
The root cause is the missing annotation at set_link_state() Add the missing __must_hold(&dum->lock)
--- drivers/usb/gadget/udc/dummy_hcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/dummy_hcd.c +1 -0
@@ -427,6 +427,7 @@ static void set_link_state_by_speed(struct dummy_hcd *dum_hcd)/* caller must hold lock */ static void set_link_state (struct dummy_hcd *dum_hcd) + __must_hold(&dum->lock) {struct dummy *dum = dum_hcd->dum;unsigned int power_bit;
Signature · 1 line
2.25.3
PATCH 6/6 net: atm: Add annotation for lec_priv_walk()
In reply to Jules IrengeSparse 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
--- net/atm/lec.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/atm/lec.c +6 -0
@@ -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; }
Signature · 1 line
2.25.3
Re: [PATCH 6/6] net: atm: Add annotation for lec_priv_walk()
Quoted 10 lines · Jules Irenge
Sparse reports a warning at
lec_priv_walk()
warning: context imbalance inlec_priv_walk()- unexpected unlockThe 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 warningAdd 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.
Signature · 2 lines
With Best Regards, Andy Shevchenko