[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250901131714.646988-1-liaoyuanhong@vivo.com>
Date: Mon, 1 Sep 2025 21:17:13 +0800
From: Liao Yuanhong <liaoyuanhong@...o.com>
To: 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>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)),
"H. Peter Anvin" <hpa@...or.com>,
linux-perf-users@...r.kernel.org (open list:PERFORMANCE EVENTS SUBSYSTEM),
linux-kernel@...r.kernel.org (open list:PERFORMANCE EVENTS SUBSYSTEM)
Cc: Liao Yuanhong <liaoyuanhong@...o.com>
Subject: [PATCH] perf/x86/intel: Use guard() instead of mutex_lock() to simplify code
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>
---
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;
}
--
2.34.1
Powered by blists - more mailing lists