Skip to contentSkip to conversation

xen: Remove legacy __read_mostly/__ro_after_init definitions

PATCH In review Andrew Cooper 3 participants 11 messages Sep 5, 2024 – Sep 9, 2024

lore
Share & tools
lore
#0 lore raw

cover xen: Remove legacy __read_mostly/__ro_after_init definitions

This continues prior work done for PPC and RISCV. Patches 1-4 are some header rearranging for x86, with the convenient side effect of letting ARM fall out in the wash in patch 5.

I've done a reasonable amount of Gitlab CI work, but I cant claim to have tried every possible combination. RANDCONFIG might find some transitive paths I haven't spotted.

Andrew Cooper (5):
x86/build: Rework includes in genapic/probe.c xen/build: Drop unused includes of xen/cache.h x86/build: Swap cache.h includes for xen/sections.h x86/cache: Drop legacy __read_mostly/__ro_after_init definitions ARM/cache: Drop legacy __read_mostly/__ro_after_init definitions

 xen/arch/arm/include/asm/cache.h     |  3 ---
 xen/arch/x86/acpi/cpu_idle.c         |  3 ++-
 xen/arch/x86/bzimage.c               |  1 -
 xen/arch/x86/cpu-policy.c            |  2 +-
 xen/arch/x86/dmi_scan.c              |  1 -
 xen/arch/x86/genapic/probe.c         | 34 +++++++++++++---------------
 xen/arch/x86/guest/hypervisor.c      |  2 +-
 xen/arch/x86/include/asm/cache.h     |  3 ---
 xen/arch/x86/include/asm/genapic.h   |  2 ++
 xen/arch/x86/include/asm/processor.h |  1 -
 xen/common/decompress.h              |  1 -
 xen/common/efi/runtime.c             |  3 ++-
 xen/include/acpi/platform/aclinux.h  |  1 -
 xen/include/xen/cache.h              |  5 ----
 xen/include/xen/lib.h                |  1 +
 xen/include/xen/rcupdate.h           |  1 -
 16 files changed, 25 insertions(+), 39 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/5 x86/build: Rework includes in genapic/probe.c

probe.c includes a large number of headers which are unused, and not from churn so far as I can see in history. Strip back to a reasonable set.

One complication is that genapic.h has to include xen/cpumask.h because there's no way to forward declare a cpumask_t.

Also strip trailing whitespace while adjusting the file.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

---
 xen/arch/x86/genapic/probe.c       | 34 ++++++++++++++----------------
 xen/arch/x86/include/asm/genapic.h |  2 ++
 2 files changed, 18 insertions(+), 18 deletions(-)
xen/arch/x86/genapic/probe.c +16 -18
index 10ceeae4d247..946c3d3ce364 100644
@@ -1,25 +1,23 @@
-/* Copyright 2003 Andi Kleen, SuSE Labs. 
- * Subject to the GNU Public License, v.2 
- * 
+/* Copyright 2003 Andi Kleen, SuSE Labs.
+ * Subject to the GNU Public License, v.2
+ *
  * Generic x86 APIC driver probe layer.
- */  
-#include <xen/cpumask.h>
-#include <xen/string.h>
-#include <xen/kernel.h>
-#include <xen/ctype.h>
+ */
+#include <xen/bug.h>
+#include <xen/errno.h>
 #include <xen/init.h>
 #include <xen/param.h>
-#include <asm/cache.h>
-#include <asm/fixmap.h>
-#include <asm/mpspec.h>
-#include <asm/apicdef.h>
-#include <asm/mach-generic/mach_apic.h>
-#include <asm/setup.h>
+#include <xen/sections.h>
+#include <xen/string.h>
+#include <xen/types.h>
+
+#include <asm/apic.h>
+#include <asm/genapic.h>
 
 struct genapic __ro_after_init genapic;
 
 static const struct genapic *const __initconstrel apic_probe[] = {
-	&apic_bigsmp, 
+	&apic_bigsmp,
 	&apic_default,	/* must be last */
 	NULL,
 };
@@ -57,8 +55,8 @@ static int __init cf_check genapic_apic_force(const char *str)
 }
 custom_param("apic", genapic_apic_force);
 
-void __init generic_apic_probe(void) 
-{ 
+void __init generic_apic_probe(void)
+{
 	int i;
 
 	record_boot_APIC_mode();
@@ -75,4 +73,4 @@ void __init generic_apic_probe(void)
 	BUG_ON(!genapic.name);
 
 	printk(KERN_INFO "Using APIC driver %s\n", genapic.name);
-} 
+}
xen/arch/x86/include/asm/genapic.h +2 -0
index 970df8ffe0a4..a694371c6d16 100644
@@ -1,6 +1,8 @@
 #ifndef _ASM_GENAPIC_H
 #define _ASM_GENAPIC_H 1
 
