lock warnings cleanup
Subsystems (5)
cover lock warnings cleanup
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, improve on readability of the code
and give better insight or directive on what the functions are actually doing.
Jules Irenge (5):
ipc/msg: Add missing annotation for freeque()
video: Add missing annotation for cyber2000fb_enable_ddc() and
cyber2000fb_disable_ddc()
ocfs2: Add missing annotation for dlm_empty_lockres()
libata: Add missing annotation for ata_scsi_rbuf_get() and
ata_scsi_rbuf_fill()
ipmi: Add missing annotation for ipmi_ssif_lock_cond() and
ipmi_ssif_unlock_cond()
drivers/ata/libata-scsi.c | 2 ++ drivers/char/ipmi/ipmi_ssif.c | 2 ++ drivers/video/fbdev/cyber2000fb.c | 2 ++ fs/ocfs2/dlm/dlmmaster.c | 1 + ipc/msg.c | 2 ++ 5 files changed, 9 insertions(+)
Signature · 1 line
2.24.1
PATCH 1/5 ipc/msg: Add missing annotation for freeque()
Sparse reports a warning at freeque()
warning: context imbalance in freeque() - unexpected unlock
The root cause is the missing annotation at freeque()
Add the missing __releases(RCU) annotation Add the missing __releases(&msq->q_perm) annotation
--- ipc/msg.c | 2 ++ 1 file changed, 2 insertions(+)
ipc/msg.c +2 -0
@@ -268,6 +268,8 @@ static void expunge_all(struct msg_queue *msq, int res,* before freeque() is called. msg_ids.rwsem remains locked on exit. */ static void freeque (struct ipc_namespace *ns,struct kern_ipc_perm *ipcp) +__releases (RCU ) + __releases(&msq->q_perm) {struct msg_msg *msg, *t; struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm);
Signature · 1 line
2.24.1
PATCH 2/5 video: Add missing annotation for cyber2000fb_enable_ddc() and cyber2000fb_disable_ddc()
In reply to Jules IrengeSparse reports warnings at cyber2000fb_enable_ddc()
and cyber2000fb_disable_ddc()
warning: context imbalance in cyber2000fb_enable_ddc()
- wrong count at exit
warning: context imbalance in cyber2000fb_disable_ddc()
- unexpected unlock
The root cause is the missing annotation at cyber2000fb_enable_ddc()
and cyber2000fb_disable_ddc()
Add the missing __acquires(&cfb->reg_b0_lock) annotation Add the missing __releases(&cfb->reg_b0_lock) annotation
--- drivers/video/fbdev/cyber2000fb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/cyber2000fb.c +2 -0
@@ -1160,12 +1160,14 @@ EXPORT_SYMBOL(cyber2000fb_detach);#define DDC_SDA_IN (1 << 6)static void cyber2000fb_enable_ddc (struct cfb_info *cfb) + __acquires(&cfb->reg_b0_lock) {spin_lock (&cfb->reg_b0_lock);cyber2000fb_writew (0x1bf ,0x3ce , cfb); }static void cyber2000fb_disable_ddc (struct cfb_info *cfb) + __releases(&cfb->reg_b0_lock) {cyber2000fb_writew (0x0bf ,0x3ce , cfb);spin_unlock (&cfb->reg_b0_lock);
Signature · 1 line
2.24.1
Re: [PATCH 2/5] video: Add missing annotation for cyber2000fb_enable_ddc() and cyber2000fb_disable_ddc()
Hi Jules.
Quoted 9 lines · Jules Irenge
Sparse reports warnings at
cyber2000fb_enable_ddc()and cyber2000fb_disable_ddc()warning: context imbalance in
cyber2000fb_enable_ddc()
- wrong count at exitwarning: context imbalance in
cyber2000fb_disable_ddc()
- unexpected unlock
Quoted 7 lines
The root cause is the missing annotation at
cyber2000fb_enable_ddc()and cyber2000fb_disable_ddc()Add the missing
__acquires(&cfb->reg_b0_lock)annotation Add the missing__releases(&cfb->reg_b0_lock)annotationSigned-off-by Jules Irenge <[email protected]>
Thanks, added to drm-misc-next, so the patch will hit the kernel when the merge windows opens the next time.
Was this the only locking relevant warning in fbdev? I would expect a few more.
Sam
Quoted 30 lines
--- drivers/video/fbdev/cyber2000fb.c | 2 ++ 1 file changed, 2 insertions(+)drivers/video/fbdev/cyber2000fb.c +2
-0@@ -1160,12 +1160,14 @@ EXPORT_SYMBOL(cyber2000fb_detach);#define DDC_SDA_IN (1 << 6)static void cyber2000fb_enable_ddc (struct cfb_info *cfb) + __acquires(&cfb->reg_b0_lock) {spin_lock (&cfb->reg_b0_lock);cyber2000fb_writew (0x1bf ,0x3ce , cfb); }static void cyber2000fb_disable_ddc (struct cfb_info *cfb) + __releases(&cfb->reg_b0_lock) {cyber2000fb_writew (0x0bf ,0x3ce , cfb);spin_unlock (&cfb->reg_b0_lock);Signature · 6 lines
2.24.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 ocfs2: Add missing annotation for dlm_empty_lockres()
In reply to Jules IrengeSparse reports a warning at dlm_empty_lockres()
warning: context imbalance in dlm_purge_lockres() - unexpected unlock
The root cause is the missing annotation at dlm_purge_lockres()
Add the missing __must_hold(&dlm->spinlock)
--- fs/ocfs2/dlm/dlmmaster.c | 1 + 1 file changed, 1 insertion(+)
fs/ocfs2/dlm/dlmmaster.c +1 -0
@@ -2762,6 +2762,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,* Returns: 1 if dlm->spinlock was dropped/retaken, 0 if never dropped */ int dlm_empty_lockres (struct dlm_ctxt *dlm,struct dlm_lock_resource *res) + __must_hold(&dlm->spinlock) {int ret;int lock_dropped =0 ;
Signature · 1 line
2.24.1
Joseph Qi
maintainerRe: [PATCH 3/5] ocfs2: Add missing annotation for dlm_empty_lockres()
Quoted 8 lines · Jules Irenge
Sparse reports a warning at
dlm_empty_lockres()warning: context imbalance in
dlm_purge_lockres()- unexpected unlockThe root cause is the missing annotation at
dlm_purge_lockres()Add the missing
__must_hold(&dlm->spinlock)
Seems this is duplicate with assert_spin_locked()?
Thanks,
Joseph
Quoted 18 lines
Signed-off-by Jules Irenge <[email protected]>--- fs/ocfs2/dlm/dlmmaster.c | 1 + 1 file changed, 1 insertion(+)fs/ocfs2/dlm/dlmmaster.c +1
-0@@ -2762,6 +2762,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,* Returns: 1 if dlm->spinlock was dropped/retaken, 0 if never dropped */ int dlm_empty_lockres (struct dlm_ctxt *dlm,struct dlm_lock_resource *res) + __must_hold(&dlm->spinlock) {int ret;int lock_dropped =0 ;
Re: [PATCH 3/5] ocfs2: Add missing annotation for dlm_empty_lockres()
Quoted 10 lines · On Sat, 4 Apr 2020 07:45:49 +0800 Joseph Qi <[email protected]> wrote:
Quoted 8 lines · Jules Irenge
Sparse reports a warning at
dlm_empty_lockres()warning: context imbalance in
dlm_purge_lockres()- unexpected unlockThe root cause is the missing annotation at
dlm_purge_lockres()Add the missing
__must_hold(&dlm->spinlock)Seems this is duplicate with
assert_spin_locked()?
I doubt is sparse is smart enough to treat assert_spin_locked() as equivalent to __must_hold(). It would be neat though.
PATCH 4/5 libata: Add missing annotation for ata_scsi_rbuf_get() and ata_scsi_rbuf_fill()
In reply to Jules IrengeSparse reports a warning at ata_scsi_rbuf_fill() and ata_scsi_rbuf_get()
warning: context imbalance in ata_scsi_rbuf_get() - wrong count at exit
warning: context imbalance in ata_scsi_rbuf_fill() - unexpected unlock
The root cause is the missing annotation at ata_scsi_rbuf_fill()
and ata_scsi_rbuf_get()
Add the missing __acquires(&ata_scsi_rbuf_lock)
Add the missing __releases(&ata_scsi_rbuf_lock)
--- drivers/ata/libata-scsi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ata/libata-scsi.c +2 -0
@@ -2082,6 +2082,7 @@ struct ata_scsi_args {*/ static void *ata_scsi_rbuf_get (struct scsi_cmnd *cmd,bool copy_in,unsigned long *flags) + __acquires(&ata_scsi_rbuf_lock) {spin_lock_irqsave (&ata_scsi_rbuf_lock, *flags);
@@ -2106,6 +2107,7 @@ static void *ata_scsi_rbuf_get(struct scsi_cmnd *cmd, bool copy_in,*/ static inline void ata_scsi_rbuf_put (struct scsi_cmnd *cmd,bool copy_out,unsigned long *flags) + __releases(&ata_scsi_rbuf_lock) {if (copy_out) sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd),
Signature · 1 line
2.24.1
PATCH 5/5 ipmi: Add missing annotation for ipmi_ssif_lock_cond() and ipmi_ssif_unlock_cond()
In reply to Jules IrengeSparse reports a warning at ipmi_ssif_unlock_cond()
and ipmi_ssif_lock_cond()
warning: context imbalance in ipmi_ssif_lock_cond()
- wrong count at exit
warning: context imbalance in ipmi_ssif_unlock_cond()
- unexpected unlock
The root cause is the missing annotation at ipmi_ssif_unlock_cond()
and ipmi_ssif_lock_cond()
Add the missing __acquires(&ata_scsi_rbuf_lock)
Add the missing __releases(&ata_scsi_rbuf_lock)
--- drivers/char/ipmi/ipmi_ssif.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/char/ipmi/ipmi_ssif.c +2 -0
@@ -313,6 +313,7 @@ static int start_send(struct ssif_info *ssif_info,static unsigned long *ipmi_ssif_lock_cond (struct ssif_info *ssif_info,unsigned long *flags) + __acquires(&ssif_info->lock) {spin_lock_irqsave (&ssif_info->lock, *flags);return flags;
@@ -320,6 +321,7 @@ static unsigned long *ipmi_ssif_lock_cond(struct ssif_info *ssif_info,static void ipmi_ssif_unlock_cond (struct ssif_info *ssif_info,unsigned long *flags) + __releases(&ssif_info->lock) {spin_unlock_irqrestore (&ssif_info->lock, *flags); }
Signature · 1 line
2.24.1
Re: [PATCH 5/5] ipmi: Add missing annotation for ipmi_ssif_lock_cond() and ipmi_ssif_unlock_cond()
Quoted 8 lines · Jules Irenge
Sparse reports a warning at
ipmi_ssif_unlock_cond()
andipmi_ssif_lock_cond()warning: context imbalance in
ipmi_ssif_lock_cond()
- wrong count at exit
warning: context imbalance inipmi_ssif_unlock_cond()
- unexpected unlock
Quoted 5 lines
The root cause is the missing annotation at
ipmi_ssif_unlock_cond()
andipmi_ssif_lock_cond()Add the missing
__acquires(&ata_scsi_rbuf_lock)
Add the missing__releases(&ata_scsi_rbuf_lock)
Yeah, this is good, I've included it in my tree.
-corey
Quoted 29 lines
Signed-off-by Jules Irenge <[email protected]>--- drivers/char/ipmi/ipmi_ssif.c | 2 ++ 1 file changed, 2 insertions(+)drivers/char/ipmi/ipmi_ssif.c +2
-0@@ -313,6 +313,7 @@ static int start_send(struct ssif_info *ssif_info,static unsigned long *ipmi_ssif_lock_cond (struct ssif_info *ssif_info,unsigned long *flags) + __acquires(&ssif_info->lock) {spin_lock_irqsave (&ssif_info->lock, *flags);return flags;@@ -320,6 +321,7 @@ static unsigned long *ipmi_ssif_lock_cond(struct ssif_info *ssif_info,static void ipmi_ssif_unlock_cond (struct ssif_info *ssif_info,unsigned long *flags) + __releases(&ssif_info->lock) {spin_unlock_irqrestore (&ssif_info->lock, *flags); }Signature · 1 line
2.24.1