From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
David Lechner <dlechner@baylibre.com>,
"Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>
Subject: Re: [PATCH v3 1/8] cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() for conditional locks
Date: Tue, 15 Jul 2025 16:34:40 +0100 [thread overview]
Message-ID: <20250715163440.00007849@huawei.com> (raw)
In-Reply-To: <20250711234932.671292-2-dan.j.williams@intel.com>
On Fri, 11 Jul 2025 16:49:25 -0700
Dan Williams <dan.j.williams@intel.com> wrote:
> From: Peter Zijlstra <peterz@infradead.org>
>
> scoped_cond_guard(), automatic cleanup for conditional locks, has a couple
> pain points:
>
> * It causes existing straight-line code to be re-indented into a new
> bracketed scope. While this can be mitigated by a new helper function
> to contain the scope, that is not always a comfortable conversion.
>
> * The return code from the conditional lock is tossed in favor of a scheme
> to pass a 'return err;' statement to the macro.
>
> Other attempts to clean this up, to behave more like guard() [1], got hung
> up trying to both establish and evaluate the conditional lock in one
> statement.
>
> ACQUIRE() solves this by reflecting the result of the condition in the
> automatic variable established by the lock CLASS(). The result is
> separately retrieved with the ACQUIRE_ERR() helper, effectively a PTR_ERR()
> operation.
>
> Link: http://lore.kernel.org/all/Z1LBnX9TpZLR5Dkf@gmail.com [1]
> Link: http://patch.msgid.link/20250512105026.GP4439@noisy.programming.kicks-ass.net
> Link: http://patch.msgid.link/20250512185817.GA1808@noisy.programming.kicks-ass.net
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: "Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>
> Signed-off-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> [djbw: wrap Peter's proposal with changelog and comments]
> Co-developed-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
LGTM and is definitely an improvement on all previous attempts to solve this.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
next prev parent reply other threads:[~2025-07-15 15:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-11 23:49 [PATCH v3 0/8] cleanup: Introduce ACQUIRE(), a guard() " Dan Williams
2025-07-11 23:49 ` [PATCH v3 1/8] cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() " Dan Williams
2025-07-15 15:34 ` Jonathan Cameron [this message]
2025-07-11 23:49 ` [PATCH v3 2/8] cxl/mbox: Convert poison list mutex to ACQUIRE() Dan Williams
2025-07-11 23:49 ` [PATCH v3 3/8] cxl/decoder: Move decoder register programming to a helper Dan Williams
2025-07-11 23:49 ` [PATCH v3 4/8] cxl/decoder: Drop pointless locking Dan Williams
2025-07-11 23:49 ` [PATCH v3 5/8] cxl/region: Split commit_store() into __commit() and queue_reset() helpers Dan Williams
2025-07-14 21:49 ` Fabio M. De Francesco
2025-07-11 23:49 ` [PATCH v3 6/8] cxl/region: Move ready-to-probe state check to a helper Dan Williams
2025-07-14 22:02 ` Fabio M. De Francesco
2025-07-15 15:33 ` Jonathan Cameron
2025-07-15 17:08 ` dan.j.williams
2025-07-11 23:49 ` [PATCH v3 7/8] cxl/region: Consolidate cxl_decoder_kill_region() and cxl_region_detach() Dan Williams
2025-07-14 18:17 ` Dave Jiang
2025-07-15 17:07 ` dan.j.williams
2025-07-14 22:09 ` Fabio M. De Francesco
2025-07-15 15:56 ` Jonathan Cameron
2025-07-15 16:44 ` dan.j.williams
2025-07-16 10:32 ` Jonathan Cameron
2025-07-11 23:49 ` [PATCH v3 8/8] cxl: Convert to ACQUIRE() for conditional rwsem locking Dan Williams
2025-07-14 16:28 ` Shiju Jose
2025-07-14 19:21 ` dan.j.williams
2025-07-14 18:39 ` Dave Jiang
2025-07-14 22:12 ` Fabio M. De Francesco
2025-07-15 16:20 ` Jonathan Cameron
2025-07-15 17:13 ` dan.j.williams
2025-07-15 17:38 ` Dave Jiang
2025-07-16 20:52 ` [PATCH v3 0/8] cleanup: Introduce ACQUIRE(), a guard() for conditional locks Dave Jiang
2025-07-30 15:10 ` Andy Shevchenko
2025-08-01 18:49 ` dan.j.williams
2025-08-01 19:02 ` Nathan Chancellor
2025-08-01 23:51 ` dan.j.williams
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=20250715163440.00007849@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dan.j.williams@intel.com \
--cc=dlechner@baylibre.com \
--cc=fabio.m.de.francesco@linux.intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®