Re: [PATCH] kernel: locking: add releases(lock) annotation

From: Jules Irenge
Date: Thu Feb 06 2020 - 09:59:30 EST




On Tue, 17 Dec 2019, Peter Zijlstra wrote:

> On Mon, Dec 16, 2019 at 03:39:52PM +0000, Jules Irenge wrote:
> > Add releases(lock) annotation to remove issue detected by sparse tool.
> > warning: context imbalance in xxxxxxx() - unexpected unlock
> >
> > Signed-off-by: Jules Irenge <jbi.octave@xxxxxxxxx>
>
> So, personally I detest these sparse things.
>
> But I'm also confused, as that function already has the annotation, see
> spinlock_api_smp.h. In order for sparse to see these annotations at the
> usage size, they need to be on the declaration, not the definition.
>

Yes, I completely agree with you, but acording to my short experience
with Sparse, the warning at function definition will always be there
despite the annotation being at the function declaration.

The annotation at declaration help fix the warning when the anotated
function is called within another function, this function can be
elsewhere. It fixes the warning at the function within which the
annotated function has been called.

Please correct me if I am wrong.

Kind regards,
Jules