[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d5062761-c00b-470c-ac01-08b9dd32329f@linux.intel.com>
Date: Tue, 2 Sep 2025 09:20:53 -0700
From: "Liang, Kan" <kan.liang@...ux.intel.com>
To: Liao Yuanhong <liaoyuanhong@...o.com>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>, Thomas Gleixner
<tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"open list:PERFORMANCE EVENTS SUBSYSTEM" <linux-perf-users@...r.kernel.org>,
"open list:PERFORMANCE EVENTS SUBSYSTEM" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] perf/x86/intel: Use guard() instead of mutex_lock() to
simplify code
On 2025-09-01 6:17 a.m., Liao Yuanhong wrote:
> Using guard(mutex) instead of mutex_lock/mutex_unlock pair. Simplifies the
> error handling to just return in case of error. No need for the 'done'
> label anymore so remove it.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@...o.com>
Reviewed-by: Kan Liang <kan.liang@...ux.intel.com>
Thanks,
Kan
> ---
> arch/x86/events/intel/core.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index 28f5468a6ea3..ac88d9535e85 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -6107,18 +6107,16 @@ static ssize_t freeze_on_smi_store(struct device *cdev,
> if (val > 1)
> return -EINVAL;
>
> - mutex_lock(&freeze_on_smi_mutex);
> + guard(mutex)(&freeze_on_smi_mutex);
>
> if (x86_pmu.attr_freeze_on_smi == val)
> - goto done;
> + return count;
>
> x86_pmu.attr_freeze_on_smi = val;
>
> cpus_read_lock();
> on_each_cpu(flip_smm_bit, &val, 1);
> cpus_read_unlock();
> -done:
> - mutex_unlock(&freeze_on_smi_mutex);
>
> return count;
> }
Powered by blists - more mailing lists