Re: [RFC PATCH] cleanup: Introduce "acquire"/"drop" cleanup helpers for interruptible locks

From: Linus Torvalds
Date: Fri May 02 2025 - 23:10:58 EST


On Fri, 2 May 2025 at 19:02, Dan Williams <dan.j.williams@xxxxxxxxx> wrote:
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index e3e851813c2a..cec9dfb22567 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -1394,8 +1394,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
> int nr_records = 0;
> int rc;
>
> - struct mutex *lock __drop(mutex_unlock) =
> - mutex_intr_acquire(&mds->poison.lock);
> + CLASS(mutex_intr_acquire, lock)(&mds->poison.lock);
> if (IS_ERR(lock))
> return PTR_ERR(lock);

Ok, so this whole CLASS-based model looks much better to me and fixes
my concerns.

Let's see if somebody else hates it, but I think this might be viable.

That said, I have to admit that it still looks pretty odd, but it does
look like something people can get used to.

Linus