[PATCH] xen: Use __has_include() in xen/percpu.h

Andrew Cooper posted 1 patch 2 weeks, 1 day ago
xen/arch/arm/include/asm/Makefile   |  1 -
xen/arch/ppc/include/asm/Makefile   |  1 -
xen/arch/riscv/include/asm/Makefile |  1 -
xen/include/asm-generic/percpu.h    | 14 --------------
xen/include/xen/percpu.h            |  4 +++-
5 files changed, 3 insertions(+), 18 deletions(-)
delete mode 100644 xen/include/asm-generic/percpu.h
[PATCH] xen: Use __has_include() in xen/percpu.h
Posted by Andrew Cooper 2 weeks, 1 day ago
Only x86 has an asm/percpu.h.  Have the compiler only include it if it's
present, rather than symlinking an empty file.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <jbeulich@suse.com>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Teddy Astie <teddy.astie@vates.tech>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>

This same pattern can be applied most of the rest of generic-*, and it's high
time we purged that logic.
---
 xen/arch/arm/include/asm/Makefile   |  1 -
 xen/arch/ppc/include/asm/Makefile   |  1 -
 xen/arch/riscv/include/asm/Makefile |  1 -
 xen/include/asm-generic/percpu.h    | 14 --------------
 xen/include/xen/percpu.h            |  4 +++-
 5 files changed, 3 insertions(+), 18 deletions(-)
 delete mode 100644 xen/include/asm-generic/percpu.h

diff --git a/xen/arch/arm/include/asm/Makefile b/xen/arch/arm/include/asm/Makefile
index 4565baca6a4d..a78a498eb566 100644
--- a/xen/arch/arm/include/asm/Makefile
+++ b/xen/arch/arm/include/asm/Makefile
@@ -5,7 +5,6 @@ generic-y += hardirq.h
 generic-y += iocap.h
 generic-y += irq-dt.h
 generic-y += paging.h
-generic-y += percpu.h
 generic-y += random.h
 generic-y += softirq.h
 generic-y += vm_event.h
diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/Makefile
index c989a7f89b34..a5c46704ccad 100644
--- a/xen/arch/ppc/include/asm/Makefile
+++ b/xen/arch/ppc/include/asm/Makefile
@@ -6,7 +6,6 @@ generic-y += hardirq.h
 generic-y += hypercall.h
 generic-y += iocap.h
 generic-y += paging.h
-generic-y += percpu.h
 generic-y += perfc_defn.h
 generic-y += random.h
 generic-y += softirq.h
diff --git a/xen/arch/riscv/include/asm/Makefile b/xen/arch/riscv/include/asm/Makefile
index 86c56251d5d7..d3483699278d 100644
--- a/xen/arch/riscv/include/asm/Makefile
+++ b/xen/arch/riscv/include/asm/Makefile
@@ -6,7 +6,6 @@ generic-y += hardirq.h
 generic-y += hypercall.h
 generic-y += iocap.h
 generic-y += irq-dt.h
-generic-y += percpu.h
 generic-y += random.h
 generic-y += softirq.h
 generic-y += vm_event.h
diff --git a/xen/include/asm-generic/percpu.h b/xen/include/asm-generic/percpu.h
deleted file mode 100644
index 3fdb3a2a0208..000000000000
--- a/xen/include/asm-generic/percpu.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_GENERIC_PERCPU_H__
-#define __ASM_GENERIC_PERCPU_H__
-
-#endif /* __ASM_GENERIC_PERCPU_H__ */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/xen/percpu.h b/xen/include/xen/percpu.h
index 30609f49f0b3..d324671b5b5f 100644
--- a/xen/include/xen/percpu.h
+++ b/xen/include/xen/percpu.h
@@ -27,7 +27,9 @@
 
 #define get_per_cpu_var(var)  (per_cpu__##var)
 
-#include <asm/percpu.h>
+#if __has_include(<asm/percpu.h>)
+# include <asm/percpu.h>
+#endif
 
 #ifndef __ASSEMBLER__
 

base-commit: a2ca4f8b9890899ca89d6116002e7a9c5957d8c6
-- 
2.39.5


Re: [PATCH] xen: Use __has_include() in xen/percpu.h
Posted by Orzel, Michal 1 week, 6 days ago

On 09-Sep-26 13:53, Andrew Cooper wrote:
> Only x86 has an asm/percpu.h.  Have the compiler only include it if it's
> present, rather than symlinking an empty file.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>

~Michal
Re: [PATCH] xen: Use __has_include() in xen/percpu.h
Posted by Jan Beulich 2 weeks, 1 day ago
On 09.09.2026 13:53, Andrew Cooper wrote:
> Only x86 has an asm/percpu.h.  Have the compiler only include it if it's
> present, rather than symlinking an empty file.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>