mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	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>
Subject: Re: [PATCH v2 2/8] cxl/mbox: Convert poison list mutex to ACQUIRE()
Date: Thu, 10 Jul 2025 15:25:50 -0700	[thread overview]
Message-ID: <68703dee2684a_588c100ae@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20250623110808.00003fcb@huawei.com>

Jonathan Cameron wrote:
> On Wed, 18 Jun 2025 22:04:10 -0700
> Dan Williams <dan.j.williams@intel.com> wrote:
> 
> > Towards removing all explicit unlock calls in the CXL subsystem, convert
> > the conditional poison list mutex to use a conditional lock guard.
> > 
> > Rename the lock to have the compiler validate that all existing call sites
> > are converted.
> > 
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > 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>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> 
> One trivial inline. Either way
> 
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> 
> > ---
> >  drivers/cxl/core/mbox.c | 7 +++----
> >  drivers/cxl/cxlmem.h    | 4 ++--
> >  2 files changed, 5 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > index 2689e6453c5a..81b21effe8cf 100644
> > --- a/drivers/cxl/core/mbox.c
> > +++ b/drivers/cxl/core/mbox.c
> > @@ -1401,8 +1401,8 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
> >  	int nr_records = 0;
> >  	int rc;
> >  
> > -	rc = mutex_lock_interruptible(&mds->poison.lock);
> > -	if (rc)
> > +	ACQUIRE(mutex_intr, lock)(&mds->poison.mutex);
> 
> I'd slightly prefer the 'canonical' style from the cleanup.h docs in previous patch.
> 
> 	rc = ACQUIRE_ERR(mutex_intr, &lock);
> 	if (rc)
> 		return rc;

I took a pass at that conversion before sending this out, but came back
to the inline assignment approach because the compactness matched the
familiar pattern with other error pointer handling.

The comfortable pattern with ERR_PTR() is:

	if (IS_ERR())
		return PTR_ERR();

The same could be done here with something like:

	if (ACQUIRE_ERR(@class, @lock))
		return ACQUIRE_ERR(@class, @lock))

...but that also feels like a mouthful especially if there is already a
local return code variable that can be used. So,

	if ((ret = ACQUIRE_ERR(@class, @lock))
		return ret;

...feel like a reasonable compromise for compactness on a common
pattern. Especially if cleanup helpers are also generally accepted as a
reason to bend the "variables declared at the top of scope" convention.

  reply	other threads:[~2025-07-10 22:26 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-19  5:04 [PATCH v2 0/8] cleanup: Introduce ACQUIRE(), a guard() for conditional locks Dan Williams
2025-06-19  5:04 ` [PATCH v2 1/8] cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() " Dan Williams
2025-06-19 21:17   ` Dan Williams
2025-06-23 10:05   ` Jonathan Cameron
2025-07-10 22:46     ` dan.j.williams
2025-06-19  5:04 ` [PATCH v2 2/8] cxl/mbox: Convert poison list mutex to ACQUIRE() Dan Williams
2025-06-20 20:43   ` Alison Schofield
2025-06-23 10:08   ` Jonathan Cameron
2025-07-10 22:25     ` dan.j.williams [this message]
2025-06-23 14:49   ` Dave Jiang
2025-06-19  5:04 ` [PATCH v2 3/8] cxl/decoder: Move decoder register programming to a helper Dan Williams
2025-06-20 21:00   ` Alison Schofield
2025-06-23 10:51   ` Jonathan Cameron
2025-06-23 14:50   ` Dave Jiang
2025-06-19  5:04 ` [PATCH v2 4/8] cxl/decoder: Drop pointless locking Dan Williams
2025-06-19 23:40   ` Davidlohr Bueso
2025-06-20 21:02   ` Alison Schofield
2025-06-23 10:53   ` Jonathan Cameron
2025-06-23 14:51   ` Dave Jiang
2025-06-19  5:04 ` [PATCH v2 5/8] cxl/region: Split commit_store() into __commit() and queue_reset() helpers Dan Williams
2025-06-20 21:32   ` Alison Schofield
2025-06-21  4:51     ` dan.j.williams
2025-06-23 10:59   ` Jonathan Cameron
2025-06-23 14:59   ` Dave Jiang
2025-06-19  5:04 ` [PATCH v2 6/8] cxl/region: Move ready-to-probe state check to a helper Dan Williams
2025-06-23 15:01   ` Dave Jiang
2025-06-19  5:04 ` [PATCH v2 7/8] cxl/region: Introduce CLASS(cxl_decoder_detach...) consolidate multiple paths Dan Williams
2025-06-23 10:49   ` Jonathan Cameron
2025-07-11  4:12     ` dan.j.williams
2025-06-19  5:04 ` [PATCH v2 8/8] cxl: Convert to ACQUIRE() for conditional rwsem locking Dan Williams
2025-06-23 10:32   ` Jonathan Cameron
2025-07-11  3:21     ` dan.j.williams
2025-06-19 11:13 ` [PATCH v2 0/8] cleanup: Introduce ACQUIRE(), a guard() for conditional locks Peter Zijlstra
2025-07-02 23:39 ` Alison Schofield
2025-07-11  4:28   ` 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=68703dee2684a_588c100ae@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=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --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®