mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf/x86/intel: Use guard() instead of mutex_lock() to simplify code
@ 2025-09-01 13:17 Liao Yuanhong
  2025-09-02 16:20 ` Liang, Kan
  2025-09-02 16:54 ` Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: Liao Yuanhong @ 2025-09-01 13:17 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Thomas Gleixner,
	Borislav Petkov, Dave Hansen,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	H. Peter Anvin, open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM
  Cc: Liao Yuanhong

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@vivo.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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-02 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-01 13:17 [PATCH] perf/x86/intel: Use guard() instead of mutex_lock() to simplify code Liao Yuanhong
2025-09-02 16:20 ` Liang, Kan
2025-09-02 16:54 ` Markus Elfring

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®