[PW_SID:1079742] treewide: Cleanup LATCH, CLOCK_TICK_RATE and get_cycles() [ab]use#1752
[PW_SID:1079742] treewide: Cleanup LATCH, CLOCK_TICK_RATE and get_cycles() [ab]use#1752linux-riscv-bot wants to merge 38 commits into
Conversation
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 <tglx@kernel.org Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Calculating the timeout from get_cycles() is a historical leftover without any functional requirement. Use ktime_get() instead. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: x86@kernel.org Cc: Lu Baolu <baolu.lu@linux.intel.com> Cc: iommu@lists.linux.dev Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
ARCNET is a museums piece and the function timing can be done with ftrace. Remove the cruft. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Cc: netdev@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Calculating a timeout from get_cycles() is a historical leftover without any functional requirement. Use ktime_get() instead. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Cc: linux-wireless@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: linux-mm@kvack.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org> Cc: Bernie Thompson <bernie@plugable.com> Cc: linux-fbdev@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
get_cycles() is not guaranteed to be functional on all systems/platforms and the values returned are unitless and not easy to map to something useful. Use ktime_get() instead, which provides nanosecond timestamps and is functional everywhere. This is part of a larger effort to limit get_cycles() usage to low level architecture code. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: linux-ext4@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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 <tglx@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Uladzislau Rezki <urezki@gmail.com>
Cc: linux-mm@kvack.org
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
KCSAN uses get_cycles() for two purposes:
1) Seeding the random state with get_cycles() is a historical leftover.
2) The microbenchmark uses get_cycles(), which provides an unit less
counter value and is not guaranteed to be functional on all
systems/platforms.
Use random_get_entropy() for seeding the random state and ktime_get() which
is universaly functional and provides at least a comprehensible unit.
This is part of a larger effort to remove get_cycles() usage from
non-architecture code.
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: kasan-dev@googlegroups.com
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Seeding the random state with get_cycles() is functionally equivalent on the architectures which provide get_cycles(), but it does not make sense semantically. Use random_get_entropy() instead, which is the proper interface. This is part of a larger effort to remove get_cycles() usage from non-architecture code. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: kasan-dev@googlegroups.com Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The whole code guarded by BAYCOM_DEBUG is only writing debug values into a datastructure, but there is no way to ever access them. Remove the pointless ballast. This is part of a larger effort to remove get_cycles() usage from non-architecture code. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Thomas Sailer <t.sailer@alumni.ethz.ch> Cc: linux-hams@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Chasing down to what random_get_entropy() resolves is a 'spot the mouse' game through a maze of #ifdeffery. Also the placement in timex.h is non-obvious and has just been chosen because it provides conveniant access to the underlying get_cycles() #ifdeffery. Provide a config switch which is selectable by the architecture and a temporary #ifdef guard in timex.h. Architectures which select the config switch must provide asm/random.h with the architecture specific implementation. Update all usage sites to include linux/random.h so that the gradual conversion does not cause build regressions. This is part of a larger effort to remove get_cycles() usage from non-architecture code. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: "Jason A. Donenfeld" <Jason@zx2c4.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining usage of get_cycles() is to provide random_get_entropy(). Switch alpha over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Remove asm/timex.h as it has no functionality anymore. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Richard Henderson <richard.henderson@linaro.org> Cc: linux-alpha@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining usage of get_cycles() is to provide random_get_entropy(). Switch ARM over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Remove asm/timex.h as it has no functionality anymore. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Russell King <linux@armlinux.org.uk> Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining usage of get_cycles() is to provide random_get_entropy(). Switch arm64 over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. As a consequence this unearthed a nasty include dependecy hell where random code including rqspinlock.h relies on a magic include of asm/arch_timer.h. Including the headers in asm/random.h turned out to be impossible as well. The only solution for now is to uninline random_get_entropy(). Fix up all other dependencies on the content of asm/timex.h in those files which really depend on it. Remove asm/timex.h as it has no functionality anymore. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining non-architecture usage of get_cycles() is to provide random_get_entropy(). Switch loongarch over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Add 'asm/timex.h' includes to the relevant files, so the global include can be removed once all architectures are converted over. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: loongarch@lists.linux.dev Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining usage of get_cycles() is to provide random_get_entropy(). Switch m68k over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Remove asm/timex.h as it has no functionality anymore. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: linux-m68k@lists.linux-m68k.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining usage of get_cycles() is to provide random_get_entropy(). Switch mips over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. As a consequence this unearthed a nasty include dependency hell because arbitrary code relies on a magic include of asm/timex.h. Including the headers in asm/random.h turned out to be impossible as well. The only solution for now is to uninline random_get_entropy(). Fix up all other dependencies on the content of asm/timex.h in those files which really depend on it. Remove asm/timex.h as it has no functionality anymore. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining non-architecture usage of get_cycles() is to provide random_get_entropy(). Switch nios2 over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Add 'asm/timex.h' includes to the relevant files, so the global include can be removed once all architectures are converted over. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Dinh Nguyen <dinguyen@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The only remaining non-architecture usage of get_cycles() is to provide random_get_entropy(). Switch openrisc over to the new scheme of selecting ARCH_HAS_RANDOM_ENTROPY and providing random_get_entropy() in asm/random.h. Add 'asm/timex.h' includes to the relevant files, so the global include can be removed once all architectures are converted over. Signed-off-by: Thomas Gleixner <tglx@kernel.org> Cc: Jonas Bonn <jonas@southpole.se> Cc: linux-openrisc@vger.kernel.org Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 36: "[36/38] sparc: Select ARCH_HAS_RANDOM_ENTROPY for SPARC64" |
|
Patch 36: "[36/38] sparc: Select ARCH_HAS_RANDOM_ENTROPY for SPARC64" |
|
Patch 36: "[36/38] sparc: Select ARCH_HAS_RANDOM_ENTROPY for SPARC64" |
|
Patch 36: "[36/38] sparc: Select ARCH_HAS_RANDOM_ENTROPY for SPARC64" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 37: "[37/38] x86: Select ARCH_HAS_RANDOM_ENTROPY" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
|
Patch 38: "[38/38] treewide: Remove asm/timex.h includes from generic code" |
PR for series 1079742 applied to workflow__riscv__fixes
Name: treewide: Cleanup LATCH, CLOCK_TICK_RATE and get_cycles() [ab]use
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1079742
Version: 1