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: <20240826034538.8225-1-chenyufan@vivo.com>
Date: Mon, 26 Aug 2024 11:45:36 +0800
From: Chen Yufan <chenyufan@...o.com>
To: Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	x86@...nel.org,
	"H. Peter Anvin" <hpa@...or.com>,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>,
	Chen Yufan <chenyufan@...o.com>,
	Phil Auld <pauld@...hat.com>,
	Tony Luck <tony.luck@...el.com>,
	linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com
Subject: [PATCH v3] x86/aperfmperf: Use time_after() for jiffies comparison

Use time_after() instead of using
jiffies directly to handle wraparound.

Signed-off-by: Chen Yufan <chenyufan@...o.com>
---
The modifications made compared to the previous version are as follows:
1. Remove extra '+' in the header.
2. Change the subject and description for clarity.
---
 arch/x86/kernel/cpu/aperfmperf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 0b69bfbf345d..2772cc166b1b 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -16,6 +16,7 @@
 #include <linux/sched/topology.h>
 #include <linux/smp.h>
 #include <linux/syscore_ops.h>
+#include <linux/jiffies.h>
 
 #include <asm/cpu.h>
 #include <asm/cpu_device_id.h>
@@ -434,7 +435,7 @@ unsigned int arch_freq_get_on_cpu(int cpu)
 	 * Bail on invalid count and when the last update was too long ago,
 	 * which covers idle and NOHZ full CPUs.
 	 */
-	if (!mcnt || (jiffies - last) > MAX_SAMPLE_AGE)
+	if (!mcnt || time_after(jiffies, last + MAX_SAMPLE_AGE))
 		goto fallback;
 
 	return div64_u64((cpu_khz * acnt), mcnt);
-- 
2.39.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