Skip to contentSkip to conversation

ARM: VDSO: remove cntvct_ok global variable

PATCH In review Rasmus Villemoes 2 participants 2 messages Nov 3, 2023 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: VDSO: remove cntvct_ok global variable

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.

---
 arch/arm/include/asm/vdso/vsyscall.h |  1 -
 arch/arm/kernel/vdso.c               | 10 +++-------
 2 files changed, 3 insertions(+), 8 deletions(-)
arch/arm/include/asm/vdso/vsyscall.h +0 -1
index 47e41ae8ccd0..9a2cd2673a82 100644
@@ -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.
arch/arm/kernel/vdso.c +3 -7
index f297d66a8a76..ba87ffc6f194 100644
@@ -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;
Signature · 1 line
2.40.1.1.g1c60b9335d
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Rasmus Villemoes

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.

Fine by me.

Quoted 53 lines
---
 arch/arm/include/asm/vdso/vsyscall.h |  1 -
 arch/arm/kernel/vdso.c               | 10 +++-------
 2 files changed, 3 insertions(+), 8 deletions(-)
arch/arm/include/asm/vdso/vsyscall.h +0 -1
index 47e41ae8ccd0..9a2cd2673a82 100644
@@ -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.
arch/arm/kernel/vdso.c +3 -7
index f297d66a8a76..ba87ffc6f194 100644
@@ -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;
Signature · 2 lines
Regards,
Vincenzo