From: <dan.j.williams@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
David Lechner <dlechner@baylibre.com>,
Peter Zijlstra <peterz@infradead.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
"Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>,
"Davidlohr Bueso" <dave@stgolabs.net>,
Dave Jiang <dave.jiang@intel.com>,
"Alison Schofield" <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Shiju Jose <shiju.jose@huawei.com>
Subject: Re: [PATCH v3 8/8] cxl: Convert to ACQUIRE() for conditional rwsem locking
Date: Tue, 15 Jul 2025 10:13:04 -0700 [thread overview]
Message-ID: <68768c20640c7_2ead10081@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20250715172035.00007f96@huawei.com>
Jonathan Cameron wrote:
> On Fri, 11 Jul 2025 16:49:32 -0700
> Dan Williams <dan.j.williams@intel.com> wrote:
>
> > Use ACQUIRE() to cleanup conditional locking paths in the CXL driver
> > The ACQUIRE() macro and its associated ACQUIRE_ERR() helpers, like
> > scoped_cond_guard(), arrange for scoped-based conditional locking. Unlike
> > scoped_cond_guard(), these macros arrange for an ERR_PTR() to be retrieved
> > representing the state of the conditional lock.
> >
> > The goal of this conversion is to complete the removal of all explicit
> > unlock calls in the subsystem. I.e. the methods to acquire a lock are
> > solely via guard(), scoped_guard() (for limited cases), or ACQUIRE(). All
> > unlock is implicit / scope-based. In order to make sure all lock sites are
> > converted, the existing rwsem's are consolidated and renamed in 'struct
> > cxl_rwsem'. While that makes the patch noisier it gives a clean cut-off
> > between old-world (explicit unlock allowed), and new world (explicit unlock
> > deleted).
> >
> > Cc: David Lechner <dlechner@baylibre.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: "Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>
> > Cc: Davidlohr Bueso <dave@stgolabs.net>
> > Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
> > Cc: Dave Jiang <dave.jiang@intel.com>
> > Cc: Alison Schofield <alison.schofield@intel.com>
> > Cc: Vishal Verma <vishal.l.verma@intel.com>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Shiju Jose <shiju.jose@huawei.com>
> > Acked-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>
> Two trivial comments inline.
>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index 4314aaed8ad8..ad60c93be803 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
>
> > static int attach_target(struct cxl_region *cxlr,
> > struct cxl_endpoint_decoder *cxled, int pos,
> > unsigned int state)
> > {
> > - int rc = 0;
> > -
> > - if (state == TASK_INTERRUPTIBLE)
> > - rc = down_write_killable(&cxl_region_rwsem);
> > - else
> > - down_write(&cxl_region_rwsem);
> > - if (rc)
> > - return rc;
> > -
> > - down_read(&cxl_dpa_rwsem);
> > - rc = cxl_region_attach(cxlr, cxled, pos);
> > - up_read(&cxl_dpa_rwsem);
> > - up_write(&cxl_region_rwsem);
> > + int rc = __attach_target(cxlr, cxled, pos, state);
> >
>
> ... (start of block for next comment)
>
> > - if (rc)
> > - dev_warn(cxled->cxld.dev.parent,
> > - "failed to attach %s to %s: %d\n",
> > - dev_name(&cxled->cxld.dev), dev_name(&cxlr->dev), rc);
> > + if (rc == 0)
> > + return 0;
> >
> > + dev_warn(cxled->cxld.dev.parent, "failed to attach %s to %s: %d\n",
> > + dev_name(&cxled->cxld.dev), dev_name(&cxlr->dev), rc);
>
> I'm not seeing a reason for this change. I prefer the original
> with the error path as the out of line case.
I prefer the out-dent of the message. I'll let Dave tie-break.
> > return rc;
> > }
>
>
> > @@ -3592,30 +3552,23 @@ static int cxl_region_can_probe(struct cxl_region *cxlr)
> ...
>
> > if (test_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags)) {
> > dev_err(&cxlr->dev,
> > "failed to activate, re-commit region and retry\n");
> > - rc = -ENXIO;
> > - goto out;
> > + return -ENXIO;
>
> return dev_err_probe(&cxlr->dev, -ENXIO,
> "failed to activate, re-commit region and retry\n");
>
> perhaps. I always like the cleanup.h stuff enabling this as it improves the patch
> line count no end ;)
I think that looks good, but perhaps as a follow-on cleanup?
next prev parent reply other threads:[~2025-07-15 17:13 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() for conditional locks 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
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 [this message]
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=68768c20640c7_2ead10081@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=dlechner@baylibre.com \
--cc=fabio.m.de.francesco@linux.intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=shiju.jose@huawei.com \
--cc=torvalds@linux-foundation.org \
--cc=vishal.l.verma@intel.com \
/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®