+#include <xen/cpumask.h>
+
 /*
  * Generic APIC driver interface.
  *
Signature · 1 line
2.39.2
Acked-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] x86/build: Rework includes in genapic/probe.c

Quoted 9 lines · Andrew Cooper

probe.c includes a large number of headers which are unused, and not from churn so far as I can see in history. Strip back to a reasonable set.

One complication is that genapic.h has to include xen/cpumask.h because there's no way to forward declare a cpumask_t.

Also strip trailing whitespace while adjusting the file.

#3 lore raw

PATCH 2/5 xen/build: Drop unused includes of xen/cache.h

In reply to Andrew Cooper

None of these are used, not even transitively.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

---
 xen/arch/x86/bzimage.c               | 1 -
 xen/arch/x86/dmi_scan.c              | 1 -
 xen/arch/x86/include/asm/processor.h | 1 -
 xen/common/decompress.h              | 1 -
 xen/include/acpi/platform/aclinux.h  | 1 -
 xen/include/xen/rcupdate.h           | 1 -
 6 files changed, 6 deletions(-)
xen/arch/x86/bzimage.c +0 -1
index ac4fd428be0e..66f648f311e4 100644
@@ -1,4 +1,3 @@
-#include <xen/cache.h>
 #include <xen/errno.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
xen/arch/x86/dmi_scan.c +0 -1
index 81f80c053a7a..811bf355fba6 100644
@@ -3,7 +3,6 @@
 #include <xen/kernel.h>
 #include <xen/string.h>
 #include <xen/init.h>
-#include <xen/cache.h>
 #include <xen/acpi.h>
 #include <asm/io.h>
 #include <asm/system.h>
xen/arch/x86/include/asm/processor.h +0 -1
index e71dbb8d3fbf..26e2fb13699a 100644
@@ -5,7 +5,6 @@
 #define __ASM_X86_PROCESSOR_H
 
 #ifndef __ASSEMBLY__
-#include <xen/cache.h>
 #include <xen/types.h>
 #include <xen/smp.h>
 #include <xen/percpu.h>
xen/common/decompress.h +0 -1
index e8195b353a15..4683eb6c7ea1 100644
@@ -1,6 +1,5 @@
 #ifdef __XEN__
 
-#include <xen/cache.h>
 #include <xen/decompress.h>
 #include <xen/init.h>
 #include <xen/string.h>
xen/include/acpi/platform/aclinux.h +0 -1
index f5e0a6108e0b..a66c2e6d1d8f 100644
@@ -47,7 +47,6 @@
 #define ACPI_USE_SYSTEM_CLIBRARY
 #define ACPI_USE_DO_WHILE_0
 
-#include <xen/cache.h>
 #include <xen/string.h>
 #include <xen/kernel.h>
 #include <xen/ctype.h>
xen/include/xen/rcupdate.h +0 -1
index 6f2587058edb..95f4ad81c4a8 100644
@@ -31,7 +31,6 @@
 #ifndef __XEN_RCUPDATE_H
 #define __XEN_RCUPDATE_H
 
-#include <xen/cache.h>
 #include <xen/compiler.h>
 #include <xen/spinlock.h>
 #include <xen/cpumask.h>
Signature · 1 line
2.39.2
#5 lore raw

PATCH 3/5 x86/build: Swap cache.h includes for xen/sections.h

In reply to Andrew Cooper

These include {xen/asm}/cache.h but only want xen/sections.h.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

---
 xen/arch/x86/acpi/cpu_idle.c    | 3 ++-
 xen/arch/x86/cpu-policy.c       | 2 +-
 xen/arch/x86/guest/hypervisor.c | 2 +-
 xen/common/efi/runtime.c        | 3 ++-
 4 files changed, 6 insertions(+), 4 deletions(-)
xen/arch/x86/acpi/cpu_idle.c +2 -1
index f175e4d7d370..876317fad059 100644
@@ -40,7 +40,8 @@
 #include <xen/param.h>
 #include <xen/trace.h>
 #include <xen/irq.h>
-#include <asm/cache.h>
+#include <xen/sections.h>
+
 #include <asm/io.h>
 #include <asm/iocap.h>
 #include <asm/hpet.h>
xen/arch/x86/cpu-policy.c +1 -1
index 888e7ac4d4dc..2524c1c7a60d 100644
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
-#include <xen/cache.h>
 #include <xen/kernel.h>
 #include <xen/param.h>
 #include <xen/sched.h>
+#include <xen/sections.h>
 
 #include <xen/lib/x86/cpu-policy.h>
 
xen/arch/x86/guest/hypervisor.c +1 -1
index ac80e8324599..7afc5038b4e4 100644
@@ -8,9 +8,9 @@
  */
 #include <xen/cpumask.h>
 #include <xen/init.h>
+#include <xen/sections.h>
 #include <xen/types.h>
 
-#include <asm/cache.h>
 #include <asm/guest.h>
 
 static struct hypervisor_ops __ro_after_init ops;
xen/common/efi/runtime.c +2 -1
index d952c3ba785e..d03e5c90ce9f 100644
@@ -1,9 +1,10 @@
 #include "efi.h"
 #include "runtime.h"
-#include <xen/cache.h>
+
 #include <xen/errno.h>
 #include <xen/guest_access.h>
 #include <xen/irq.h>
