Re: [PATCH 1/3 v5] cleanup: Add cond_guard() to conditional guards

From: Jonathan Cameron
Date: Mon Feb 19 2024 - 06:51:18 EST


On Sat, 17 Feb 2024 11:59:02 +0100
"Fabio M. De Francesco" <fabio.maria.de.francesco@xxxxxxxxxxxxxxx> wrote:

> Add cond_guard() macro to conditional guards.
>
> cond_guard() is a guard to be used with the conditional variants of locks,
> like down_read_trylock() or mutex_lock_interruptible().
>
> It takes a statement (or statement-expression) that is passed as its
> second argument. That statement (or statement-expression) is executed if
> waiting for a lock is interrupted or if a _trylock() fails in case of
> contention.
>
> Usage example:
>
> cond_guard(mutex_intr, return -EINTR, &mutex);
>
> Consistent with other usage of _guard(), locks are unlocked at the exit of
> the scope where cond_guard() is called. This macro can be called multiple
> times in the same scope.
>
> Cc: Dave Jiang <dave.jiang@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Suggested-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> Suggested-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> Suggested-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@xxxxxxxxxxxxxxx>
Looks good.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>