lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250727032516.10063-1-wangqing7171@gmail.com>
Date: Sun, 27 Jul 2025 11:25:16 +0800
From: Qing Wong <wangqing7171@...il.com>
To: peterz@...radead.org,
	linux-kernel@...r.kernel.org
Cc: mingo@...nel.org,
	akpm@...ux-foundation.org,
	song@...nel.org,
	Qing Wang <wangqing7171@...il.com>
Subject: [PATCH] watchdog: Don't need a definition of the perf fallback-attr

From: Qing Wang <wangqing7171@...il.com>

The 'hardlockup_config_perf_event()' only overwrites the type and
config of the perf attr. It's wasteful that redefining a big static
variable to fallback. It’s just a matter of simply fallback these
two variables.

Signed-off-by: Qing Wang <wangqing7171@...il.com>
---
 kernel/watchdog_perf.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c
index 75af12ff774e..08b9acbd2aa4 100644
--- a/kernel/watchdog_perf.c
+++ b/kernel/watchdog_perf.c
@@ -92,14 +92,6 @@ static struct perf_event_attr wd_hw_attr = {
 	.disabled	= 1,
 };
 
-static struct perf_event_attr fallback_wd_hw_attr = {
-	.type		= PERF_TYPE_HARDWARE,
-	.config		= PERF_COUNT_HW_CPU_CYCLES,
-	.size		= sizeof(struct perf_event_attr),
-	.pinned		= 1,
-	.disabled	= 1,
-};
-
 /* Callback function for perf event subsystem */
 static void watchdog_overflow_callback(struct perf_event *event,
 				       struct perf_sample_data *data,
@@ -114,6 +106,12 @@ static void watchdog_overflow_callback(struct perf_event *event,
 	watchdog_hardlockup_check(smp_processor_id(), regs);
 }
 
+static void fallback_wd_hw_attr(void)
+{
+	wd_hw_attr.type = PERF_TYPE_HARDWARE;
+	wd_hw_attr.config = PERF_COUNT_HW_CPU_CYCLES;
+}
+
 static int hardlockup_detector_event_create(void)
 {
 	unsigned int cpu;
@@ -133,8 +131,7 @@ static int hardlockup_detector_event_create(void)
 	evt = perf_event_create_kernel_counter(wd_attr, cpu, NULL,
 					       watchdog_overflow_callback, NULL);
 	if (IS_ERR(evt)) {
-		wd_attr = &fallback_wd_hw_attr;
-		wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);
+		fallback_wd_hw_attr();
 		evt = perf_event_create_kernel_counter(wd_attr, cpu, NULL,
 						       watchdog_overflow_callback, NULL);
 	}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