All of lore.kernel.org
 help / color / mirror / Atom feed
* sparse warnings related to kref_put_lock() and refcount_dec_and_lock()
@ 2022-06-27 15:15 ` Alexander Aring
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2022-06-27 15:15 UTC (permalink / raw)
  To: linux-sparse; +Cc: cluster-devel

Hi,

I recently converted to use kref_put_lock() in fs/dlm subsystem and
now I get the following warning in sparse:

warning: context imbalance in 'put_rsb' - unexpected unlock

It seems sparse is not able to detect that there is a conditional
requirement that the lock passed to kref_put_lock() (or also
refcount_dec_and_lock()) is locked or not. I evaluate the return value
to check if kref_put_lock() helds the lock and unlock it then. The
idea is that the lock needs only to be held when the refcount is going
to be zero.

It seems other users unlock the lock at the release callback of
kref_put_lock() and annotate the callback with "__releases()" which
seems to work to avoid the sparse warning. However this works if you
don't have additional stack pointers which you need to pass to the
release callback.

My question would be is this a known problem and a recommended way to
avoid this sparse warning (maybe just for now)?

Thanks.

- Alex


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-06-29 14:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 15:15 sparse warnings related to kref_put_lock() and refcount_dec_and_lock() Alexander Aring
2022-06-27 15:15 ` [Cluster-devel] " Alexander Aring
2022-06-27 18:42 ` Luc Van Oostenryck
2022-06-27 18:42   ` [Cluster-devel] " Luc Van Oostenryck
2022-06-28  0:56   ` Alexander Aring
2022-06-28  0:56     ` [Cluster-devel] " Alexander Aring
2022-06-28  1:06     ` Alexander Aring
2022-06-28  1:06       ` [Cluster-devel] " Alexander Aring
2022-06-28  8:58       ` Luc Van Oostenryck
2022-06-28  8:58         ` [Cluster-devel] " Luc Van Oostenryck
2022-06-28 13:26         ` Alexander Aring
2022-06-28 13:26           ` [Cluster-devel] " Alexander Aring
2022-06-28 17:27         ` Linus Torvalds
2022-06-28 17:27           ` [Cluster-devel] " Linus Torvalds
2022-06-29 14:42           ` Alexander Aring
2022-06-29 14:42             ` [Cluster-devel] " Alexander Aring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.