From nobody Wed Apr 15 04:37:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CCD1C19F21 for ; Wed, 27 Jul 2022 03:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240246AbiG0DPM (ORCPT ); Tue, 26 Jul 2022 23:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240120AbiG0DPI (ORCPT ); Tue, 26 Jul 2022 23:15:08 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 868EB3CBFC; Tue, 26 Jul 2022 20:15:04 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 8B8FE1E80D54; Wed, 27 Jul 2022 11:15:15 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05eI2f5kp0in; Wed, 27 Jul 2022 11:15:12 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: yuzhe@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id C0AFD1E80D05; Wed, 27 Jul 2022 11:15:11 +0800 (CST) From: Yu Zhe To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, liqiong@nfschina.com, Yu Zhe Subject: [PATCH] x86/aperfmperf: use time_is_before_jiffies(a + b) to replace "jiffies - a > b" Date: Wed, 27 Jul 2022 11:14:05 +0800 Message-Id: <20220727031405.26892-1-yuzhe@nfschina.com> X-Mailer: git-send-email 2.11.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" time_is_before_jiffies deals with timer wrapping correctly. Signed-off-by: Yu Zhe --- arch/x86/kernel/cpu/aperfmperf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmp= erf.c index 1f60a2b27936..22e0bac3fffe 100644 --- a/arch/x86/kernel/cpu/aperfmperf.c +++ b/arch/x86/kernel/cpu/aperfmperf.c @@ -423,7 +423,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_is_before_jiffies(last + MAX_SAMPLE_AGE)) goto fallback; =20 return div64_u64((cpu_khz * acnt), mcnt); --=20 2.11.0