From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CDEF3A3E8D; Fri, 10 Apr 2026 12:18:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823516; cv=none; b=mV1EwIWrnJjKV4EN0w82wQhK11qezHqqED77RRYJ1/82o7EczF5P//rhn8aqmaLZhK0/GLwShT3E3Tn7Y3YaHF8Ckn7/gZpdakiowsYYzRC0+tx3wZPsYXY65MjUNYEHknXeZE7FrKIdc1UE/g3FR8gosbq1elgZD2CWuLPI8V0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823516; c=relaxed/simple; bh=Qxe5s7KoLSq5kG1N2smycXiRWybB8taeJTlNsbfy0fg=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=SuYLMO6gKlYYvAnjNGuRqiJ1pqLOOSrsBWh/ho6wjg28d+dFAU98jwoW55HsI1Vo9BBL6pZWqXbP75Ot9vOnl+jSewq0Cb3eDtr1wFOcbn4/eWCwK1LuXA74f2tw97ebuWz8tftzHX/ItaYBZR71Ve7WfuvG4DT598LWvUeYB+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PujwWQLA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PujwWQLA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DF48C2BC87; Fri, 10 Apr 2026 12:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823515; bh=Qxe5s7KoLSq5kG1N2smycXiRWybB8taeJTlNsbfy0fg=; h=Date:From:To:Cc:Subject:References:From; b=PujwWQLA2dOIyLlZvIM0oB1Wg7c5ZIyCwzH/XHGNRGehg+YFil6OmFstHyfDwz6a4 UXi7viGoUKPW4HP65M0H75qRplTYAji9Z6ikhUQOkcZXvM13Netjmq5O6I/+9+JQ+w bxUrL+dmChTEREYE3VSmYBwXmygVivr7jmb4e0itrCIHXq31ae3WiG49uZ0Z2PTGdc +od1M1yaD34oi/oFSPoyZ73JAQOxw0kf9oLJ4YVR9wqn75mlEWMpZuBIxST6yrXcHs fYRNY0LFjGxQtZU4+RTQobyzbJWEzJNsARBCqXSJyY40dbr06WXMHmkuYa6yNGx2XV 5kZ5/s9dunCZA== Date: Fri, 10 Apr 2026 14:18:32 +0200 Message-ID: <20260410120317.642797961@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 01/38] percpu: Sanitize __percpu_qual include hell References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Slapping __percpu_qual into the next available header is sloppy at best. It's required by __percpu which is defined in compiler_types.h and that is meant to be included without requiring a boatload of other headers so that a struct or function declaration can contain a __percpu qualifier w/o further prerequisites. This implicit dependency on linux/percpu.h makes that impossible and causes a major problem when trying to seperate headers. Create asm/percpu_types.h and move it there. Include that from compiler_types.h and the whole recursion problem goes away. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/percpu.h | 5 ----- arch/x86/include/asm/percpu_types.h | 17 +++++++++++++++++ include/asm-generic/Kbuild | 1 + include/asm-generic/percpu_types.h | 20 ++++++++++++++++++++ include/linux/compiler_types.h | 1 + 5 files changed, 39 insertions(+), 5 deletions(-) --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -40,12 +40,10 @@ #endif =20 #define __percpu_prefix -#define __percpu_seg_override CONCATENATE(__seg_, __percpu_seg) =20 #else /* !CONFIG_CC_HAS_NAMED_AS: */ =20 #define __percpu_prefix __force_percpu_prefix -#define __percpu_seg_override =20 #endif /* CONFIG_CC_HAS_NAMED_AS */ =20 @@ -82,7 +80,6 @@ =20 #define __force_percpu_prefix #define __percpu_prefix -#define __percpu_seg_override =20 #define PER_CPU_VAR(var) (var)__percpu_rel =20 @@ -92,8 +89,6 @@ # define __my_cpu_type(var) typeof(var) # define __my_cpu_ptr(ptr) (ptr) # define __my_cpu_var(var) (var) - -# define __percpu_qual __percpu_seg_override #else # define __my_cpu_type(var) typeof(var) __percpu_seg_override # define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) --- /dev/null +++ b/arch/x86/include/asm/percpu_types.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_PERCPU_TYPES_H +#define _ASM_X86_PERCPU_TYPES_H + +#if defined(CONFIG_SMP) && defined(CONFIG_CC_HAS_NAMED_AS) +#define __percpu_seg_override CONCATENATE(__seg_, __percpu_seg) +#else /* !CONFIG_CC_HAS_NAMED_AS: */ +#define __percpu_seg_override +#endif + +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(USE_TYPEOF_UNQUAL) +#define __percpu_qual __percpu_seg_override +#endif + +#include + +#endif --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild @@ -44,6 +44,7 @@ mandatory-y +=3D module.lds.h mandatory-y +=3D msi.h mandatory-y +=3D pci.h mandatory-y +=3D percpu.h +mandatory-y +=3D percpu_types.h mandatory-y +=3D pgalloc.h mandatory-y +=3D preempt.h mandatory-y +=3D rqspinlock.h --- /dev/null +++ b/include/asm-generic/percpu_types.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_PERCPU_TYPES_H_ +#define _ASM_GENERIC_PERCPU_TYPES_H_ + +#ifndef __ASSEMBLER__ +/* + * __percpu_qual is the qualifier for the percpu named address space. + * + * Most arches use generic named address space for percpu variables but + * some arches define percpu variables in different named address space + * (on the x86 arch, percpu variable may be declared as being relative + * to the %fs or %gs segments using __seg_fs or __seg_gs named address + * space qualifier). + */ +#ifndef __percpu_qual +# define __percpu_qual +#endif + +#endif /* __ASSEMBLER__ */ +#endif /* _ASM_GENERIC_PERCPU_TYPES_H_ */ --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -41,6 +41,7 @@ # define BTF_TYPE_TAG(value) /* nothing */ #endif =20 +#include #include =20 /* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */ From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CC5022F74A; Fri, 10 Apr 2026 12:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823521; cv=none; b=rqDXxwY3QsOmPxBqBxDSsmhaXwcybcXv/3KOpb/6EIz2tuKNLb4AWC5MsAFvGRMc3DmKLvXua4qll058VjQtjbXjBsckGEggreaz7GySGURrrtDu1efcZpD3BFkUsj8N719z3W40UJ31h5HFouj8iazoTDUi/mzmhvobvrrzonI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823521; c=relaxed/simple; bh=jM+JreNQ/pvWEKCuy6rQc5u1kgCA5N5UN7yUgNovu14=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=HMORE5MdVT7OUsMYXeSSOHyQyRGbVAkusslY/N2X6eNYxnSlcZ9E2C/zyzGJC0KiLhwLaVUIyJZDZLGzNurhPeyXlkclrFbMGa2T3VwVLlPxs+wYOC2K5ot7lbmbHodkrkhaKZf7pX5pKeBn4HZIFGl66vzqwQz31Z8Z1+cXx+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nWtTU/8b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nWtTU/8b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34709C2BC87; Fri, 10 Apr 2026 12:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823521; bh=jM+JreNQ/pvWEKCuy6rQc5u1kgCA5N5UN7yUgNovu14=; h=Date:From:To:Subject:References:cc:From; b=nWtTU/8bYflAI0sVDZCcTSRoMHHBafK4f8aE8OQUIADFXrWn3gkAS6D8iyeDcGytD IkAJ7wfDdphIDTv0/p2VgJLmG6txpPJj7VHjB28F0wfKCyzE07p6hHvScSQ/hPg40n m5UonCXCWoABi9Y1P5pL07/VfBtvxj5IX/qtz/8nDDpNNssj+hm09ux1rli9d/5Kp7 u2W39VabHnp7xFO01m/Vf4vbZzsQaYVQbm/v4/bBGJXSthxziJGUNQp6cLMMBeBrVY Rxdzr0TBEmAzR1XxM10SdBatX0CJ8cwLuQKU2F/sGImGk9kogedHCPTsKBS8t/RjVc cuRhduaM+Iuqw== Date: Fri, 10 Apr 2026 14:18:37 +0200 Message-ID: <20260410120317.709923681@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 02/38] x86: Cleanup include recursion hell References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Including a random architecture specific header which requires global headers just to avoid including that header at the two usage sites is really beyond lazy and tasteless. Including global headers just to get the __percpu macro from linux/compiler_types.h falls into the same category. Remove the linux/percpu.h and asm/cpumask.h includes from msr.h and smp.h and fix the resulting fallout by a simple forward struct declaration and by including the x86 specific asm/cpumask.h header where it is actually required. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/msr.h | 5 +++-- arch/x86/include/asm/pvclock.h | 1 + arch/x86/include/asm/smp.h | 2 -- arch/x86/include/asm/vdso/gettimeofday.h | 5 ++--- arch/x86/kernel/cpu/mce/core.c | 1 + arch/x86/kernel/nmi.c | 1 + arch/x86/kernel/smpboot.c | 1 + 7 files changed, 9 insertions(+), 7 deletions(-) --- a/arch/x86/include/asm/msr.h +++ b/arch/x86/include/asm/msr.h @@ -8,12 +8,11 @@ =20 #include #include -#include #include #include =20 +#include #include -#include =20 struct msr_info { u32 msr_no; @@ -256,6 +255,8 @@ int msr_set_bit(u32 msr, u8 bit); int msr_clear_bit(u32 msr, u8 bit); =20 #ifdef CONFIG_SMP +struct cpumask; + int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); int rdmsrq_on_cpu(unsigned int cpu, u32 msr_no, u64 *q); --- a/arch/x86/include/asm/pvclock.h +++ b/arch/x86/include/asm/pvclock.h @@ -2,6 +2,7 @@ #ifndef _ASM_X86_PVCLOCK_H #define _ASM_X86_PVCLOCK_H =20 +#include #include #include =20 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -5,8 +5,6 @@ #include #include =20 -#include - DECLARE_PER_CPU_CACHE_HOT(int, cpu_number); =20 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map); --- a/arch/x86/include/asm/vdso/gettimeofday.h +++ b/arch/x86/include/asm/vdso/gettimeofday.h @@ -11,13 +11,12 @@ #define __ASM_VDSO_GETTIMEOFDAY_H =20 #ifndef __ASSEMBLER__ - +#include #include + #include #include -#include #include -#include #include =20 #define VDSO_HAS_TIME 1 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -48,6 +48,7 @@ #include =20 #include +#include #include #include #include --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -26,6 +26,7 @@ #include #include =20 +#include #include #include #include --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C0613BE641; Fri, 10 Apr 2026 12:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823526; cv=none; b=d+0G3opLrnTDTxnRRnCeBqrNjRHTlu5iL3dUtgwQJAxS/F2R8+k6kSXE25K/32/Y8YnPewP7AumrzS4NtrAprBJ5JkAJ1skRVTQ3+nb2Q/6iXrGFCBgmwxD5iviZJkqaSC6je3qKuLYv+wj/RXoA70mLCvK4xvoTEVVIYAEpBPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823526; c=relaxed/simple; bh=OWF9pG0hQ95RygMnh7+vDhgeHyKnJRYOWEj0GBEdTEY=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=OKMh6y6fSS910YwmmiPAxypbiUB1DxEjJ5wW23jEBHA2z45tNB+tamOFJ/+eiIkjHg/kfp2YozPwHWNlzX7FHKnb/hxmZ+2lPXP4kQ9DM8TYunRqORTLToK480cY3+8GXwAmrCIkMKHcz1RyxLYqImQXYPgkb3Uh3tbYvlbjfHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gYJITPmd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gYJITPmd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51EC1C2BCB0; Fri, 10 Apr 2026 12:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823526; bh=OWF9pG0hQ95RygMnh7+vDhgeHyKnJRYOWEj0GBEdTEY=; h=Date:From:To:Subject:References:cc:From; b=gYJITPmdy2GNPsbI6AD2iZ7zhMgePGS+gqPbXQCs7WsAhhu/qyX8hH+Xi69K/urPl BoSeBlt4BbqU4ZnISQ8slAdj5VCjiDRcN9bfEzsBBE9dj/wWUHwDFECfvHb21gTPQ5 cvjmyUKF+jJ25R6iZ5vAzO3xaA8XXwp+1aea+F9V1esc/zHHX5PN7paJBTByHcDBl2 auQKRV9dXMsXdujNzqathwxe2n8RWyCswG/DXqH2EllhOxm/ndPsrTIJX4WzacriA/ t/DalYn89VnEQy6E+ROiviOqorgI/E12LPFkiSGiJSdwmaaiky6k8Wx7OG7Y+w6GUr Ni5ruNMG7XCYg== Date: Fri, 10 Apr 2026 14:18:42 +0200 Message-ID: <20260410120317.776571540@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 03/38] x86/apm: Remove last LATCH usage References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" LATCH is a historical leftover and has been replaced with PIT_LATCH in all other places a decade ago. Replace the last holdout and remove the definition from jiffies.h. This allows to remove the otherwise unused CLOCK_TICK_RATE define in the next step. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apm_32.c | 4 ++-- include/linux/jiffies.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c @@ -1196,9 +1196,9 @@ static void reinit_timer(void) /* set the clock to HZ */ outb_p(0x34, PIT_MODE); /* binary, mode 2, LSB/MSB, ch 0 */ udelay(10); - outb_p(LATCH & 0xff, PIT_CH0); /* LSB */ + outb_p(PIT_LATCH & 0xff, PIT_CH0); /* LSB */ udelay(10); - outb_p(LATCH >> 8, PIT_CH0); /* MSB */ + outb_p(PIT_LATCH >> 8, PIT_CH0); /* MSB */ udelay(10); raw_spin_unlock_irqrestore(&i8253_lock, flags); #endif --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -56,9 +56,6 @@ #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / = (DEN)) =20 -/* LATCH is used in the interval timer and ftape setup. */ -#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ - extern void register_refined_jiffies(long clock_tick_rate); =20 /* TICK_USEC is the time between ticks in usec */ From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 907A13C1978; Fri, 10 Apr 2026 12:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823531; cv=none; b=mDk65ggUWxBydJz3x0nmAdBCnQndeaYnQKXnClJqUUV6bkEAVoeHA80K4p2Fx/uJTGO32qIXUsVOAUjri6/tmjrsFcrqmMkTpzO5vEmU2z/I6x0zGdRqgGz1yRD2PD6hEPumvDcWq2A5XqI1j+8+451p11y2kVF9Y6XP0fECaVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823531; c=relaxed/simple; bh=d9g4tptgi4bHAMeSUYU/X2RKjwFUxFqrN/mhP3KVNVE=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=CTZdikNibaQEV3BkLOvgJp6nd2ucYLrNkwoLfv53ZSbsgmd9LCo+FovOPxRqiAhur5rSqEqY7JCKVMAMF/TVF2RCRmT2uQSycsVcwjB//O3Sr4gxGsD71sRmD50Kx8c+peSKwPwDTiNpyHXi3WHncVew8GxsZgppktAAkHZzwLM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C95dlBh1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C95dlBh1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41928C2BCAF; Fri, 10 Apr 2026 12:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823531; bh=d9g4tptgi4bHAMeSUYU/X2RKjwFUxFqrN/mhP3KVNVE=; h=Date:From:To:Subject:References:cc:From; b=C95dlBh11sE1EDcg7WkfMi8fo/Gu65tTzE/T1Srv47O6KGVj91UAmlXjU/FculsKY awynI69i3I7OzFyIZRoLHG74aENkFw6rGItybhxSqe437lYLBTdjTVnjO/BdcaqFmm BXfUg/n2zRCzaQYn/z/fsuHLl0WmkcWVFMRkJhLQ5RkhTFRVvrz/UodergNNz9SIp4 BVs5UNoonypUPXLwnttDKrM12mG46vN5EiYmDA6MeZqU6JoMxzzH1xMf+HYNN+Suws 7vEfC+JysbP6o62RQk33gA7qFJeSKzf6pdk/9/gi1eWOgpyfVkfoVSPrkQiIoyiqxd pjPaBhdVrzMKA== Date: Fri, 10 Apr 2026 14:18:47 +0200 Message-ID: <20260410120317.843419270@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 04/38] x86: Use PIT_TICK_RATE instead of CLOCK_TICK_RATE References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" CLOCK_TICK_RATE is only used in x86 but defined all over the tree for no reason with comments that it's scheduled for removal for more than a decade. Use PIT_TICK_RATE for registering refined jiffies to get rid of the last dependency. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1268,7 +1268,7 @@ void __init setup_arch(char **cmdline_p) =20 mcheck_init(); =20 - register_refined_jiffies(CLOCK_TICK_RATE); + register_refined_jiffies(PIT_TICK_RATE); =20 #ifdef CONFIG_EFI if (efi_enabled(EFI_BOOT)) From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B9A3BD64E; Fri, 10 Apr 2026 12:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823536; cv=none; b=W1Qr3EFm5UGIa8+7VGnvp+jyjq5XcRJmCSUT3OjmmaLcA7t1LGusJKtmdnEL/coTVvLqd3A/QvbHhvQsPsfRtj/zh3JZIdy7/4XefjCy31AB/F81YjtOBJ6DotylwWSk35xFRGUR1yM2OPQVL8rYqSxiBeNYBpEqT3colElxGSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823536; c=relaxed/simple; bh=5QVlF6IfS2lfQjmpis0ghbno4R+SPdTSC+UKXWlrbwM=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=s+jMIW8X6tv3SR24xiHvCQIVb+RnsoalvkJ5hSvifaCBT8VZmF5FUBosC33gZrsItSzgWWQzimEbjDTQCv95E7wfNws8fbCoRG/BlSh6MBYeikgyplc/qkgUluYJSbGi638+SpUIAfpx4JK2ZRDii0yvyWjFuyfqNtBrQQPIL98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LfuXj06c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LfuXj06c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ABB2C2BCB0; Fri, 10 Apr 2026 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823536; bh=5QVlF6IfS2lfQjmpis0ghbno4R+SPdTSC+UKXWlrbwM=; h=Date:From:To:Subject:References:cc:From; b=LfuXj06c5pJdrLIRQZOGGUnvC0/7H7T958xB88dpTHpJCnzTPWKuOvuVXAdy6Ak37 q3NsmsuJzmcCS4AtrQC6BBqMKLBV6i7NYvY31kVUwAJ1fUk5DiH1UvcZhqx6Zvfgxu CGnnZL59E7B5pPEKoSA2vv7lFrz68ryBNvlt7/he9gTUf+7cGk/WAoXUpUjNZe0UmE dP1W1cGxClFkhCm5BU3vACeJkyoHuX3oJ0uOmck90IwaQnQkpQKPURmYasy2VBvUvQ oOQV5XFs6UHn87rkBmH0n2LYh6YtwROpX/B/rCdI1TFAoh7Z5miPuEptvyhsFFD5GH nRoQ9tRI1uYXg== Date: Fri, 10 Apr 2026 14:18:52 +0200 Message-ID: <20260410120317.910770161@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 05/38] treewide: Remove CLOCK_TICK_RATE References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This has been scheduled for removal more than a decade ago and the comments related to it have been dutifully ignored. The last dependencies are gone. Remove it along with various now empty asm/timex.h files. Signed-off-by: Thomas Gleixner Acked-by: Geert Uytterhoeven # m68k Reviewed-by: Christophe Leroy (CS GROUP) --- arch/alpha/include/asm/timex.h | 4 ---- arch/arc/include/asm/timex.h | 15 --------------- arch/arm/mach-omap1/Kconfig | 2 +- arch/hexagon/include/asm/timex.h | 3 --- arch/m68k/include/asm/timex.h | 15 --------------- arch/microblaze/include/asm/timex.h | 13 ------------- arch/mips/include/asm/timex.h | 8 -------- arch/openrisc/include/asm/timex.h | 3 --- arch/parisc/include/asm/timex.h | 2 -- arch/powerpc/include/asm/timex.h | 2 -- arch/s390/include/asm/timex.h | 2 -- arch/sh/include/asm/timex.h | 24 ------------------------ arch/sparc/include/asm/timex.h | 2 +- arch/sparc/include/asm/timex_32.h | 14 -------------- arch/sparc/include/asm/timex_64.h | 2 -- arch/um/include/asm/timex.h | 9 --------- arch/x86/include/asm/timex.h | 3 --- 17 files changed, 2 insertions(+), 121 deletions(-) --- a/arch/alpha/include/asm/timex.h +++ b/arch/alpha/include/asm/timex.h @@ -7,10 +7,6 @@ #ifndef _ASMALPHA_TIMEX_H #define _ASMALPHA_TIMEX_H =20 -/* With only one or two oddballs, we use the RTC as the ticker, selecting - the 32.768kHz reference clock, which nicely divides down to our HZ. */ -#define CLOCK_TICK_RATE 32768 - /* * Standard way to access the cycle counter. * Currently only used on SMP for scheduling. --- a/arch/arc/include/asm/timex.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.c= om) - */ - -#ifndef _ASM_ARC_TIMEX_H -#define _ASM_ARC_TIMEX_H - -#define CLOCK_TICK_RATE 80000000 /* slated to be removed */ - -#include - -/* XXX: get_cycles() to be implemented with RTSC insn */ - -#endif /* _ASM_ARC_TIMEX_H */ --- a/arch/arm/mach-omap1/Kconfig +++ b/arch/arm/mach-omap1/Kconfig @@ -74,7 +74,7 @@ config OMAP_32K_TIMER currently only available for OMAP16XX, 24XX, 34XX, OMAP4/5 and DRA7XX. =20 On OMAP2PLUS this value is only used for CONFIG_HZ and - CLOCK_TICK_RATE compile time calculation. + timer frequency compile time calculation. The actual timer selection is done in the board file through the (DT_)MACHINE_START structure. =20 --- a/arch/hexagon/include/asm/timex.h +++ b/arch/hexagon/include/asm/timex.h @@ -9,9 +9,6 @@ #include #include =20 -/* Using TCX0 as our clock. CLOCK_TICK_RATE scheduled to be removed. */ -#define CLOCK_TICK_RATE 19200 - #define ARCH_HAS_READ_CURRENT_TIMER =20 static inline int read_current_timer(unsigned long *timer_val) --- a/arch/m68k/include/asm/timex.h +++ b/arch/m68k/include/asm/timex.h @@ -7,21 +7,6 @@ #ifndef _ASMm68K_TIMEX_H #define _ASMm68K_TIMEX_H =20 -#ifdef CONFIG_COLDFIRE -/* - * CLOCK_TICK_RATE should give the underlying frequency of the tick timer - * to make ntp work best. For Coldfires, that's the main clock. - */ -#include -#define CLOCK_TICK_RATE MCF_CLK -#else -/* - * This default CLOCK_TICK_RATE is probably wrong for many 68k boards - * Users of those boards will need to check and modify accordingly - */ -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ -#endif - typedef unsigned long cycles_t; =20 static inline cycles_t get_cycles(void) --- a/arch/microblaze/include/asm/timex.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (C) 2006 Atmark Techno, Inc. - */ - -#ifndef _ASM_MICROBLAZE_TIMEX_H -#define _ASM_MICROBLAZE_TIMEX_H - -#include - -#define CLOCK_TICK_RATE 1000 /* Timer input freq. */ - -#endif /* _ASM_TIMEX_H */ --- a/arch/mips/include/asm/timex.h +++ b/arch/mips/include/asm/timex.h @@ -19,14 +19,6 @@ #include =20 /* - * This is the clock rate of the i8253 PIT. A MIPS system may not have - * a PIT by the symbol is used all over the kernel including some APIs. - * So keeping it defined to the number for the PIT is the only sane thing - * for now. - */ -#define CLOCK_TICK_RATE 1193182 - -/* * Standard way to access the cycle counter. * Currently only used on SMP for scheduling. * --- a/arch/openrisc/include/asm/timex.h +++ b/arch/openrisc/include/asm/timex.h @@ -25,9 +25,6 @@ static inline cycles_t get_cycles(void) } #define get_cycles get_cycles =20 -/* This isn't really used any more */ -#define CLOCK_TICK_RATE 1000 - #define ARCH_HAS_READ_CURRENT_TIMER =20 #endif --- a/arch/parisc/include/asm/timex.h +++ b/arch/parisc/include/asm/timex.h @@ -9,8 +9,6 @@ =20 #include =20 -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - typedef unsigned long cycles_t; =20 static inline cycles_t get_cycles(void) --- a/arch/powerpc/include/asm/timex.h +++ b/arch/powerpc/include/asm/timex.h @@ -11,8 +11,6 @@ #include #include =20 -#define CLOCK_TICK_RATE 1024000 /* Underlying HZ */ - typedef unsigned long cycles_t; =20 static inline cycles_t get_cycles(void) --- a/arch/s390/include/asm/timex.h +++ b/arch/s390/include/asm/timex.h @@ -177,8 +177,6 @@ static inline void local_tick_enable(uns set_clock_comparator(get_lowcore()->clock_comparator); } =20 -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - typedef unsigned long cycles_t; =20 static __always_inline unsigned long get_tod_clock(void) --- a/arch/sh/include/asm/timex.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * linux/include/asm-sh/timex.h - * - * sh architecture timex specifications - */ -#ifndef __ASM_SH_TIMEX_H -#define __ASM_SH_TIMEX_H - -/* - * Only parts using the legacy CPG code for their clock framework - * implementation need to define their own Pclk value. If provided, this - * can be used for accurately setting CLOCK_TICK_RATE, otherwise we - * simply fall back on the i8253 PIT value. - */ -#ifdef CONFIG_SH_PCLK_FREQ -#define CLOCK_TICK_RATE (CONFIG_SH_PCLK_FREQ / 4) /* Underlying HZ */ -#else -#define CLOCK_TICK_RATE 1193180 -#endif - -#include - -#endif /* __ASM_SH_TIMEX_H */ --- a/arch/sparc/include/asm/timex.h +++ b/arch/sparc/include/asm/timex.h @@ -4,6 +4,6 @@ #if defined(__sparc__) && defined(__arch64__) #include #else -#include +#include #endif #endif --- a/arch/sparc/include/asm/timex_32.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * linux/include/asm/timex.h - * - * sparc architecture timex specifications - */ -#ifndef _ASMsparc_TIMEX_H -#define _ASMsparc_TIMEX_H - -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - -#include - -#endif --- a/arch/sparc/include/asm/timex_64.h +++ b/arch/sparc/include/asm/timex_64.h @@ -9,8 +9,6 @@ =20 #include =20 -#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ - /* Getting on the cycle counter on sparc64. */ typedef unsigned long cycles_t; #define get_cycles() tick_ops->get_tick() --- a/arch/um/include/asm/timex.h +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __UM_TIMEX_H -#define __UM_TIMEX_H - -#define CLOCK_TICK_RATE (HZ) - -#include - -#endif --- a/arch/x86/include/asm/timex.h +++ b/arch/x86/include/asm/timex.h @@ -14,9 +14,6 @@ static inline unsigned long random_get_e } #define random_get_entropy random_get_entropy =20 -/* Assume we use the PIT time source for the clock tick */ -#define CLOCK_TICK_RATE PIT_TICK_RATE - #define ARCH_HAS_READ_CURRENT_TIMER =20 #endif /* _ASM_X86_TIMEX_H */ From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86AC33BD64E; Fri, 10 Apr 2026 12:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823541; cv=none; b=Px7ny0ZNfiwxgo5HylHhqUqUuKw83r7is4ajUBW88OefDmadycMe1lMwz5t83SLtP78ThyF58bPPDiTOejddXP/WqIyrHMMCZfVp44/vB+IlrjgXzZ0czeuWfU9E+VxfQA1uhQxR2+uw/PcpUZ5lxByyTIr4gsyZ2Hh9Jbp7F6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823541; c=relaxed/simple; bh=tQOpQ/MIydS0DCislclXfYYGX/MLE87s4jSCgeL+WRY=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=pDOilWArj3eB0SkYqjcthTQDUOBVBAXinuRPbsCLaqu0pNIYtd1vQDlERI6iqYlAWSLO02AWwo0qJAo+XcA6ZSezmKAUScm0HJCV8UFQd26RAhHU6z9wwO4n7EvS/gJZgOSYXMwx2PwQRY71LrXXq3f2huIgdg9OJ6O6cH0qA90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QXjWZmAy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QXjWZmAy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90115C19425; Fri, 10 Apr 2026 12:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823541; bh=tQOpQ/MIydS0DCislclXfYYGX/MLE87s4jSCgeL+WRY=; h=Date:From:To:Cc:Subject:References:From; b=QXjWZmAyCTkHp5kfenmZQLgv/6aaV3rIg6DEVvlyBDoQvhTKTRyPfm45H+KsvdAYy VHZ0mkxMvX7NrAkZvm3k49raaKd2C+9wSQwjJDY1g6mCI0csX9QiI7H4JXm3HNueX3 EOv1ltqGraI125ajQJZTWidJZvX+BaYkMhFhYKyP7KvvAlz25RxVHq+2fEWi/RQGR8 Hcehq8u7DgPSnaFiQzuBhfPrBLqOhc8OPmg3byOKx6qYpgk7RPMNSknmgg5KdEM/9q gq5iGE6+JxvJ8JrvjFxV3K0ttPe/RN2jOy+C/nJannjRPpT1rSSYryTOpfiapdmnXH zppEqqCxX8IxA== Date: Fri, 10 Apr 2026 14:18:57 +0200 Message-ID: <20260410120317.978403520@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 06/38] calibrate: Rework delay timer calibration References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The header define in asm/timex,h and the naming of the function to read the delay timer are confusing at best. Convert it to a config switch selected by the archictures, which provide the functionality, and rename the function to delay_read_timer(), which makes the purpose clear. Move the declaration to linux/delay.h where it belongs. Remove the resulting empty asm/timex.h files as well. No functional change. Signed-off-by: Thomas Gleixner Cc: Arnd Bergmann --- arch/Kconfig | 3 +++ arch/arm/Kconfig | 1 + arch/arm/include/asm/delay.h | 1 - arch/arm/include/asm/timex.h | 5 ++++- arch/arm/lib/delay.c | 10 ++++------ arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/timex.h | 20 -------------------- arch/hexagon/kernel/time.c | 8 +++++++- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/timex.h | 2 -- arch/openrisc/lib/delay.c | 9 ++++----- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/timex.h | 8 -------- arch/riscv/lib/delay.c | 7 ++++++- arch/sparc/Kconfig | 1 + arch/sparc/include/asm/timex_64.h | 2 -- arch/sparc/kernel/time_64.c | 4 ++-- arch/x86/Kconfig | 1 + arch/x86/include/asm/timex.h | 2 -- arch/x86/lib/delay.c | 8 +++----- include/asm-generic/timex.h | 7 ------- include/linux/delay.h | 2 ++ include/linux/timex.h | 2 -- init/calibrate.c | 19 +++++++++---------- 24 files changed, 50 insertions(+), 75 deletions(-) --- a/arch/Kconfig +++ b/arch/Kconfig @@ -363,6 +363,9 @@ config ARCH_HAS_DMA_CLEAR_UNCACHED config ARCH_HAS_CPU_FINALIZE_INIT bool =20 +config ARCH_HAS_DELAY_TIMER + bool + # The architecture has a per-task state that includes the mm's PASID config ARCH_HAS_CPU_PASID bool --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -11,6 +11,7 @@ config ARM select ARCH_HAS_CPU_FINALIZE_INIT if MMU select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VIRTUAL if MMU + select ARCH_HAS_DELAY_TIMER select ARCH_HAS_DMA_ALLOC if MMU select ARCH_HAS_DMA_OPS select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE --- a/arch/arm/include/asm/delay.h +++ b/arch/arm/include/asm/delay.h @@ -91,7 +91,6 @@ extern void __loop_udelay(unsigned long extern void __loop_const_udelay(unsigned long); =20 /* Delay-loop timer registration. */ -#define ARCH_HAS_READ_CURRENT_TIMER extern void register_current_timer_delay(const struct delay_timer *timer); =20 #endif /* __ASSEMBLY__ */ --- a/arch/arm/include/asm/timex.h +++ b/arch/arm/include/asm/timex.h @@ -10,7 +10,10 @@ #define _ASMARM_TIMEX_H =20 typedef unsigned long cycles_t; -#define get_cycles() ({ cycles_t c; read_current_timer(&c) ? 0 : c; }) +// Temporary workaround +bool delay_read_timer(unsigned long *t); + +#define get_cycles() ({ cycles_t c; delay_read_timer(&c) ? 0 : c; }) #define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_= entropy_fallback()) =20 #endif --- a/arch/arm/lib/delay.c +++ b/arch/arm/lib/delay.c @@ -12,7 +12,6 @@ #include #include #include -#include =20 /* * Default to the loop-based delay implementation. @@ -27,15 +26,14 @@ static const struct delay_timer *delay_t static bool delay_calibrated; static u64 delay_res; =20 -int read_current_timer(unsigned long *timer_val) +bool delay_read_timer(unsigned long *timer_val) { if (!delay_timer) - return -ENXIO; - + return false; *timer_val =3D delay_timer->read_current_timer(); - return 0; + return true; } -EXPORT_SYMBOL_GPL(read_current_timer); +EXPORT_SYMBOL_GPL(delay_read_timer); =20 static inline u64 cyc_to_ns(u64 cyc, u32 mult, u32 shift) { --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -5,6 +5,7 @@ comment "Linux Kernel Configuration for config HEXAGON def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_DELAY_TIMER select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_NO_PREEMPT select ARCH_WANT_FRAME_POINTERS --- a/arch/hexagon/include/asm/timex.h +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#ifndef _ASM_TIMEX_H -#define _ASM_TIMEX_H - -#include -#include - -#define ARCH_HAS_READ_CURRENT_TIMER - -static inline int read_current_timer(unsigned long *timer_val) -{ - *timer_val =3D __vmgettime(); - return 0; -} - -#endif --- a/arch/hexagon/kernel/time.c +++ b/arch/hexagon/kernel/time.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -17,7 +18,6 @@ #include #include =20 -#include #include #include =20 @@ -231,3 +231,9 @@ void __udelay(unsigned long usecs) cpu_relax(); /* not sure how this improves readability */ } EXPORT_SYMBOL(__udelay); + +bool delay_read_timer(unsigned long *timer_val) +{ + *timer_val =3D __vmgettime(); + return true; +} --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -7,6 +7,7 @@ config OPENRISC def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_DELAY_TIMER select ARCH_HAS_DMA_SET_UNCACHED select ARCH_HAS_DMA_CLEAR_UNCACHED select ARCH_HAS_SYNC_DMA_FOR_DEVICE --- a/arch/openrisc/include/asm/timex.h +++ b/arch/openrisc/include/asm/timex.h @@ -25,6 +25,4 @@ static inline cycles_t get_cycles(void) } #define get_cycles get_cycles =20 -#define ARCH_HAS_READ_CURRENT_TIMER - #endif --- a/arch/openrisc/lib/delay.c +++ b/arch/openrisc/lib/delay.c @@ -13,18 +13,17 @@ */ =20 #include +#include #include #include -#include + #include -#include -#include #include =20 -int read_current_timer(unsigned long *timer_value) +bool delay_read_timer(unsigned long *timer_value) { *timer_value =3D get_cycles(); - return 0; + return true; } =20 void __delay(unsigned long cycles) --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -29,6 +29,7 @@ config RISCV select ARCH_HAS_DEBUG_VIRTUAL if MMU select ARCH_HAS_DEBUG_VM_PGTABLE select ARCH_HAS_DEBUG_WX + select ARCH_HAS_DELAY_TIMER select ARCH_HAS_ELF_CORE_EFLAGS if BINFMT_ELF && ELF_CORE select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FORTIFY_SOURCE --- a/arch/riscv/include/asm/timex.h +++ b/arch/riscv/include/asm/timex.h @@ -80,12 +80,4 @@ static inline u64 get_cycles64(void) return ((u64)hi << 32) | lo; } #endif /* CONFIG_64BIT */ - -#define ARCH_HAS_READ_CURRENT_TIMER -static inline int read_current_timer(unsigned long *timer_val) -{ - *timer_val =3D get_cycles(); - return 0; -} - #endif /* _ASM_RISCV_TIMEX_H */ --- a/arch/riscv/lib/delay.c +++ b/arch/riscv/lib/delay.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include =20 @@ -109,3 +108,9 @@ void ndelay(unsigned long nsecs) __delay(ncycles >> NDELAY_SHIFT); } EXPORT_SYMBOL(ndelay); + +bool delay_read_timer(unsigned long *timer_val) +{ + *timer_val =3D get_cycles(); + return true; +} --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -70,6 +70,7 @@ config SPARC32 config SPARC64 def_bool 64BIT select ALTERNATE_USER_ADDRESS_SPACE + select ARCH_HAS_DELAY_TIMER select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER select HAVE_KRETPROBES --- a/arch/sparc/include/asm/timex_64.h +++ b/arch/sparc/include/asm/timex_64.h @@ -13,6 +13,4 @@ typedef unsigned long cycles_t; #define get_cycles() tick_ops->get_tick() =20 -#define ARCH_HAS_READ_CURRENT_TIMER - #endif --- a/arch/sparc/kernel/time_64.c +++ b/arch/sparc/kernel/time_64.c @@ -894,8 +894,8 @@ unsigned long long sched_clock(void) return ((get_tick() * quotient) >> SPARC64_NSEC_PER_CYC_SHIFT) - offset; } =20 -int read_current_timer(unsigned long *timer_val) +bool delay_read_timer(unsigned long *timer_val) { *timer_val =3D get_tick(); - return 0; + return true; } --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -81,6 +81,7 @@ config X86 select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEBUG_VM_PGTABLE if !X86_PAE + select ARCH_HAS_DELAY_TIMER select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_DMA_OPS if GART_IOMMU || XEN select ARCH_HAS_EARLY_DEBUG if KGDB --- a/arch/x86/include/asm/timex.h +++ b/arch/x86/include/asm/timex.h @@ -14,6 +14,4 @@ static inline unsigned long random_get_e } #define random_get_entropy random_get_entropy =20 -#define ARCH_HAS_READ_CURRENT_TIMER - #endif /* _ASM_X86_TIMEX_H */ --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -14,12 +14,10 @@ =20 #include #include -#include #include #include =20 #include -#include #include #include =20 @@ -189,13 +187,13 @@ void use_mwaitx_delay(void) delay_fn =3D delay_halt; } =20 -int read_current_timer(unsigned long *timer_val) +bool delay_read_timer(unsigned long *timer_val) { if (delay_fn =3D=3D delay_tsc) { *timer_val =3D rdtsc(); - return 0; + return true; } - return -1; + return false; } =20 void __delay(unsigned long loops) --- a/include/asm-generic/timex.h +++ b/include/asm-generic/timex.h @@ -13,11 +13,4 @@ static inline cycles_t get_cycles(void) } #endif =20 -/* - * Architectures are encouraged to implement read_current_timer - * and define this in order to avoid the expensive delay loop - * calibration during boot. - */ -#undef ARCH_HAS_READ_CURRENT_TIMER - #endif /* __ASM_GENERIC_TIMEX_H */ --- a/include/linux/delay.h +++ b/include/linux/delay.h @@ -17,6 +17,8 @@ extern unsigned long loops_per_jiffy; =20 #include =20 +bool delay_read_timer(unsigned long *t); + /* * Using udelay() for intervals greater than a few milliseconds can * risk overflow for high loops_per_jiffy (high bogomips) machines. The --- a/include/linux/timex.h +++ b/include/linux/timex.h @@ -156,8 +156,6 @@ extern int do_clock_adjtime(const clocki =20 extern void hardpps(const struct timespec64 *, const struct timespec64 *); =20 -int read_current_timer(unsigned long *timer_val); - /* The clock frequency of the i8253/i8254 PIT */ #define PIT_TICK_RATE 1193182ul =20 --- a/init/calibrate.c +++ b/init/calibrate.c @@ -13,7 +13,6 @@ #include #include #include -#include =20 unsigned long lpj_fine; unsigned long preset_lpj; @@ -25,9 +24,9 @@ static int __init lpj_setup(char *str) =20 __setup("lpj=3D", lpj_setup); =20 -#ifdef ARCH_HAS_READ_CURRENT_TIMER +#ifdef CONFIG_ARCH_HAS_DELAY_TIMER =20 -/* This routine uses the read_current_timer() routine and gets the +/* This routine uses the delay_read_timer() routine and gets the * loops per jiffy directly, instead of guessing it using delay(). * Also, this code tries to handle non-maskable asynchronous events * (like SMIs) @@ -48,13 +47,13 @@ static unsigned long calibrate_delay_dir int min =3D -1; int i; =20 - if (read_current_timer(&pre_start) < 0 ) + if (!delay_read_timer(&pre_start)) return 0; =20 /* * A simple loop like * while ( jiffies < start_jiffies+1) - * start =3D read_current_timer(); + * start =3D delay_read_timer(); * will not do. As we don't really know whether jiffy switch * happened first or timer_value was read first. And some asynchronous * event can happen between these two events introducing errors in lpj. @@ -72,22 +71,22 @@ static unsigned long calibrate_delay_dir =20 for (i =3D 0; i < MAX_DIRECT_CALIBRATION_RETRIES; i++) { pre_start =3D 0; - read_current_timer(&start); + delay_read_timer(&start); start_jiffies =3D jiffies; while (time_before_eq(jiffies, start_jiffies + 1)) { pre_start =3D start; - read_current_timer(&start); + delay_read_timer(&start); } - read_current_timer(&post_start); + delay_read_timer(&post_start); =20 pre_end =3D 0; end =3D post_start; while (time_before_eq(jiffies, start_jiffies + 1 + DELAY_CALIBRATION_TICKS)) { pre_end =3D end; - read_current_timer(&end); + delay_read_timer(&end); } - read_current_timer(&post_end); + delay_read_timer(&post_end); =20 timer_rate_max =3D (post_end - pre_start) / DELAY_CALIBRATION_TICKS; From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0D053BD64E; Fri, 10 Apr 2026 12:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823546; cv=none; b=rHZxoBZ+bDfVoZ/eKqvYwfI6z/nNNdf0dFPM9e3f34jpUiObpn123ho4/kU8ZDcEWyH0UIDPuFhQdJrnioDLh5aBHJlWv4bm02d5lkwKcSh3jTKoj05wuKmAuMvsFYPd2JWC4ncwlVwUuIMxnOPQuF5cTurN4D0BYAxe5bpYoiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823546; c=relaxed/simple; bh=e1hr7RxQAtfkXxmpOByj9AnE8rprLs7FfW1VJuycE3U=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=JPqUytWaWBHysIZ3Aff2KqPjeJEN3vumceXGsXjSE7c/JaAIs9hZuj+ah+lBv0Q9xNAls4Pk8fXTMT+JYUTs3YgbVYiZuKkilFJ++N9c97UHUsQH8+K+iOcvEimqDGT3Kq4HfWRUC/dQTBILxnkcT0hogJiWXQlACRnVk5LEHXM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RN1rF/li; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RN1rF/li" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CDE4C2BCB3; Fri, 10 Apr 2026 12:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823546; bh=e1hr7RxQAtfkXxmpOByj9AnE8rprLs7FfW1VJuycE3U=; h=Date:From:To:Subject:References:cc:From; b=RN1rF/lik/IDDm6vfArIXRWDzYeJ5FOTg7VZhjC87W8dEFx4XOLkGFYYWGhN5FSAp UgUW5oHG+RoyFDJ2Lb8wy9bLXZ629e0sIZHO26a4htp9GCeP67dTQge4t3eD4oDh93 1M2FHKCxNFZC0Fzd0yadwA9xaercjxCXri8tQar5sfr/ENoprWWJO3/MtUJLqRehkg l/QzejVV1juchHtR/6u+RSlRsRj9VAJZETUAE3E4ZTRyX1FMMGjRx2pW1U9TsOYtOg Iiw1IsbQmNZnTrKZs9AZodQQ0gykTA14aWPgbU/9QJFDHI9V1VA1cDQRoqdiQlL5WN Y1nwRLUUSmSZw== Date: Fri, 10 Apr 2026 14:19:03 +0200 Message-ID: <20260410120318.045532623@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 07/38] treewide: Consolidate cycles_t References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Most architectures define cycles_t as unsigned long execpt: - x86 requires it to be 64-bit independent of the 32-bit/64-bit build. - parisc and mips define it as unsigned int parisc has no real reason to do so as there are only a few usage sites which either expand it to a 64-bit value or utilize only the lower 32bits. mips has no real requirement either. Move the typedef to types.h and provide a config switch to enforce the 64-bit type for x86. Signed-off-by: Thomas Gleixner Acked-by: Geert Uytterhoeven # m68k --- arch/Kconfig | 4 ++++ arch/alpha/include/asm/timex.h | 3 --- arch/arm/include/asm/timex.h | 1 - arch/loongarch/include/asm/timex.h | 2 -- arch/m68k/include/asm/timex.h | 2 -- arch/mips/include/asm/timex.h | 2 -- arch/nios2/include/asm/timex.h | 2 -- arch/parisc/include/asm/timex.h | 2 -- arch/powerpc/include/asm/timex.h | 4 +--- arch/riscv/include/asm/timex.h | 2 -- arch/s390/include/asm/timex.h | 2 -- arch/sparc/include/asm/timex_64.h | 1 - arch/x86/Kconfig | 1 + arch/x86/include/asm/tsc.h | 2 -- include/asm-generic/timex.h | 1 - include/linux/types.h | 6 ++++++ 16 files changed, 12 insertions(+), 25 deletions(-) --- a/arch/Kconfig +++ b/arch/Kconfig @@ -360,6 +360,10 @@ config ARCH_HAS_DMA_SET_UNCACHED config ARCH_HAS_DMA_CLEAR_UNCACHED bool =20 +# cycles_t is always 64bit wide +config ARCH_HAS_CYCLES_T_64 + bool + config ARCH_HAS_CPU_FINALIZE_INIT bool =20 --- a/arch/alpha/include/asm/timex.h +++ b/arch/alpha/include/asm/timex.h @@ -15,9 +15,6 @@ * But this only means we'll force a reschedule every 8 seconds or so, * which isn't an evil thing. */ - -typedef unsigned int cycles_t; - static inline cycles_t get_cycles (void) { cycles_t ret; --- a/arch/arm/include/asm/timex.h +++ b/arch/arm/include/asm/timex.h @@ -9,7 +9,6 @@ #ifndef _ASMARM_TIMEX_H #define _ASMARM_TIMEX_H =20 -typedef unsigned long cycles_t; // Temporary workaround bool delay_read_timer(unsigned long *t); =20 --- a/arch/loongarch/include/asm/timex.h +++ b/arch/loongarch/include/asm/timex.h @@ -12,8 +12,6 @@ #include #include =20 -typedef unsigned long cycles_t; - #define get_cycles get_cycles =20 static inline cycles_t get_cycles(void) --- a/arch/m68k/include/asm/timex.h +++ b/arch/m68k/include/asm/timex.h @@ -7,8 +7,6 @@ #ifndef _ASMm68K_TIMEX_H #define _ASMm68K_TIMEX_H =20 -typedef unsigned long cycles_t; - static inline cycles_t get_cycles(void) { return 0; --- a/arch/mips/include/asm/timex.h +++ b/arch/mips/include/asm/timex.h @@ -29,8 +29,6 @@ * We know that all SMP capable CPUs have cycle counters. */ =20 -typedef unsigned int cycles_t; - /* * On R4000/R4400 an erratum exists such that if the cycle counter is * read in the exact moment that it is matching the compare register, --- a/arch/nios2/include/asm/timex.h +++ b/arch/nios2/include/asm/timex.h @@ -5,8 +5,6 @@ #ifndef _ASM_NIOS2_TIMEX_H #define _ASM_NIOS2_TIMEX_H =20 -typedef unsigned long cycles_t; - extern cycles_t get_cycles(void); #define get_cycles get_cycles =20 --- a/arch/parisc/include/asm/timex.h +++ b/arch/parisc/include/asm/timex.h @@ -9,8 +9,6 @@ =20 #include =20 -typedef unsigned long cycles_t; - static inline cycles_t get_cycles(void) { return mfctl(16); --- a/arch/powerpc/include/asm/timex.h +++ b/arch/powerpc/include/asm/timex.h @@ -11,9 +11,7 @@ #include #include =20 -typedef unsigned long cycles_t; - -static inline cycles_t get_cycles(void) +ostatic inline cycles_t get_cycles(void) { return mftb(); } --- a/arch/riscv/include/asm/timex.h +++ b/arch/riscv/include/asm/timex.h @@ -8,8 +8,6 @@ =20 #include =20 -typedef unsigned long cycles_t; - #ifdef CONFIG_RISCV_M_MODE =20 #include --- a/arch/s390/include/asm/timex.h +++ b/arch/s390/include/asm/timex.h @@ -177,8 +177,6 @@ static inline void local_tick_enable(uns set_clock_comparator(get_lowcore()->clock_comparator); } =20 -typedef unsigned long cycles_t; - static __always_inline unsigned long get_tod_clock(void) { union tod_clock clk; --- a/arch/sparc/include/asm/timex_64.h +++ b/arch/sparc/include/asm/timex_64.h @@ -10,7 +10,6 @@ #include =20 /* Getting on the cycle counter on sparc64. */ -typedef unsigned long cycles_t; #define get_cycles() tick_ops->get_tick() =20 #endif --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -79,6 +79,7 @@ config X86 select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_CPU_PASID if IOMMU_SVA select ARCH_HAS_CURRENT_STACK_POINTER + select ARCH_HAS_CYCLES_T_64 select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEBUG_VM_PGTABLE if !X86_PAE select ARCH_HAS_DELAY_TIMER --- a/arch/x86/include/asm/tsc.h +++ b/arch/x86/include/asm/tsc.h @@ -67,8 +67,6 @@ static __always_inline u64 rdtsc_ordered /* * Standard way to access the cycle counter. */ -typedef unsigned long long cycles_t; - extern unsigned int cpu_khz; extern unsigned int tsc_khz; =20 --- a/include/asm-generic/timex.h +++ b/include/asm-generic/timex.h @@ -5,7 +5,6 @@ /* * If you have a cycle counter, return the value here. */ -typedef unsigned long cycles_t; #ifndef get_cycles static inline cycles_t get_cycles(void) { --- a/include/linux/types.h +++ b/include/linux/types.h @@ -270,5 +270,11 @@ struct rcuwait { struct task_struct __rcu *task; }; =20 +#ifdef CONFIG_ARCH_HAS_CYCLES_T_64 +typedef unsigned long long cycles_t; +#else +typedef unsigned long cycles_t; +#endif + #endif /* __ASSEMBLY__ */ #endif /* _LINUX_TYPES_H */ From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5240D3BD64E; Fri, 10 Apr 2026 12:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823551; cv=none; b=Coyxp6lIkeIFJNsrdxqQn9VNq1Dd91+mjgGIwEmVZY/vhJHaaQbLzss0itQikN3TCbMosxkZXTrvQJDjv1kZVV8z6oANp3jyIoFNlrlLPx0te64vF1RKRbLA+XZnsx/tRlFE/uTmVw6Al17j/P/m8zcSltP3BO4BwifqbBek078= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823551; c=relaxed/simple; bh=bea3byi4f+lJwA9RE9L4RIIWG0LfPmc09XAUdHtlAlE=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=uGpT1AiSAr6h9n0GuuSfkG3onoJpNqNwUxMKeAdYGd/A7E5CeZ+0ov7ASXousy/aPcBeiA5onN4l/Jg/p8ouE1RM207z0wtwddA/X49s6JYNzeocBB0FD3If/ow0mRlbh9MpiRgNglAjIoOOZSQiiqgMGSXtrdSw5p1WuNB/hWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YwhpP/sf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YwhpP/sf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 455B0C2BC87; Fri, 10 Apr 2026 12:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823550; bh=bea3byi4f+lJwA9RE9L4RIIWG0LfPmc09XAUdHtlAlE=; h=Date:From:To:Subject:References:cc:From; b=YwhpP/sfl2uNAokHMGyDzPyXqsYG5Z3HHapkhzwVASiSkGSv1ImeSFBY018VYZGU6 EPRk8H/tD4bE94DCGFfik82fydH/mvkzeKH2zcGHFzmiPQlK2yTJNXmBvp6CR6/aKP ZUXJ1ridIfNl+octSklnUsCiAFVq0bMAbDZHArZ2XlGiEpILEnKNdARJlXe1YoLGU7 gTGiAjrmuKfAH7Stm5YSWpKnJ3J0WABG0fiD/+Dm/7aJCfY6aDBkC0dcXhqkELemEA OLCKD9b/UmnIij2UMaT5laELpK9/RUq1POEHXDOcdk6mujQiavRoj/L2U3OHpVV16q LiEll066ex31A== Date: Fri, 10 Apr 2026 14:19:08 +0200 Message-ID: <20260410120318.121043259@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 08/38] x86/tsc: Use rdtsc() instead of get_cycles() References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This code knows that TSC is available so there is no point to use the TSC feature guarded get_cycles(). No functional change. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/tsc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -371,12 +371,12 @@ static u64 tsc_read_refs(u64 *p, int hpe int i; =20 for (i =3D 0; i < MAX_RETRIES; i++) { - t1 =3D get_cycles(); + t1 =3D rdtsc(); if (hpet) *p =3D hpet_readl(HPET_COUNTER) & 0xFFFFFFFF; else *p =3D acpi_pm_read_early(); - t2 =3D get_cycles(); + t2 =3D rdtsc(); if ((t2 - t1) < thresh) return t2; } @@ -468,13 +468,13 @@ static unsigned long pit_calibrate_tsc(u outb(latch & 0xff, 0x42); outb(latch >> 8, 0x42); =20 - tsc =3D t1 =3D t2 =3D get_cycles(); + tsc =3D t1 =3D t2 =3D rdtsc(); =20 pitcnt =3D 0; tscmax =3D 0; tscmin =3D ULONG_MAX; while ((inb(0x61) & 0x20) =3D=3D 0) { - t2 =3D get_cycles(); + t2 =3D rdtsc(); delta =3D t2 - tsc; tsc =3D t2; if ((unsigned long) delta < tscmin) @@ -553,9 +553,9 @@ static inline int pit_expect_msb(unsigne if (!pit_verify_msb(val)) break; prev_tsc =3D tsc; - tsc =3D get_cycles(); + tsc =3D rdtsc(); } - *deltap =3D get_cycles() - prev_tsc; + *deltap =3D rdtsc() - prev_tsc; *tscp =3D tsc; =20 /* From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F9463BFE40; Fri, 10 Apr 2026 12:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823555; cv=none; b=UPss8nVAuMTAN3pnwUYX6yCZ7+jJvr73arfBZPYO+xfwireSSUjyXhJH5TGQ2piRT0WZ92UY7H4aQYrc7Qc8Cit5Y9Q5MA5vJJm9sY507ms2K6bYHWG+JcnaZWwfSTv1kk9NrryoJL3WAkgfkOi6yy0gieHgOqbowiG02E8toGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823555; c=relaxed/simple; bh=qtG4jYoFMBUH8Rv5LkkLsBrvbBwuDbTX1269QfkLCzw=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=NuZWGs7c9F/nxYYh4xjAHr15mr+jzC5d2SbzM+zhw7jfOaF+82PzmSsSMf8h9ydKzttuf868rQzsgbwMXH/vxT5bnYS7OCppCwbArnZR/UoKblIV+tH7WwMhHqTjeR08UbE5jTwi+0XeOJrDD2f626jOLL4+5inCrBf4sWCCJtE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pacXAmHL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pacXAmHL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BE3EC2BC87; Fri, 10 Apr 2026 12:19:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823555; bh=qtG4jYoFMBUH8Rv5LkkLsBrvbBwuDbTX1269QfkLCzw=; h=Date:From:To:Cc:Subject:References:From; b=pacXAmHLAMseTev4RAQUAZDfRzJFeJXjwMW3x14w8vUm7ybikBbtslQQu96s/8Sq0 a3pcIexn/gzfbwI2qYLuXSTx/gSXbmVwhuUFKfTY31pSFVH71nhoebkIPAnwJfmArK tPmJiCD8oWRaoY6EByg0L3DGpV75oKKW/C5lmUUCoaSznEsjUHpS9yyQByZ5hUlH3x P8NYw39byMTR2ebfPveTfvTFbDgwqYFvegEj7/kJQbjlvVeppRrN8YtOduabfxNT6E Yw4oV6JDjGSLEpWghPJGJFmnCci2PXJh9wjpVWvhGUbODkplfUDbeuEJIVIN1zibiF mC2OEaJT1jHhg== Date: Fri, 10 Apr 2026 14:19:12 +0200 Message-ID: <20260410120318.187521447@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Arnd Bergmann , Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 09/38] iommu/vt-d: Use sched_clock() instead of get_cycles() References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Calculating the timeout from get_cycles() is a historical leftover without any functional requirement. Use ktime_get() instead. Signed-off-by: Thomas Gleixner Cc: x86@kernel.org Cc: Lu Baolu Cc: iommu@lists.linux.dev Reviewed-by: Lu Baolu --- arch/x86/include/asm/iommu.h | 3 --- drivers/iommu/intel/dmar.c | 4 ++-- drivers/iommu/intel/iommu.h | 8 ++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) --- a/arch/x86/include/asm/iommu.h +++ b/arch/x86/include/asm/iommu.h @@ -18,9 +18,6 @@ extern bool x86_swiotlb_enable; #define x86_swiotlb_enable false #endif =20 -/* 10 seconds */ -#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) - static inline int __init arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr) { --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1606,9 +1606,9 @@ void qi_flush_pasid_cache(struct intel_i */ void dmar_disable_qi(struct intel_iommu *iommu) { + ktime_t start_time =3D ktime_get(); unsigned long flags; u32 sts; - cycles_t start_time =3D get_cycles(); =20 if (!ecap_qis(iommu->ecap)) return; @@ -1624,7 +1624,7 @@ void dmar_disable_qi(struct intel_iommu */ while ((readl(iommu->reg + DMAR_IQT_REG) !=3D readl(iommu->reg + DMAR_IQH_REG)) && - (DMAR_OPERATION_TIMEOUT > (get_cycles() - start_time))) + (DMAR_OPERATION_TIMEOUT > (ktime_get() - start_time))) cpu_relax(); =20 iommu->gcmd &=3D ~DMA_GCMD_QIE; --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -23,6 +23,7 @@ #include #include #include +#include #include =20 #include @@ -360,14 +361,17 @@ /* PERFINTRSTS_REG */ #define DMA_PERFINTRSTS_PIS ((u32)1) =20 +#define DMAR_OPERATION_TIMEOUT (((ktime_t)10) * NSEC_PER_SEC) + #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ do { \ - cycles_t start_time =3D get_cycles(); \ + ktime_t start_time =3D ktime_get(); \ + \ while (1) { \ sts =3D op(iommu->reg + offset); \ if (cond) \ break; \ - if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\ + if (DMAR_OPERATION_TIMEOUT < (ktime_get() - start_time))\ panic("DMAR hardware is malfunctioning\n"); \ cpu_relax(); \ } \ From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2105C3BFE40; Fri, 10 Apr 2026 12:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823560; cv=none; b=KCohC9xR+GR/9Pt5RkH8cHDJxwjF9QkuoHHXN1azjakl/wjOaIDEQxkOqpe7xuA9PmAK8M7MJKiuUuD9SyrK+gZaiu67fpGLzQa9mH7NIWGuw62xhm6ZAtGpSvz2zGvLAtB/X0Bu2YXnGWkh+ZOt/6YJZPnUBuBu4xDqyyOc0I8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823560; c=relaxed/simple; bh=p4ul6fecafqSjuz/HWiW1SqReHpNi3SQC1heaf7AtH8=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=buCr1PgDuGE9ZEGgxhWb0EPGGGswBCZk02FAupQUqgmMbWtgzUmv0Nybucf2JEaGZ5znJIIfVK+JiFL91iXtgrrW5olYreoDWD9spHBNm7qtjuC6OB5dpRu/Nj8DVyzgmsS6ac0rItTn6CLsIvx2uk/WkPZBnDGjv/krom0Hrm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VM13lKS0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VM13lKS0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E38E7C2BC87; Fri, 10 Apr 2026 12:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823559; bh=p4ul6fecafqSjuz/HWiW1SqReHpNi3SQC1heaf7AtH8=; h=Date:From:To:Cc:Subject:References:From; b=VM13lKS0vi1Fampzs2SOJUSl5pFNtZPRrbRXrfYUkEg7syYn7CVko7c7egIdexCfj MaRLNlopnK85+N7I7i3OZHuHcMdHWNGNdlJV5bSYYI//COctIU1M1ukOOe7R86fGRN QQ/j+jjVi+CYY1R1j+UlDL84K4FAOhCbq1OrkH36o+f5XviRftg90dsfUTYhZvjNV5 hk3/t6EuYClXGdWJA1CVm0r4gv7+Uuy+bWtd/uVuLx4/iO4+bV/Z+fKbXLcG7tmKkB b/7xC9trAvx6oz1zNsW6Ny9Eav33gyvB9AokHXFATxUfQATArxGnp5TkYcwejIeG8o hkZquPfDoH+3g== Date: Fri, 10 Apr 2026 14:19:16 +0200 Message-ID: <20260410120318.253872322@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Michael Grzeschik , netdev@vger.kernel.org, Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 10/38] arcnet: Remove function timing code References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ARCNET is a museums piece and the function timing can be done with ftrace. Remove the cruft. Signed-off-by: Thomas Gleixner Cc: Michael Grzeschik Cc: netdev@vger.kernel.org Acked-by: David Woodhouse --- drivers/net/arcnet/arc-rimi.c | 4 ++-- drivers/net/arcnet/arcdevice.h | 20 +------------------- drivers/net/arcnet/com20020.c | 6 ++---- drivers/net/arcnet/com90io.c | 6 ++---- drivers/net/arcnet/com90xx.c | 4 ++-- 5 files changed, 9 insertions(+), 31 deletions(-) --- a/drivers/net/arcnet/arc-rimi.c +++ b/drivers/net/arcnet/arc-rimi.c @@ -291,7 +291,7 @@ static void arcrimi_copy_to_card(struct struct arcnet_local *lp =3D netdev_priv(dev); void __iomem *memaddr =3D lp->mem_start + 0x800 + bufnum * 512 + offset; =20 - TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count)); + memcpy_toio(memaddr, buf, count); } =20 static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, @@ -300,7 +300,7 @@ static void arcrimi_copy_from_card(struc struct arcnet_local *lp =3D netdev_priv(dev); void __iomem *memaddr =3D lp->mem_start + 0x800 + bufnum * 512 + offset; =20 - TIME(dev, "memcpy_fromio", count, memcpy_fromio(buf, memaddr, count)); + memcpy_fromio(buf, memaddr, count); } =20 static int node; --- a/drivers/net/arcnet/arcdevice.h +++ b/drivers/net/arcnet/arcdevice.h @@ -11,7 +11,6 @@ #ifndef _LINUX_ARCDEVICE_H #define _LINUX_ARCDEVICE_H =20 -#include #include =20 #ifdef __KERNEL__ @@ -62,7 +61,7 @@ #define D_RX 512 /* show rx packets */ #define D_SKB 1024 /* show skb's */ #define D_SKB_SIZE 2048 /* show skb sizes */ -#define D_TIMING 4096 /* show time needed to copy buffers to card */ +#define D_TIMING 4096 /* Not longer supported. Use tracing instead */ #define D_DEBUG 8192 /* Very detailed debug line for line */ =20 #ifndef ARCNET_DEBUG_MAX @@ -95,23 +94,6 @@ do { \ pr_cont(fmt, ##__VA_ARGS__); \ } while (0) =20 -/* see how long a function call takes to run, expressed in CPU cycles */ -#define TIME(dev, name, bytes, call) \ -do { \ - if (BUGLVL(D_TIMING)) { \ - unsigned long _x, _y; \ - _x =3D get_cycles(); \ - call; \ - _y =3D get_cycles(); \ - arc_printk(D_TIMING, dev, \ - "%s: %d bytes in %lu cycles =3D=3D %lu Kbytes/100Mcycle\n", \ - name, bytes, _y - _x, \ - 100000000 / 1024 * bytes / (_y - _x + 1)); \ - } else { \ - call; \ - } \ -} while (0) - /* * Time needed to reset the card - in ms (milliseconds). This works on my * SMC PC100. I can't find a reference that tells me just how long I --- a/drivers/net/arcnet/com20020.c +++ b/drivers/net/arcnet/com20020.c @@ -70,8 +70,7 @@ static void com20020_copy_from_card(stru arcnet_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO); =20 /* copy the data */ - TIME(dev, "insb", count, - arcnet_insb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count)); + arcnet_insb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count); } =20 static void com20020_copy_to_card(struct net_device *dev, int bufnum, @@ -84,8 +83,7 @@ static void com20020_copy_to_card(struct arcnet_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO); =20 /* copy the data */ - TIME(dev, "outsb", count, - arcnet_outsb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count)); + arcnet_outsb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count); } =20 /* Reset the card and check some basic stuff during the detection stage. */ --- a/drivers/net/arcnet/com90io.c +++ b/drivers/net/arcnet/com90io.c @@ -332,15 +332,13 @@ static void com90io_setmask(struct net_d static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset, void *buf, int count) { - TIME(dev, "put_whole_buffer", count, - put_whole_buffer(dev, bufnum * 512 + offset, count, buf)); + put_whole_buffer(dev, bufnum * 512 + offset, count, buf); } =20 static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offset, void *buf, int count) { - TIME(dev, "get_whole_buffer", count, - get_whole_buffer(dev, bufnum * 512 + offset, count, buf)); + get_whole_buffer(dev, bufnum * 512 + offset, count, buf); } =20 static int io; /* use the insmod io=3D irq=3D shmem=3D options */ --- a/drivers/net/arcnet/com90xx.c +++ b/drivers/net/arcnet/com90xx.c @@ -633,7 +633,7 @@ static void com90xx_copy_to_card(struct struct arcnet_local *lp =3D netdev_priv(dev); void __iomem *memaddr =3D lp->mem_start + bufnum * 512 + offset; =20 - TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count)); + memcpy_toio(memaddr, buf, count); } =20 static void com90xx_copy_from_card(struct net_device *dev, int bufnum, @@ -642,7 +642,7 @@ static void com90xx_copy_from_card(struc struct arcnet_local *lp =3D netdev_priv(dev); void __iomem *memaddr =3D lp->mem_start + bufnum * 512 + offset; =20 - TIME(dev, "memcpy_fromio", count, memcpy_fromio(buf, memaddr, count)); + memcpy_fromio(buf, memaddr, count); } =20 MODULE_DESCRIPTION("ARCnet COM90xx normal chipset driver"); From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1B0F3C6A5F; Fri, 10 Apr 2026 12:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823565; cv=none; b=khBC9WsQQp4PBB1nP7lNqMcne0HAzWXEi5O1gcXdEeLR0ZhlpN5hMFWt/o1CmLVsckQEogH0ow50GK+/O0c8Wq9Y40bfolcOP9m2unAGdXrcFWeNAhrhGWZKJxhP1oe8+IBtod6MEvW9mW/MkMkG/nMGWr7BB9+RP9YxrZ+sVZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823565; c=relaxed/simple; bh=tLIpqPCaUi8Lfeqau43+rfn7UZ8vuvPykTPYNUPuuyU=; h=Date:Message-ID:From:To:Subject:References:MIME-Version: Content-Type:cc; b=Jres9KWGihZd5HOXSG0kMYg/4Kndf3yrmtzyIvjR5YFsu6dLX5IaSU3wf8SIcDtfqUKAy+d493f3WHmB60G3yl2Clu7iiM9Dur0GEYVGUHS1Nh5D1erBf4kZRN1ikcJq6ypIDGcNahOSK3yUgwUtC2EOerc+gStYHuNFV3cYUO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uunn/bCq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uunn/bCq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A057C2BCB3; Fri, 10 Apr 2026 12:19:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823565; bh=tLIpqPCaUi8Lfeqau43+rfn7UZ8vuvPykTPYNUPuuyU=; h=Date:From:To:Subject:References:cc:From; b=uunn/bCqpDYdqH3aqiI0+2U/qm27AeTQwxnXbKYibcvcv2ZEX2J7abPlER3gpmuTw CBdP5mMh40n2zp7Tno2Q99U//gHXFdOV0IBNQapDNZb3rSYwBD5TySsxa/Td7SLyaZ p+uL6Iv9jGq9ZtmZnt8i06X/J571L31cWnZuiDLMRsOKbpHdih8iJDMdVxjdr+94oH +kfrO2pFRZtB2b/jp8TX3WQWaL7ksYC/uaT6tTAybV37imt1fhiAkDjh2EPTnuViku 1P4aDmEJtrdQSxbhtiFRIYbjrzGEHTE4V2Fb8MxeAUFtdhNoavN7essScQIWwWoRqs j/BFBM5JmmtDw== Date: Fri, 10 Apr 2026 14:19:21 +0200 Message-ID: <20260410120318.320727701@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Subject: [patch 11/38] misc: sgi-gru: Remove get_cycles() [ab]use References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 cc: Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Calculating a timeout from get_cycles() is a historical leftover without any functional requirement. Use ktime_get() instead. Signed-off-by: Thomas Gleixner --- drivers/misc/sgi-gru/gruhandles.c | 20 ++++++++------------ drivers/misc/sgi-gru/grukservices.c | 3 ++- drivers/misc/sgi-gru/grutlbpurge.c | 5 ++--- 3 files changed, 12 insertions(+), 16 deletions(-) --- a/drivers/misc/sgi-gru/gruhandles.c +++ b/drivers/misc/sgi-gru/gruhandles.c @@ -6,26 +6,22 @@ */ =20 #include +#include #include "gru.h" #include "grulib.h" #include "grutables.h" =20 -/* 10 sec */ #include -#include -#define GRU_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) -#define CLKS2NSEC(c) ((c) * 1000000 / tsc_khz) + +#define GRU_OPERATION_TIMEOUT_NSEC (((ktime_t)10 * NSEC_PER_SEC)) =20 /* Extract the status field from a kernel handle */ #define GET_MSEG_HANDLE_STATUS(h) (((*(unsigned long *)(h)) >> 16) & 3) =20 struct mcs_op_statistic mcs_op_statistics[mcsop_last]; =20 -static void update_mcs_stats(enum mcs_op op, unsigned long clks) +static void update_mcs_stats(enum mcs_op op, unsigned long nsec) { - unsigned long nsec; - - nsec =3D CLKS2NSEC(clks); atomic_long_inc(&mcs_op_statistics[op].count); atomic_long_add(nsec, &mcs_op_statistics[op].total); if (mcs_op_statistics[op].max < nsec) @@ -58,21 +54,21 @@ static void report_instruction_timeout(v =20 static int wait_instruction_complete(void *h, enum mcs_op opc) { + ktime_t start_time =3D ktime_get(); int status; - unsigned long start_time =3D get_cycles(); =20 while (1) { cpu_relax(); status =3D GET_MSEG_HANDLE_STATUS(h); if (status !=3D CCHSTATUS_ACTIVE) break; - if (GRU_OPERATION_TIMEOUT < (get_cycles() - start_time)) { + if (GRU_OP_TIMEOUT_NSEC < (ktime_get() - start_time)) { report_instruction_timeout(h); - start_time =3D get_cycles(); + start_time =3D ktime_get(); } } if (gru_options & OPT_STATS) - update_mcs_stats(opc, get_cycles() - start_time); + update_mcs_stats(opc, (unsigned long)(ktime_get() - start_time)); return status; } =20 --- a/drivers/misc/sgi-gru/grukservices.c +++ b/drivers/misc/sgi-gru/grukservices.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "gru.h" #include "grulib.h" @@ -1106,7 +1107,7 @@ static int quicktest3(unsigned long arg) int ret =3D 0; =20 memset(buf2, 0, sizeof(buf2)); - memset(buf1, get_cycles() & 255, sizeof(buf1)); + memset(buf1, get_random_u32() & 255, sizeof(buf1)); gru_copy_gpa(uv_gpa(buf2), uv_gpa(buf1), BUFSIZE); if (memcmp(buf1, buf2, BUFSIZE)) { printk(KERN_DEBUG "GRU:%d quicktest3 error\n", smp_processor_id()); --- a/drivers/misc/sgi-gru/grutlbpurge.c +++ b/drivers/misc/sgi-gru/grutlbpurge.c @@ -22,13 +22,12 @@ #include #include #include +#include #include #include "gru.h" #include "grutables.h" #include =20 -#define gru_random() get_cycles() - /* ---------------------------------- TLB Invalidation functions -------- * get_tgh_handle * @@ -49,7 +48,7 @@ static inline int get_off_blade_tgh(stru int n; =20 n =3D GRU_NUM_TGH - gru->gs_tgh_first_remote; - n =3D gru_random() % n; + n =3D get_random_u32() % n; n +=3D gru->gs_tgh_first_remote; return n; } From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DD3528469A; Fri, 10 Apr 2026 12:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823570; cv=none; b=i8C6HH9w41IcaD2pHkJzFVDvm8Kf2Dmc3ORiZruIwEqFryN9zAKY9rVGfYCHklK4hQMNxpOj4+vEEvoF06hPITbkJBYQuPO4PCvLTr/Of9YFjeMi6OFHVKUDry8yXi7wKq78aT1QhwC+tY/+fNSqbMFCo2rC93kJEAthThoodk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823570; c=relaxed/simple; bh=gx3RztExl/RgjhE+RVjeBSM72TbSvLK5CUYrt3EY96I=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=RAdwQj2oHkZDVwPH6SQGf4m/Z3+LYM14OcVhlwl7wo5p5LdSs14XHR5KR8wGmfM0pdZfolek6ptPlgoIs0vN9i5pKTibZovdb2dSeOXmHjjH0PKDmJ+ElW5uR2doYSf7RfVZbYsulE20FnKas9qCQ6pr8JUO1VVz7hYCzHE3BnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bpuk5rSR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bpuk5rSR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B4F4C2BCB0; Fri, 10 Apr 2026 12:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823570; bh=gx3RztExl/RgjhE+RVjeBSM72TbSvLK5CUYrt3EY96I=; h=Date:From:To:Cc:Subject:References:From; b=Bpuk5rSRR/rs1jSmitZH/KfJL+3TNuP+dz9xwjVC8e1YVix0oW3s2Pp/y+L8X9oHD FfGXk8B3TY0jbEAZNS2FVq5qwscSTPNozRdmP6S1az7QsSRwh37CnHDegYmWg/dUhl oXkQ09dlNxtpDlZfCfFVBtb5yeQYcj5dZxd8vIShSLkbr1gWWPlcdAHe/FZpu8mplV u5Y93dLHQf7k/6QZkYgksDu7FYlgnX/m++LNPEYIEnDd7dRmUlTkWsJQwVidroG1Bi MdGUi4KzTqg9X+Zn0ce3HiuHIaE9YE1XVzPbK1ak8XvacDL5nVhYnRULjmYf5QSMQ0 DvaPTMl303Xmg== Date: Fri, 10 Apr 2026 14:19:27 +0200 Message-ID: <20260410120318.386500288@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: linux-wireless@vger.kernel.org, Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 12/38] wifi: wil6210: Replace get_cyles() usage References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no reason why this debug code requires to use get_cycles() for timing purposes. Use ktime_get() instead. Signed-off-by: Thomas Gleixner Cc: linux-wireless@vger.kernel.org --- drivers/net/wireless/ath/wil6210/debugfs.c | 2 +- drivers/net/wireless/ath/wil6210/txrx.c | 6 +++--- drivers/net/wireless/ath/wil6210/txrx_edma.c | 4 ++-- drivers/net/wireless/ath/wil6210/wil6210.h | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -151,7 +151,7 @@ static int ring_show(struct seq_file *s, char name[10]; char sidle[10]; /* performance monitoring */ - cycles_t now =3D get_cycles(); + ktime_t now =3D ktime_get(); uint64_t idle =3D txdata->idle * 100; uint64_t total =3D now - txdata->begin; =20 --- a/drivers/net/wireless/ath/wil6210/txrx.c +++ b/drivers/net/wireless/ath/wil6210/txrx.c @@ -1976,7 +1976,7 @@ static int __wil_tx_vring_tso(struct wil used =3D wil_ring_used_tx(vring); if (wil_val_in_range(wil->ring_idle_trsh, used, used + descs_used)) { - txdata->idle +=3D get_cycles() - txdata->last_idle; + txdata->idle +=3D ktime_get() - txdata->last_idle; wil_dbg_txrx(wil, "Ring[%2d] not idle %d -> %d\n", vring_index, used, used + descs_used); } @@ -2129,7 +2129,7 @@ static int __wil_tx_ring(struct wil6210_ used =3D wil_ring_used_tx(ring); if (wil_val_in_range(wil->ring_idle_trsh, used, used + nr_frags + 1)) { - txdata->idle +=3D get_cycles() - txdata->last_idle; + txdata->idle +=3D ktime_get() - txdata->last_idle; wil_dbg_txrx(wil, "Ring[%2d] not idle %d -> %d\n", ring_index, used, used + nr_frags + 1); } @@ -2531,7 +2531,7 @@ int wil_tx_complete(struct wil6210_vif * used_new, used_before_complete)) { wil_dbg_txrx(wil, "Ring[%2d] idle %d -> %d\n", ringid, used_before_complete, used_new); - txdata->last_idle =3D get_cycles(); + txdata->last_idle =3D ktime_get(); } =20 /* shall we wake net queues? */ --- a/drivers/net/wireless/ath/wil6210/txrx_edma.c +++ b/drivers/net/wireless/ath/wil6210/txrx_edma.c @@ -1286,7 +1286,7 @@ int wil_tx_sring_handler(struct wil6210_ used_new, used_before_complete)) { wil_dbg_txrx(wil, "Ring[%2d] idle %d -> %d\n", ring_id, used_before_complete, used_new); - txdata->last_idle =3D get_cycles(); + txdata->last_idle =3D ktime_get(); } =20 again: @@ -1499,7 +1499,7 @@ static int __wil_tx_ring_tso_edma(struct used =3D wil_ring_used_tx(ring); if (wil_val_in_range(wil->ring_idle_trsh, used, used + descs_used)) { - txdata->idle +=3D get_cycles() - txdata->last_idle; + txdata->idle +=3D ktime_get() - txdata->last_idle; wil_dbg_txrx(wil, "Ring[%2d] not idle %d -> %d\n", ring_index, used, used + descs_used); } --- a/drivers/net/wireless/ath/wil6210/wil6210.h +++ b/drivers/net/wireless/ath/wil6210/wil6210.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "wmi.h" #include "wil_platform.h" #include "fw.h" @@ -632,7 +633,7 @@ struct wil_txrx_ops { struct wil_ring_tx_data { bool dot1x_open; int enabled; - cycles_t idle, last_idle, begin; + ktime_t idle, last_idle, begin; u8 agg_wsize; /* agreed aggregation window, 0 - no agg */ u16 agg_timeout; u8 agg_amsdu; From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 810AB3BADB4; Fri, 10 Apr 2026 12:19:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823575; cv=none; b=ofgh+PvuO0lxABxnJ5gkDdfHST6+naXUl7euh22VIARdnNwmpQwHdJnlCVI2dRd9IJVf8inMUMRrqS5VXeyuYBCryzTOYvWClXAptY/V0/Up8vKsN8IoyJWXHEw9OfEIjvGJ0902L8qRYtyE39f1qcwsjO/Pwcgi6R5GZ58w0as= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823575; c=relaxed/simple; bh=GB9a/XQKSHIwV9FYvefMOZoOdepkVaVbWcUyHQeAJMw=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=raGfblO+FxRYKmmu0rrIwE83eUii33gUA+Qd3o14/8XlIYmb2m5jpdm83UN+OYtHvMn1M29xxLaOPLBR39zIlm+FxFsVZV0ITd1zyVcI1sckJCHKNB1fi264dD3zs1i/5t/iw+XAITqJa7Q9uRj+zeWkKqvx/FqB16DbyWIvBpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kdLSbwwL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kdLSbwwL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D535C19421; Fri, 10 Apr 2026 12:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823575; bh=GB9a/XQKSHIwV9FYvefMOZoOdepkVaVbWcUyHQeAJMw=; h=Date:From:To:Cc:Subject:References:From; b=kdLSbwwLxIuQWDxnaQ43x3JS9cXZHSMpULEhhU8ID9ECY5jS+n7m20CMk0YroM4U5 D4FjOptptOJeolxHIofJ3rTeQ/ALPjLpvnJ7Qi7NqzIwHDqURUXi9DJGGx8dZS+lLk JCAzGIYvaKballV64My3qHcmSE8ptIN1eu7xnjzlOO9PgVdkDRLJV0RvV58tiiKr4i bv+wJwmXD1eqFR2U5N9wMLLyoNfqxlEArSV4W94QZ6qgCudbzRKlUn/CHtSVarPoCX xb06JWRkDGSiFGx6qUkcv+KUlCb5xHLy85m3KWHYpSlfnAmYw64l8Tsoi4lMULg/pB WwpH4H0qB6HQQ== Date: Fri, 10 Apr 2026 14:19:31 +0200 Message-ID: <20260410120318.454577282@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Herbert Xu , linux-crypto@vger.kernel.org, Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 13/38] crypto: tcrypt: Replace get_cycles() with ktime_get() References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" get_cycles() is the historical access to a fine grained time source, but it is a suboptimal choice for two reasons: - get_cycles() is not guaranteed to be supported and functional on all systems/platforms. If not supported or not functional it returns 0, which makes benchmarking moot. - get_cycles() returns the raw counter value of whatever the architecture platform provides. The original x86 Time Stamp Counter (TSC) was despite its name tied to the actual CPU core frequency. That's not longer the case. So the counter value is only meaningful when the CPU operates at the same frequency as the TSC or the value is adjusted to the actual CPU frequency. Other architectures and platforms provide similar disjunct counters via get_cycles(), so the result is operations per BOGO-cycles, which is not really meaningful. Use ktime_get() instead which provides nanosecond timestamps with the granularity of the underlying hardware counter, which is not different to the variety of get_cycles() implementations. This provides at least understandable metrics, i.e. operations/nanoseconds, and is available on all platforms. As with get_cycles() the result might have to be put into relation with the CPU operating frequency, but that's not any different. This is part of a larger effort to remove get_cycles() usage from non-architecture code. Signed-off-by: Thomas Gleixner Cc: Herbert Xu Cc: linux-crypto@vger.kernel.org --- crypto/tcrypt.c | 84 ++++++++++++++++++++++++++++-----------------------= ----- 1 file changed, 42 insertions(+), 42 deletions(-) --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -202,7 +202,7 @@ static int test_mb_aead_jiffies(struct t static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc, int blen, u32 num_mb) { - unsigned long cycles =3D 0; + unsigned long nsecs =3D 0; int ret =3D 0; int i; int *rc; @@ -220,20 +220,20 @@ static int test_mb_aead_cycles(struct te =20 /* The real thing. */ for (i =3D 0; i < 8; i++) { - cycles_t start, end; + ktime_t start, end; =20 - start =3D get_cycles(); + start =3D ktime_get(); ret =3D do_mult_aead_op(data, enc, num_mb, rc); - end =3D get_cycles(); + end =3D ktime_get(); =20 if (ret) goto out; =20 - cycles +=3D end - start; + nsecs +=3D (unsigned long)(end - start); } =20 - pr_cont("1 operation in %lu cycles (%d bytes)\n", - (cycles + 4) / (8 * num_mb), blen); + pr_cont("1 operation in %lu nsecs (%d bytes)\n", + nsecs / (8 * num_mb), blen); =20 out: kfree(rc); @@ -475,7 +475,7 @@ static int test_aead_jiffies(struct aead =20 static int test_aead_cycles(struct aead_request *req, int enc, int blen) { - unsigned long cycles =3D 0; + unsigned long nsecs =3D 0; int ret =3D 0; int i; =20 @@ -492,25 +492,24 @@ static int test_aead_cycles(struct aead_ =20 /* The real thing. */ for (i =3D 0; i < 8; i++) { - cycles_t start, end; + ktime_t start, end; =20 - start =3D get_cycles(); + start =3D ktime_get(); if (enc) ret =3D do_one_aead_op(req, crypto_aead_encrypt(req)); else ret =3D do_one_aead_op(req, crypto_aead_decrypt(req)); - end =3D get_cycles(); + end =3D ktime_get(); =20 if (ret) goto out; =20 - cycles +=3D end - start; + nsecs +=3D (unsigned long)(end - start); } =20 out: if (ret =3D=3D 0) - pr_cont("1 operation in %lu cycles (%d bytes)\n", - (cycles + 4) / 8, blen); + pr_cont("1 operation in %lu nsecs (%d bytes)\n", nsecs / 8, blen); =20 return ret; } @@ -771,7 +770,7 @@ static int test_ahash_jiffies(struct aha static int test_ahash_cycles_digest(struct ahash_request *req, int blen, char *out) { - unsigned long cycles =3D 0; + unsigned long nsecs =3D 0; int ret, i; =20 /* Warm-up run. */ @@ -783,25 +782,25 @@ static int test_ahash_cycles_digest(stru =20 /* The real thing. */ for (i =3D 0; i < 8; i++) { - cycles_t start, end; + ktime_t start, end; =20 - start =3D get_cycles(); + start =3D ktime_get(); =20 ret =3D do_one_ahash_op(req, crypto_ahash_digest(req)); if (ret) goto out; =20 - end =3D get_cycles(); + end =3D ktime_get(); =20 - cycles +=3D end - start; + nsecs +=3D (unsigned long)(end - start); } =20 out: if (ret) return ret; =20 - pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", - cycles / 8, cycles / (8 * blen)); + pr_cont("%6lu nsecs/operation, %4lu nsecs/byte\n", + nsecs / 8, nsecs / (8 * blen)); =20 return 0; } @@ -809,7 +808,7 @@ static int test_ahash_cycles_digest(stru static int test_ahash_cycles(struct ahash_request *req, int blen, int plen, char *out) { - unsigned long cycles =3D 0; + unsigned long nsecs =3D 0; int i, pcount, ret; =20 if (plen =3D=3D blen) @@ -832,9 +831,9 @@ static int test_ahash_cycles(struct ahas =20 /* The real thing. */ for (i =3D 0; i < 8; i++) { - cycles_t start, end; + ktime_t start, end; =20 - start =3D get_cycles(); + start =3D ktime_get(); =20 ret =3D do_one_ahash_op(req, crypto_ahash_init(req)); if (ret) @@ -848,17 +847,17 @@ static int test_ahash_cycles(struct ahas if (ret) goto out; =20 - end =3D get_cycles(); + end =3D ktime_get(); =20 - cycles +=3D end - start; + nsecs +=3D (unsigned long)(end - start); } =20 out: if (ret) return ret; =20 - pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", - cycles / 8, cycles / (8 * blen)); + pr_cont("%6lu nsecs/operation, %4lu nsecs/byte\n", + nsecs / 8, nsecs / (8 * blen)); =20 return 0; } @@ -1019,7 +1018,7 @@ static int test_mb_acipher_jiffies(struc static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int = enc, int blen, u32 num_mb) { - unsigned long cycles =3D 0; + unsigned long nsecs =3D 0; int ret =3D 0; int i; int *rc; @@ -1037,20 +1036,20 @@ static int test_mb_acipher_cycles(struct =20 /* The real thing. */ for (i =3D 0; i < 8; i++) { - cycles_t start, end; + ktime_t start, end; =20 - start =3D get_cycles(); + start =3D ktime_get(); ret =3D do_mult_acipher_op(data, enc, num_mb, rc); - end =3D get_cycles(); + end =3D ktime_get(); =20 if (ret) goto out; =20 - cycles +=3D end - start; + nsecs +=3D (unsigned long)(end - start); } =20 - pr_cont("1 operation in %lu cycles (%d bytes)\n", - (cycles + 4) / (8 * num_mb), blen); + pr_cont("1 operation in %lu nsecs (%d bytes)\n", + nsecs / (8 * num_mb), blen); =20 out: kfree(rc); @@ -1246,7 +1245,7 @@ static int test_acipher_jiffies(struct s static int test_acipher_cycles(struct skcipher_request *req, int enc, int blen) { - unsigned long cycles =3D 0; + unsigned long nsecs =3D 0; int ret =3D 0; int i; =20 @@ -1265,27 +1264,28 @@ static int test_acipher_cycles(struct sk =20 /* The real thing. */ for (i =3D 0; i < 8; i++) { - cycles_t start, end; + ktime_t start, end; + + start =3D ktime_get(); =20 - start =3D get_cycles(); if (enc) ret =3D do_one_acipher_op(req, crypto_skcipher_encrypt(req)); else ret =3D do_one_acipher_op(req, crypto_skcipher_decrypt(req)); - end =3D get_cycles(); + end =3D ktime_get(); =20 if (ret) goto out; =20 - cycles +=3D end - start; + nsecs +=3D (unsigned long)(end - start); } =20 out: if (ret =3D=3D 0) - pr_cont("1 operation in %lu cycles (%d bytes)\n", - (cycles + 4) / 8, blen); + pr_cont("1 operation in %lu nsecs (%d bytes)\n", + nsecs / 8, blen); =20 return ret; } From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F17893C2796; Fri, 10 Apr 2026 12:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823581; cv=none; b=FGSXAKLbSldCW8kqpcDfovOn7dp6B/KmE4GRkGPgBzwZ70Jt0Dv619+GFhaTpYJr3u6hF2gyiegADdKjJsK9pGNz0N5Ljrqxrmao0jgszes0AIhjSAx7K8dI9CmwVwbvC5l9qMQpAOghO4H++/PQle+P6GA8IDChBd8kgQzA6D0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823581; c=relaxed/simple; bh=mpxbBHJF6rhzMhSEUiQvC99JYsoAEEbwdTduYzlxEPc=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=PWzpHJsGJ95ZpSdmi7jv9VUsEAguClmHJCb4KLnt5cynnRM2bJ93YuzbYGc6dBH/Csyhqa+mkPe7LNJNYwS/fv1zraF2i/Z5oEjkwQfihVOYQMblhuy0h/2qmhJtue+KJy+WbJHORfIAEkoNmR4NO4dQiBIRfqhLhwz13iiBMTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t3jBR9hr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t3jBR9hr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F0FAC19421; Fri, 10 Apr 2026 12:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823580; bh=mpxbBHJF6rhzMhSEUiQvC99JYsoAEEbwdTduYzlxEPc=; h=Date:From:To:Cc:Subject:References:From; b=t3jBR9hrloEPurMHDq+39Qmu/knh8sc4zRVE8/2evrp72m0jjf5ZLkiqhTfHJf3lQ UuLDw1roDamtB5PCEFrCj4Am/iqY2B6Eqxv0IhuFUbghxXFtjb45YYjGv/1iSpakD6 TFwz04dexWQxc2lpHNkB6gue2paUp+SphQGzt3h2nfY78uDiPTzZOojY3e61FIsW5V nWhQqjnOO5JiF4o/mhmPEmcNABsipUeHkNa04EcUPJl0rFmYRv/1fqlaU1qeGqFkTx Wm9D7sRbThBkNSUjiYqRay+oEzZSBtooNF5Q5Yp17uiVAaos9NzjDw3gIyxmgs/heb T0VBqEkO+l/iw== Date: Fri, 10 Apr 2026 14:19:37 +0200 Message-ID: <20260410120318.525653921@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Vlastimil Babka , linux-mm@kvack.org, Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, David Woodhouse , Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 14/38] slub: Use prandom instead of get_cycles() References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The decision whether to scan remote nodes is based on a 'random' number retrieved via get_cycles(). get_cycles() is about to be removed. There is already prandom state in the code, so use that instead. Signed-off-by: Thomas Gleixner Cc: Vlastimil Babka Cc: linux-mm@kvack.org Acked-by: Harry Yoo (Oracle) Acked-by: Vlastimil Babka (SUSE) --- mm/slub.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) --- a/mm/slub.c +++ b/mm/slub.c @@ -3302,6 +3302,25 @@ static inline struct slab *alloc_slab_pa return slab; } =20 +#if defined(CONFIG_SLAB_FREELIST_RANDOM) || defined(CONFIG_NUMA) +static DEFINE_PER_CPU(struct rnd_state, slab_rnd_state); + +static unsigned int slab_get_prandom_state(unsigned int limit) +{ + struct rnd_state *state; + unsigned int res; + + /* + * An interrupt or NMI handler might interrupt and change + * the state in the middle, but that's safe. + */ + state =3D &get_cpu_var(slab_rnd_state); + res =3D prandom_u32_state(state) % limit; + put_cpu_var(slab_rnd_state); + return res; +} +#endif + #ifdef CONFIG_SLAB_FREELIST_RANDOM /* Pre-initialize the random sequence cache */ static int init_cache_random_seq(struct kmem_cache *s) @@ -3365,8 +3384,6 @@ static void *next_freelist_entry(struct return (char *)start + idx; } =20 -static DEFINE_PER_CPU(struct rnd_state, slab_rnd_state); - /* Shuffle the single linked freelist based on a random pre-computed seque= nce */ static bool shuffle_freelist(struct kmem_cache *s, struct slab *slab, bool allow_spin) @@ -3383,15 +3400,7 @@ static bool shuffle_freelist(struct kmem if (allow_spin) { pos =3D get_random_u32_below(freelist_count); } else { - struct rnd_state *state; - - /* - * An interrupt or NMI handler might interrupt and change - * the state in the middle, but that's safe. - */ - state =3D &get_cpu_var(slab_rnd_state); - pos =3D prandom_u32_state(state) % freelist_count; - put_cpu_var(slab_rnd_state); + pos =3D slab_get_prandom_state(freelist_count); } =20 page_limit =3D slab->objects * s->size; @@ -3882,7 +3891,7 @@ static void *get_from_any_partial(struct * with available objects. */ if (!s->remote_node_defrag_ratio || - get_cycles() % 1024 > s->remote_node_defrag_ratio) + slab_get_prandom_state(1024) > s->remote_node_defrag_ratio) return NULL; =20 do { @@ -7102,7 +7111,7 @@ static unsigned int =20 /* see get_from_any_partial() for the defrag ratio description */ if (!s->remote_node_defrag_ratio || - get_cycles() % 1024 > s->remote_node_defrag_ratio) + slab_get_prandom_state(1024) > s->remote_node_defrag_ratio) return 0; =20 do { @@ -8421,7 +8430,7 @@ void __init kmem_cache_init_late(void) flushwq =3D alloc_workqueue("slub_flushwq", WQ_MEM_RECLAIM | WQ_PERCPU, 0); WARN_ON(!flushwq); -#ifdef CONFIG_SLAB_FREELIST_RANDOM +#if defined(CONFIG_SLAB_FREELIST_RANDOM) || defined(CONFIG_NUMA) prandom_init_once(&slab_rnd_state); #endif } From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DBD3C8731; Fri, 10 Apr 2026 12:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823585; cv=none; b=uDIIzPl6EkdrzAYSzLENkCYTsuG60ORaXJERlu2PfC7G0ivYQbrYCGMG0VEaeojnUO/mrZQnrjCZhiiGISh9/0LtebmMzKN2PU4rApAmNQaKgY50FHw3BgbaVTBs5yqBdUaCdk6a32IhLmcexUD8zz3/Ku3hCVM+SwDObMbU2Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823585; c=relaxed/simple; bh=QeSclCuMiRAS5wk6lWoviUdmtawCgYPJK7955XSCrpk=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=XD9CRe/CrB1xSZMARoEF2zB19OwDGKRmcG+xcIIm3i5PksMiNFlffOU+8CRA8JOrWyJ7Xc+hCsD1LYtnM4K33gViWPZ65NExz+c08nGUSA8bh062gHltzvUT0bC1FUXruCHxWRazERHqUvkgwYLbP4p2IlZzdFc9NWyToXXJ/6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lx7PSe/P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lx7PSe/P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F75AC2BC9E; Fri, 10 Apr 2026 12:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823585; bh=QeSclCuMiRAS5wk6lWoviUdmtawCgYPJK7955XSCrpk=; h=Date:From:To:Cc:Subject:References:From; b=lx7PSe/PjadVTpIMwJdhAJBLt/wkFkRfbRhizAqdCmT18BPcbSlnMFeRTECetW5Mz e18kIbNIOdNmzSRNcljN5MiUEDzdauvDtZpRrKPYAQq6HuU0ixY90WW/AT9/9BP1TE G0pmyVH8DHnvheD/Jtznb1TEyB0LG5ezsRLYR23JSrj8T1XCNh6BmAZvkaj4VTBCOk FjtLvndHPm1jEFcE8PqfK7D9YifyYmXQkYky/wPITICuSdRrICGnLkZ3jZxe25sBaP q8ggvP1HMAsaRRMlhxP+iwStOOzZHUsvv+/U0DMMTE0lc38vp99aMg2cqhdxuGrXAu mqm2UYpSfgZaw== Date: Fri, 10 Apr 2026 14:19:42 +0200 Message-ID: <20260410120318.592237447@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: David Woodhouse , Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, Bernie Thompson , linux-fbdev@vger.kernel.org, "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 15/38] ptp: ptp_vmclock: Replace get_cycles() usage References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" get_cycles() is not really well defined and similar to other usaage of the underlying hardware CPU counters the PTP vmclock should use an explicit interface as well. Implement ptp_vmclock_read_cpu_counter() in arm64 and x86 and simplify the Kconfig selection while at it. No functional change. Signed-off-by: Thomas Gleixner Cc: David Woodhouse Acked-by: David Woodhouse --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/ptp_vmclock.h | 12 ++++++++++++ arch/x86/Kconfig | 1 + arch/x86/include/asm/ptp_vmclock.h | 12 ++++++++++++ drivers/ptp/Kconfig | 6 ++++-- drivers/ptp/ptp_vmclock.c | 6 ++++-- 6 files changed, 34 insertions(+), 4 deletions(-) --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -112,6 +112,7 @@ config ARM64 select ARCH_SUPPORTS_SCHED_SMT select ARCH_SUPPORTS_SCHED_CLUSTER select ARCH_SUPPORTS_SCHED_MC + select ARCH_SUPPORTS_PTP_VMCLOCK if ARCH_SUPPORTS_INT128 select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT select ARCH_WANT_DEFAULT_BPF_JIT --- /dev/null +++ b/arch/arm64/include/asm/ptp_vmclock.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_PTP_VMCLOCK_H +#define __ASM_PTP_VMCLOCK_H + +#include + +static inline u64 ptp_vmclock_read_cpu_counter(void) +{ + return arch_timer_read_counter(); +} + +#endif --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -135,6 +135,7 @@ config X86 select ARCH_SUPPORTS_RT select ARCH_SUPPORTS_AUTOFDO_CLANG select ARCH_SUPPORTS_PROPELLER_CLANG if X86_64 + select ARCH_SUPPORTS_PTP_VMCLOCK if X86_TSC select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if X86_CX8 select ARCH_USE_MEMTEST --- /dev/null +++ b/arch/x86/include/asm/ptp_vmclock.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_PTP_VMCLOCK_H +#define __ASM_PTP_VMCLOCK_H + +#include + +static inline u64 ptp_vmclock_read_cpu_counter(void) +{ + return cpu_feature_enabled(X86_FEATURE_TSC) ? rdtsc() : 0; +} + +#endif --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -131,10 +131,12 @@ config PTP_1588_CLOCK_KVM To compile this driver as a module, choose M here: the module will be called ptp_kvm. =20 +config ARCH_SUPPORTS_PTP_VMCLOCK + bool + config PTP_1588_CLOCK_VMCLOCK tristate "Virtual machine PTP clock" - depends on X86_TSC || ARM_ARCH_TIMER - depends on PTP_1588_CLOCK && ARCH_SUPPORTS_INT128 + depends on PTP_1588_CLOCK && ARCH_SUPPORTS_PTP_VMCLOCK default PTP_1588_CLOCK_KVM help This driver adds support for using a virtual precision clock --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -28,6 +28,8 @@ =20 #include =20 +#include + #ifdef CONFIG_X86 #include #include @@ -144,11 +146,11 @@ static int vmclock_get_crosststamp(struc if (systime_snapshot.cs_id =3D=3D st->cs_id) { cycle =3D systime_snapshot.cycles; } else { - cycle =3D get_cycles(); + cycle =3D ptp_vmclock_read_cpu_counter(); ptp_read_system_postts(sts); } } else { - cycle =3D get_cycles(); + cycle =3D ptp_vmclock_read_cpu_counter(); } =20 delta =3D cycle - le64_to_cpu(st->clk->counter_value); From nobody Mon Jun 15 13:39:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D2137DE96; Fri, 10 Apr 2026 12:19:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823590; cv=none; b=dTl4tKcdQ4/iwzVpq5qkkc6IVN7VHh9WEXbfpOT+xWe7EWerc/xv2dvsHM3FNxkgmBMZWCFPAf5+JHSm6m/0l9fGrOCk0uyBQnnR3Lme9CAtLOcsfg3+hQ7zUouQU0AY+QYXoddWCFJCEWrN8hYk+m9N8wpJ6heihZ4+X8T3XfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775823590; c=relaxed/simple; bh=r17Pe0N1ahBhrB3JYh2nj0lozuwWxFWE8s4wbHnNz1U=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=LaNkLv/JG7BZsfehwcyrh4pS9fsCCcGrRH0IN+S4JTBwN7FfTeOZ7FCztdt3R4jCXe5h2aoqCHUQI1gb572reKNb9m85twmbNWAXUb49vdiauJxQZtBUB31di4FroogJPw5AzzJWclj4y0dW4USXNEpR0ZywVJgZMZBrdhUxdJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=okWRwWiK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="okWRwWiK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 704BDC19425; Fri, 10 Apr 2026 12:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775823590; bh=r17Pe0N1ahBhrB3JYh2nj0lozuwWxFWE8s4wbHnNz1U=; h=Date:From:To:Cc:Subject:References:From; b=okWRwWiKRXWxIOYd0Peg6lhswEXmgs6TDBmjhAnD7Q9a6usCqNg9OYWu+roqFftQt CXuq9wugiKbiMxTD+p64hE/DfyXI2OVOyYyt+MQaYOMvBz3HQvYNGX8W9+b4gE14hU 1DViHL5lpk9k7rS0TYmec/vPv8+l0l72HHkjevm3yaDtlLwCxfiyVTiYsTY5w9OTh5 Ju9iD//e8k54q8KUH3ojDg3WjR+Vu3B/cuQgNtmo0Zn1MW3hNX3wOdJ7kCRM+fO7Bg 3Yz29lBDAALUYxAqFMkB8dpm5Y3XPhihE7EzHhldnKqOW+zQ+3nRrzSdk9MbluRvBK 0NZT2IviOMPvg== Date: Fri, 10 Apr 2026 14:19:47 +0200 Message-ID: <20260410120318.658719117@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Bernie Thompson , linux-fbdev@vger.kernel.org, Arnd Bergmann , x86@kernel.org, Lu Baolu , iommu@lists.linux.dev, Michael Grzeschik , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org, Vlastimil Babka , linux-mm@kvack.org, David Woodhouse , "Theodore Tso" , linux-ext4@vger.kernel.org, Andrew Morton , Uladzislau Rezki , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Andrey Ryabinin , Thomas Sailer , linux-hams@vger.kernel.org, "Jason A. Donenfeld" , Richard Henderson , linux-alpha@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Huacai Chen , loongarch@lists.linux.dev, Geert Uytterhoeven , linux-m68k@lists.linux-m68k.org, Dinh Nguyen , Jonas Bonn , linux-openrisc@vger.kernel.org, Helge Deller , linux-parisc@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , linux-riscv@lists.infradead.org, Heiko Carstens , linux-s390@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [patch 16/38] fbdev: udlfb: Replace get_cycles() with ktime_get() References: <20260410120044.031381086@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" These metrics are not really requiring CPU cycles and as those are meanlingless when the CPU is running at a different frequency, this can use ktime_get() and achieve the same result. Part of a larger effort to confine get_cycles() access to low level architecture code. Signed-off-by: Thomas Gleixner Cc: Bernie Thompson Cc: linux-fbdev@vger.kernel.org --- Documentation/fb/udlfb.rst | 4 ++-- drivers/video/fbdev/udlfb.c | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) --- a/Documentation/fb/udlfb.rst +++ b/Documentation/fb/udlfb.rst @@ -156,8 +156,8 @@ metrics_bytes_sent 32-bit count of how USB to communicate the resulting changed pixels to the hardware. Includes compression and protocol overhead =20 -metrics_cpu_kcycles_used 32-bit count of CPU cycles used in processing the - above pixels (in thousands of cycles). +metrics_cpu_kcycles_used 32-bit count of microseconds used in processing t= he + above pixels =20 metrics_reset Write-only. Any write to this file resets all metrics above to zero. Note that the 32-bit counters above --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -24,6 +24,7 @@ #include #include #include +#include #include