+#include <xen/sections.h>
 #include <xen/time.h>
 
 DEFINE_XEN_GUEST_HANDLE(CHAR16);
Signature · 1 line
2.39.2
#7 lore raw

PATCH 4/5 x86/cache: Drop legacy __read_mostly/__ro_after_init definitions

In reply to Andrew Cooper

Lots of files were picking these up transitively, including lib.h

However, lib.h needs __read_mostly for printk_once() and this has the side effect of kicking the transitive can down the road.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

---
 xen/arch/x86/include/asm/cache.h | 3 ---
 xen/include/xen/cache.h          | 2 +-
 xen/include/xen/lib.h            | 1 +
 3 files changed, 2 insertions(+), 4 deletions(-)
xen/arch/x86/include/asm/cache.h +0 -3
index 956c05493e23..f15d10dc7f2d 100644
@@ -9,9 +9,6 @@
 #define L1_CACHE_SHIFT	(CONFIG_X86_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES	(1 << L1_CACHE_SHIFT)
 
-/* TODO: Phase out the use of this via cache.h */
-#define __read_mostly __section(".data.read_mostly")
-
 #ifndef __ASSEMBLY__
 
 void cache_flush(const void *addr, unsigned int size);
xen/include/xen/cache.h +1 -1
index a19942fd63ef..90816ba05b1a 100644
@@ -15,7 +15,7 @@
 #define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
 #endif
 
-#if defined(CONFIG_ARM) || defined(CONFIG_X86)
+#if defined(CONFIG_ARM)
 /* TODO: Phase out the use of this via cache.h */
 #define __ro_after_init __section(".data.ro_after_init")
 #endif
xen/include/xen/lib.h +1 -0
index e884a02ee8ce..81b722ea3e80 100644
@@ -10,6 +10,7 @@
 #include <xen/types.h>
 #include <xen/xmalloc.h>
 #include <xen/string.h>
+#include <xen/sections.h>
 
 #define __ACCESS_ONCE(x) ({                             \
             (void)(typeof(x))0; /* Scalar typecheck. */ \
Signature · 1 line
2.39.2
Acked-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] x86/cache: Drop legacy __read_mostly/__ro_after_init definitions

Quoted 6 lines · Andrew Cooper

Lots of files were picking these up transitively, including lib.h

However, lib.h needs __read_mostly for printk_once() and this has the side effect of kicking the transitive can down the road.

#9 lore raw

PATCH 5/5 ARM/cache: Drop legacy __read_mostly/__ro_after_init definitions

In reply to Andrew Cooper

These are no longer needed.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

---
 xen/arch/arm/include/asm/cache.h | 3 ---
 xen/include/xen/cache.h          | 5 -----
 2 files changed, 8 deletions(-)
xen/arch/arm/include/asm/cache.h +0 -3
index 029b2896fb3e..b75c970b6806 100644
@@ -6,9 +6,6 @@
 #define L1_CACHE_SHIFT  (CONFIG_ARM_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES  (1 << L1_CACHE_SHIFT)
 
-/* TODO: Phase out the use of this via cache.h */
-#define __read_mostly __section(".data.read_mostly")
-
 #endif
 /*
  * Local variables:
xen/include/xen/cache.h +0 -5
index 90816ba05b1a..6ee174efa439 100644
@@ -15,9 +15,4 @@
 #define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
 #endif
 
-#if defined(CONFIG_ARM)
-/* TODO: Phase out the use of this via cache.h */
-#define __ro_after_init __section(".data.ro_after_init")
-#endif
-
 #endif /* __LINUX_CACHE_H */
Signature · 1 line
2.39.2
Acked-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] ARM/cache: Drop legacy __read_mostly/__ro_after_init definitions

Hi Andrew,

Quoted 3 lines · Andrew Cooper

These are no longer needed.

Cheers,

Quoted 41 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>

---
  xen/arch/arm/include/asm/cache.h | 3 ---
  xen/include/xen/cache.h          | 5 -----
  2 files changed, 8 deletions(-)
xen/arch/arm/include/asm/cache.h +0 -3
index 029b2896fb3e..b75c970b6806 100644
@@ -6,9 +6,6 @@
  #define L1_CACHE_SHIFT  (CONFIG_ARM_L1_CACHE_SHIFT)
  #define L1_CACHE_BYTES  (1 << L1_CACHE_SHIFT)
 
-/* TODO: Phase out the use of this via cache.h */
-#define __read_mostly __section(".data.read_mostly")
-
  #endif
  /*
   * Local variables:
xen/include/xen/cache.h +0 -5
index 90816ba05b1a..6ee174efa439 100644
@@ -15,9 +15,4 @@
  #define __cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
  #endif
 
-#if defined(CONFIG_ARM)
-/* TODO: Phase out the use of this via cache.h */
-#define __ro_after_init __section(".data.ro_after_init")
-#endif
-
  #endif /* __LINUX_CACHE_H */
Signature · 1 line
Julien Grall