[PATCH] ARM: VDSO: remove cntvct_ok global variable

From: Rasmus Villemoes
Date: Fri Nov 03 2023 - 03:58:18 EST


The cntvct_ok variable has not had any external user since commit
c7a18100bdff ("lib/vdso: Avoid highres update if clocksource is not
VDSO capable").

It also only has one user in vdso.c, once during init, so rather than
having the caller of patch_vdso() initialize cntvct_ok, just call
cntvct_functional() directly and avoid the global variable entirely.

Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
arch/arm/include/asm/vdso/vsyscall.h | 1 -
arch/arm/kernel/vdso.c | 10 +++-------
2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/vdso/vsyscall.h b/arch/arm/include/asm/vdso/vsyscall.h
index 47e41ae8ccd0..9a2cd2673a82 100644
--- a/arch/arm/include/asm/vdso/vsyscall.h
+++ b/arch/arm/include/asm/vdso/vsyscall.h
@@ -9,7 +9,6 @@
#include <asm/cacheflush.h>

extern struct vdso_data *vdso_data;
-extern bool cntvct_ok;

/*
* Update the vDSO data page to keep in sync with kernel timekeeping.
diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c
index f297d66a8a76..ba87ffc6f194 100644
--- a/arch/arm/kernel/vdso.c
+++ b/arch/arm/kernel/vdso.c
@@ -67,11 +67,9 @@ struct elfinfo {
char *dynstr; /* ptr to .dynstr section */
};

-/* Cached result of boot-time check for whether the arch timer exists,
- * and if so, whether the virtual counter is useable.
+/* Boot-time check for whether the arch timer exists, and if so,
+ * whether the virtual counter is useable.
*/
-bool cntvct_ok __ro_after_init;
-
static bool __init cntvct_functional(void)
{
struct device_node *np;
@@ -172,7 +170,7 @@ static void __init patch_vdso(void *ehdr)
* want programs to incur the slight additional overhead of
* dispatching through the VDSO only to fall back to syscalls.
*/
- if (!cntvct_ok) {
+ if (!cntvct_functional()) {
vdso_nullpatch_one(&einfo, "__vdso_gettimeofday");
vdso_nullpatch_one(&einfo, "__vdso_clock_gettime");
vdso_nullpatch_one(&einfo, "__vdso_clock_gettime64");
@@ -213,8 +211,6 @@ static int __init vdso_init(void)
vdso_total_pages = 1; /* for the data/vvar page */
vdso_total_pages += text_pages;

- cntvct_ok = cntvct_functional();
-
patch_vdso(vdso_start);

return 0;
--
2.40.1.1.g1c60b9335d