From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Aring <aahringo@redhat.com>
Cc: will@kernel.org, boqun.feng@gmail.com, mark.rutland@arm.com,
thunder.leizhen@huawei.com, jacob.e.keller@intel.com,
akpm@linux-foundation.org, linux-sparse@vger.kernel.org,
cluster-devel@redhat.com, luc.vanoostenryck@gmail.com,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC 1/2] refcount: add __cond_lock() for conditional lock refcount API
Date: Thu, 30 Jun 2022 17:43:20 +0200 [thread overview]
Message-ID: <Yr3EmEcO1AMFRlLA@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20220630135934.1799248-2-aahringo@redhat.com>
On Thu, Jun 30, 2022 at 09:59:33AM -0400, Alexander Aring wrote:
> This patch adds the __cond_lock() macro to refcounts conditional lock
> API. Currently sparse cannot detect the conditional lock handling of
> refcount_dec_and_lock() functionality and prints a context imbalance
> warning like:
>
> warning: context imbalance in 'put_rsb' - unexpected unlock
>
> with this patch and having the refcount_dec_and_lock() functionality
> inside the if condition to decide whenever doing unlock or not the
> warning disappears.
>
> The patch follows a similar naming scheme like raw_spin_trylock() by
> adding a "raw_" prefix to refcount_dec_and_lock() functionality and
> introduce a macro for the replaced functions that uses __cond_lock()
> to signal that an acquire depends on the return value of the passed
> function.
>
> A cast to bool seems to be necessary because __cond_lock() does return a
> non-boolean scalar type.
I hate the __cond_lock() think with a passions. Please just fix sparse
to not suck.
next prev parent reply other threads:[~2022-06-30 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 13:59 [RFC 0/2] refcount: attempt to avoid imbalance warnings Alexander Aring
2022-06-30 13:59 ` [RFC 1/2] refcount: add __cond_lock() for conditional lock refcount API Alexander Aring
2022-06-30 15:43 ` Peter Zijlstra [this message]
2022-06-30 13:59 ` [RFC 2/2] kref: move kref_put_lock() callback to caller Alexander Aring
2022-06-30 16:34 ` [RFC 0/2] refcount: attempt to avoid imbalance warnings Linus Torvalds
2022-07-01 8:47 ` Peter Zijlstra
2022-07-01 12:07 ` Alexander Aring
2022-07-01 19:09 ` Alexander Aring
2025-02-08 2:52 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yr3EmEcO1AMFRlLA@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aahringo@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=boqun.feng@gmail.com \
--cc=cluster-devel@redhat.com \
--cc=jacob.e.keller@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=mark.rutland@arm.com \
--cc=thunder.leizhen@huawei.com \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox