* [PATCH 02/14] x86/paravirt: remove some unneeded struct declarations
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 03/14] x86/paravirt: remove PARAVIRT_DEBUG config option Juergen Gross
` (13 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin
In paravirt_types.h there are some struct declarations which are not
needed. Remove them.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/paravirt_types.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 37a8627d8277..84cc8c95713b 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -11,16 +11,11 @@
#include <asm/pgtable_types.h>
#include <asm/nospec-branch.h>
-struct page;
struct thread_struct;
-struct desc_ptr;
-struct tss_struct;
struct mm_struct;
-struct desc_struct;
struct task_struct;
struct cpumask;
struct flush_tlb_info;
-struct mmu_gather;
struct vm_area_struct;
/*
@@ -205,7 +200,6 @@ struct pv_mmu_ops {
#endif
} __no_randomize_layout;
-struct arch_spinlock;
#ifdef CONFIG_SMP
#include <asm/spinlock_types.h>
#endif
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 03/14] x86/paravirt: remove PARAVIRT_DEBUG config option
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
2025-09-11 6:34 ` [PATCH 02/14] x86/paravirt: remove some unneeded struct declarations Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 04/14] x86/paravirt: move thunk macros to paravirt_types.h Juergen Gross
` (12 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization
Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list
The only effect of CONFIG_PARAVIRT_DEBUG set is that instead of doing
a call using a NULL pointer a BUG() is being raised.
While the BUG() will be a little bit easier to analyse, the call of
NULL isn't really that difficult to find the reason for.
Remove the config option to make paravirt coding a little bit less
annoying.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/Kconfig | 7 -------
arch/x86/include/asm/paravirt.h | 1 -
arch/x86/include/asm/paravirt_types.h | 8 --------
3 files changed, 16 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 58d890fe2100..07bf67b849b7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -794,13 +794,6 @@ config PARAVIRT_XXL
bool
depends on X86_64
-config PARAVIRT_DEBUG
- bool "paravirt-ops debugging"
- depends on PARAVIRT && DEBUG_KERNEL
- help
- Enable to debug paravirt_ops internals. Specifically, BUG if
- a paravirt_op is missing when it is called.
-
config PARAVIRT_SPINLOCKS
bool "Paravirtualization layer for spinlocks"
depends on PARAVIRT && SMP
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index b5e59a7ba0d0..99291f3123a9 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -16,7 +16,6 @@ struct mm_struct;
#include <asm/nospec-branch.h>
#ifndef __ASSEMBLER__
-#include <linux/bug.h>
#include <linux/types.h>
#include <linux/cpumask.h>
#include <linux/static_call_types.h>
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 84cc8c95713b..085095f94f97 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -354,12 +354,6 @@ extern struct paravirt_patch_template pv_ops;
#define VEXTRA_CLOBBERS , "rax", "r8", "r9", "r10", "r11"
#endif /* CONFIG_X86_32 */
-#ifdef CONFIG_PARAVIRT_DEBUG
-#define PVOP_TEST_NULL(op) BUG_ON(pv_ops.op == NULL)
-#else
-#define PVOP_TEST_NULL(op) ((void)pv_ops.op)
-#endif
-
#define PVOP_RETVAL(rettype) \
({ unsigned long __mask = ~0UL; \
BUILD_BUG_ON(sizeof(rettype) > sizeof(unsigned long)); \
@@ -388,7 +382,6 @@ extern struct paravirt_patch_template pv_ops;
#define ____PVOP_CALL(ret, op, call_clbr, extra_clbr, ...) \
({ \
PVOP_CALL_ARGS; \
- PVOP_TEST_NULL(op); \
asm volatile(ALTERNATIVE(PARAVIRT_CALL, ALT_CALL_INSTR, \
ALT_CALL_ALWAYS) \
: call_clbr, ASM_CALL_CONSTRAINT \
@@ -402,7 +395,6 @@ extern struct paravirt_patch_template pv_ops;
extra_clbr, ...) \
({ \
PVOP_CALL_ARGS; \
- PVOP_TEST_NULL(op); \
asm volatile(ALTERNATIVE_2(PARAVIRT_CALL, \
ALT_CALL_INSTR, ALT_CALL_ALWAYS, \
alt, cond) \
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 04/14] x86/paravirt: move thunk macros to paravirt_types.h
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
2025-09-11 6:34 ` [PATCH 02/14] x86/paravirt: remove some unneeded struct declarations Juergen Gross
2025-09-11 6:34 ` [PATCH 03/14] x86/paravirt: remove PARAVIRT_DEBUG config option Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 05/14] paravirt: remove asm/paravirt_api_clock.h Juergen Gross
` (11 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin
The macros for generating PV-thunks are part of the generic paravirt
infrastructure, so they should be in paravirt_types.h.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/paravirt.h | 68 ---------------------------
arch/x86/include/asm/paravirt_types.h | 68 +++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 99291f3123a9..0d1e611f619c 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -585,74 +585,6 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
#endif /* SMP && PARAVIRT_SPINLOCKS */
-#ifdef CONFIG_X86_32
-/* save and restore all caller-save registers, except return value */
-#define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
-#define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
-#else
-/* save and restore all caller-save registers, except return value */
-#define PV_SAVE_ALL_CALLER_REGS \
- "push %rcx;" \
- "push %rdx;" \
- "push %rsi;" \
- "push %rdi;" \
- "push %r8;" \
- "push %r9;" \
- "push %r10;" \
- "push %r11;"
-#define PV_RESTORE_ALL_CALLER_REGS \
- "pop %r11;" \
- "pop %r10;" \
- "pop %r9;" \
- "pop %r8;" \
- "pop %rdi;" \
- "pop %rsi;" \
- "pop %rdx;" \
- "pop %rcx;"
-#endif
-
-/*
- * Generate a thunk around a function which saves all caller-save
- * registers except for the return value. This allows C functions to
- * be called from assembler code where fewer than normal registers are
- * available. It may also help code generation around calls from C
- * code if the common case doesn't use many registers.
- *
- * When a callee is wrapped in a thunk, the caller can assume that all
- * arg regs and all scratch registers are preserved across the
- * call. The return value in rax/eax will not be saved, even for void
- * functions.
- */
-#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
-#define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \
- extern typeof(func) __raw_callee_save_##func; \
- \
- asm(".pushsection " section ", \"ax\";" \
- ".globl " PV_THUNK_NAME(func) ";" \
- ".type " PV_THUNK_NAME(func) ", @function;" \
- ASM_FUNC_ALIGN \
- PV_THUNK_NAME(func) ":" \
- ASM_ENDBR \
- FRAME_BEGIN \
- PV_SAVE_ALL_CALLER_REGS \
- "call " #func ";" \
- PV_RESTORE_ALL_CALLER_REGS \
- FRAME_END \
- ASM_RET \
- ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
- ".popsection")
-
-#define PV_CALLEE_SAVE_REGS_THUNK(func) \
- __PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
-
-/* Get a reference to a callee-save function */
-#define PV_CALLEE_SAVE(func) \
- ((struct paravirt_callee_save) { __raw_callee_save_##func })
-
-/* Promise that "func" already uses the right calling convention */
-#define __PV_IS_CALLEE_SAVE(func) \
- ((struct paravirt_callee_save) { func })
-
#ifdef CONFIG_PARAVIRT_XXL
static __always_inline unsigned long arch_local_save_flags(void)
{
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 085095f94f97..7acff40cc159 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -512,5 +512,73 @@ unsigned long pv_native_read_cr2(void);
#define ALT_NOT_XEN ALT_NOT(X86_FEATURE_XENPV)
+#ifdef CONFIG_X86_32
+/* save and restore all caller-save registers, except return value */
+#define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
+#define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
+#else
+/* save and restore all caller-save registers, except return value */
+#define PV_SAVE_ALL_CALLER_REGS \
+ "push %rcx;" \
+ "push %rdx;" \
+ "push %rsi;" \
+ "push %rdi;" \
+ "push %r8;" \
+ "push %r9;" \
+ "push %r10;" \
+ "push %r11;"
+#define PV_RESTORE_ALL_CALLER_REGS \
+ "pop %r11;" \
+ "pop %r10;" \
+ "pop %r9;" \
+ "pop %r8;" \
+ "pop %rdi;" \
+ "pop %rsi;" \
+ "pop %rdx;" \
+ "pop %rcx;"
+#endif
+
+/*
+ * Generate a thunk around a function which saves all caller-save
+ * registers except for the return value. This allows C functions to
+ * be called from assembler code where fewer than normal registers are
+ * available. It may also help code generation around calls from C
+ * code if the common case doesn't use many registers.
+ *
+ * When a callee is wrapped in a thunk, the caller can assume that all
+ * arg regs and all scratch registers are preserved across the
+ * call. The return value in rax/eax will not be saved, even for void
+ * functions.
+ */
+#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
+#define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \
+ extern typeof(func) __raw_callee_save_##func; \
+ \
+ asm(".pushsection " section ", \"ax\";" \
+ ".globl " PV_THUNK_NAME(func) ";" \
+ ".type " PV_THUNK_NAME(func) ", @function;" \
+ ASM_FUNC_ALIGN \
+ PV_THUNK_NAME(func) ":" \
+ ASM_ENDBR \
+ FRAME_BEGIN \
+ PV_SAVE_ALL_CALLER_REGS \
+ "call " #func ";" \
+ PV_RESTORE_ALL_CALLER_REGS \
+ FRAME_END \
+ ASM_RET \
+ ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
+ ".popsection")
+
+#define PV_CALLEE_SAVE_REGS_THUNK(func) \
+ __PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
+
+/* Get a reference to a callee-save function */
+#define PV_CALLEE_SAVE(func) \
+ ((struct paravirt_callee_save) { __raw_callee_save_##func })
+
+/* Promise that "func" already uses the right calling convention */
+#define __PV_IS_CALLEE_SAVE(func) \
+ ((struct paravirt_callee_save) { func })
+
#endif /* CONFIG_PARAVIRT */
#endif /* _ASM_X86_PARAVIRT_TYPES_H */
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 05/14] paravirt: remove asm/paravirt_api_clock.h
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (2 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 04/14] x86/paravirt: move thunk macros to paravirt_types.h Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 06/14] sched: move clock related paravirt code to kernel/sched Juergen Gross
` (10 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization, loongarch, linuxppc-dev,
linux-riscv
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Russell King,
Catalin Marinas, Will Deacon, Huacai Chen, WANG Xuerui,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Peter Zijlstra, Juri Lelli,
Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
Mel Gorman, Valentin Schneider, linux-arm-kernel
All architectures supporting CONFIG_PARAVIRT share the same contents
of asm/paravirt_api_clock.h:
#include <asm/paravirt.h>
So remove all incarnations of asm/paravirt_api_clock.h and remove the
only place where it is included, as there asm/paravirt.h is included
anyway.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/arm/include/asm/paravirt_api_clock.h | 1 -
arch/arm64/include/asm/paravirt_api_clock.h | 1 -
arch/loongarch/include/asm/paravirt_api_clock.h | 1 -
arch/powerpc/include/asm/paravirt_api_clock.h | 2 --
arch/riscv/include/asm/paravirt_api_clock.h | 1 -
arch/x86/include/asm/paravirt_api_clock.h | 1 -
kernel/sched/sched.h | 1 -
7 files changed, 8 deletions(-)
delete mode 100644 arch/arm/include/asm/paravirt_api_clock.h
delete mode 100644 arch/arm64/include/asm/paravirt_api_clock.h
delete mode 100644 arch/loongarch/include/asm/paravirt_api_clock.h
delete mode 100644 arch/powerpc/include/asm/paravirt_api_clock.h
delete mode 100644 arch/riscv/include/asm/paravirt_api_clock.h
delete mode 100644 arch/x86/include/asm/paravirt_api_clock.h
diff --git a/arch/arm/include/asm/paravirt_api_clock.h b/arch/arm/include/asm/paravirt_api_clock.h
deleted file mode 100644
index 65ac7cee0dad..000000000000
--- a/arch/arm/include/asm/paravirt_api_clock.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm/paravirt.h>
diff --git a/arch/arm64/include/asm/paravirt_api_clock.h b/arch/arm64/include/asm/paravirt_api_clock.h
deleted file mode 100644
index 65ac7cee0dad..000000000000
--- a/arch/arm64/include/asm/paravirt_api_clock.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm/paravirt.h>
diff --git a/arch/loongarch/include/asm/paravirt_api_clock.h b/arch/loongarch/include/asm/paravirt_api_clock.h
deleted file mode 100644
index 65ac7cee0dad..000000000000
--- a/arch/loongarch/include/asm/paravirt_api_clock.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm/paravirt.h>
diff --git a/arch/powerpc/include/asm/paravirt_api_clock.h b/arch/powerpc/include/asm/paravirt_api_clock.h
deleted file mode 100644
index d25ca7ac57c7..000000000000
--- a/arch/powerpc/include/asm/paravirt_api_clock.h
+++ /dev/null
@@ -1,2 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#include <asm/paravirt.h>
diff --git a/arch/riscv/include/asm/paravirt_api_clock.h b/arch/riscv/include/asm/paravirt_api_clock.h
deleted file mode 100644
index 65ac7cee0dad..000000000000
--- a/arch/riscv/include/asm/paravirt_api_clock.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm/paravirt.h>
diff --git a/arch/x86/include/asm/paravirt_api_clock.h b/arch/x86/include/asm/paravirt_api_clock.h
deleted file mode 100644
index 65ac7cee0dad..000000000000
--- a/arch/x86/include/asm/paravirt_api_clock.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm/paravirt.h>
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index be9745d104f7..6442441b46d7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -84,7 +84,6 @@ struct cpuidle_state;
#ifdef CONFIG_PARAVIRT
# include <asm/paravirt.h>
-# include <asm/paravirt_api_clock.h>
#endif
#include <asm/barrier.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 06/14] sched: move clock related paravirt code to kernel/sched
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (3 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 05/14] paravirt: remove asm/paravirt_api_clock.h Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 07/14] arm/paravirt: use common code for paravirt_steal_clock() Juergen Gross
` (9 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization, loongarch, linuxppc-dev,
linux-riscv, kvm
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Russell King,
Catalin Marinas, Will Deacon, Huacai Chen, WANG Xuerui,
Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Paolo Bonzini, Vitaly Kuznetsov,
Stefano Stabellini, Oleksandr Tyshchenko, Peter Zijlstra,
Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, linux-arm-kernel,
xen-devel
Paravirt clock related functions are available in multiple archs.
In order to share the common parts, move the common static keys
to kernel/sched/ and remove them from the arch specific files.
Make a common paravirt_steal_clock() implementation available in
kernel/sched/cputime.c, guarding it with a new config option
CONFIG_HAVE_PV_STEAL_CLOCK_GEN, which can be selectd by an arch
in case it wants to use that common variant.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/Kconfig | 3 +++
arch/arm/include/asm/paravirt.h | 4 ----
arch/arm/kernel/paravirt.c | 3 ---
arch/arm64/include/asm/paravirt.h | 4 ----
arch/arm64/kernel/paravirt.c | 4 +---
arch/loongarch/include/asm/paravirt.h | 3 ---
arch/loongarch/kernel/paravirt.c | 3 +--
arch/powerpc/include/asm/paravirt.h | 3 ---
arch/powerpc/platforms/pseries/setup.c | 4 +---
arch/riscv/include/asm/paravirt.h | 4 ----
arch/riscv/kernel/paravirt.c | 4 +---
arch/x86/include/asm/paravirt.h | 4 ----
arch/x86/kernel/cpu/vmware.c | 1 +
arch/x86/kernel/kvm.c | 1 +
arch/x86/kernel/paravirt.c | 3 ---
drivers/xen/time.c | 1 +
include/linux/sched/cputime.h | 18 ++++++++++++++++++
kernel/sched/core.c | 5 +++++
kernel/sched/cputime.c | 13 +++++++++++++
kernel/sched/sched.h | 2 +-
20 files changed, 47 insertions(+), 40 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index d1b4ffd6e085..7921be052472 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1003,6 +1003,9 @@ config HAVE_IRQ_TIME_ACCOUNTING
Archs need to ensure they use a high enough resolution clock to
support irq time accounting and then call enable_sched_clock_irqtime().
+config HAVE_PV_STEAL_CLOCK_GEN
+ bool
+
config HAVE_MOVE_PUD
bool
help
diff --git a/arch/arm/include/asm/paravirt.h b/arch/arm/include/asm/paravirt.h
index 95d5b0d625cd..69da4bdcf856 100644
--- a/arch/arm/include/asm/paravirt.h
+++ b/arch/arm/include/asm/paravirt.h
@@ -5,10 +5,6 @@
#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
-
u64 dummy_steal_clock(int cpu);
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c
index 7dd9806369fb..3895a5578852 100644
--- a/arch/arm/kernel/paravirt.c
+++ b/arch/arm/kernel/paravirt.c
@@ -12,9 +12,6 @@
#include <linux/static_call.h>
#include <asm/paravirt.h>
-struct static_key paravirt_steal_enabled;
-struct static_key paravirt_steal_rq_enabled;
-
static u64 native_steal_clock(int cpu)
{
return 0;
diff --git a/arch/arm64/include/asm/paravirt.h b/arch/arm64/include/asm/paravirt.h
index 9aa193e0e8f2..c9f7590baacb 100644
--- a/arch/arm64/include/asm/paravirt.h
+++ b/arch/arm64/include/asm/paravirt.h
@@ -5,10 +5,6 @@
#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
-
u64 dummy_steal_clock(int cpu);
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c
index aa718d6a9274..943b60ce12f4 100644
--- a/arch/arm64/kernel/paravirt.c
+++ b/arch/arm64/kernel/paravirt.c
@@ -19,14 +19,12 @@
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/static_call.h>
+#include <linux/sched/cputime.h>
#include <asm/paravirt.h>
#include <asm/pvclock-abi.h>
#include <asm/smp_plat.h>
-struct static_key paravirt_steal_enabled;
-struct static_key paravirt_steal_rq_enabled;
-
static u64 native_steal_clock(int cpu)
{
return 0;
diff --git a/arch/loongarch/include/asm/paravirt.h b/arch/loongarch/include/asm/paravirt.h
index 3f4323603e6a..d219ea0d98ac 100644
--- a/arch/loongarch/include/asm/paravirt.h
+++ b/arch/loongarch/include/asm/paravirt.h
@@ -5,9 +5,6 @@
#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
u64 dummy_steal_clock(int cpu);
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
diff --git a/arch/loongarch/kernel/paravirt.c b/arch/loongarch/kernel/paravirt.c
index b1b51f920b23..8caaa94fed1a 100644
--- a/arch/loongarch/kernel/paravirt.c
+++ b/arch/loongarch/kernel/paravirt.c
@@ -6,11 +6,10 @@
#include <linux/kvm_para.h>
#include <linux/reboot.h>
#include <linux/static_call.h>
+#include <linux/sched/cputime.h>
#include <asm/paravirt.h>
static int has_steal_clock;
-struct static_key paravirt_steal_enabled;
-struct static_key paravirt_steal_rq_enabled;
static DEFINE_PER_CPU(struct kvm_steal_time, steal_time) __aligned(64);
DEFINE_STATIC_KEY_FALSE(virt_spin_lock_key);
diff --git a/arch/powerpc/include/asm/paravirt.h b/arch/powerpc/include/asm/paravirt.h
index b78b82d66057..92343a23ad15 100644
--- a/arch/powerpc/include/asm/paravirt.h
+++ b/arch/powerpc/include/asm/paravirt.h
@@ -23,9 +23,6 @@ static inline bool is_shared_processor(void)
}
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
-
u64 pseries_paravirt_steal_clock(int cpu);
static inline u64 paravirt_steal_clock(int cpu)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index b10a25325238..50b26ed8432d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -42,6 +42,7 @@
#include <linux/memblock.h>
#include <linux/swiotlb.h>
#include <linux/seq_buf.h>
+#include <linux/sched/cputime.h>
#include <asm/mmu.h>
#include <asm/processor.h>
@@ -83,9 +84,6 @@ DEFINE_STATIC_KEY_FALSE(shared_processor);
EXPORT_SYMBOL(shared_processor);
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-struct static_key paravirt_steal_enabled;
-struct static_key paravirt_steal_rq_enabled;
-
static bool steal_acc = true;
static int __init parse_no_stealacc(char *arg)
{
diff --git a/arch/riscv/include/asm/paravirt.h b/arch/riscv/include/asm/paravirt.h
index c0abde70fc2c..17e5e39c72c0 100644
--- a/arch/riscv/include/asm/paravirt.h
+++ b/arch/riscv/include/asm/paravirt.h
@@ -5,10 +5,6 @@
#ifdef CONFIG_PARAVIRT
#include <linux/static_call_types.h>
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
-
u64 dummy_steal_clock(int cpu);
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
diff --git a/arch/riscv/kernel/paravirt.c b/arch/riscv/kernel/paravirt.c
index fa6b0339a65d..d3c334f16172 100644
--- a/arch/riscv/kernel/paravirt.c
+++ b/arch/riscv/kernel/paravirt.c
@@ -16,15 +16,13 @@
#include <linux/printk.h>
#include <linux/static_call.h>
#include <linux/types.h>
+#include <linux/sched/cputime.h>
#include <asm/barrier.h>
#include <asm/page.h>
#include <asm/paravirt.h>
#include <asm/sbi.h>
-struct static_key paravirt_steal_enabled;
-struct static_key paravirt_steal_rq_enabled;
-
static u64 native_steal_clock(int cpu)
{
return 0;
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 0d1e611f619c..491cb7e037bf 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -34,10 +34,6 @@ static __always_inline u64 paravirt_sched_clock(void)
return static_call(pv_sched_clock)();
}
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
-
__visible void __native_queued_spin_unlock(struct qspinlock *lock);
bool pv_is_native_spin_unlock(void);
__visible bool __native_vcpu_is_preempted(long cpu);
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index cb3f900c46fc..a3e6936839b1 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -29,6 +29,7 @@
#include <linux/efi.h>
#include <linux/reboot.h>
#include <linux/static_call.h>
+#include <linux/sched/cputime.h>
#include <asm/div64.h>
#include <asm/x86_init.h>
#include <asm/hypervisor.h>
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 8ae750cde0c6..a23211eaaeed 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -29,6 +29,7 @@
#include <linux/syscore_ops.h>
#include <linux/cc_platform.h>
#include <linux/efi.h>
+#include <linux/sched/cputime.h>
#include <asm/timer.h>
#include <asm/cpu.h>
#include <asm/traps.h>
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index ab3e172dcc69..a3ba4747be1c 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -60,9 +60,6 @@ void __init native_pv_lock_init(void)
static_branch_enable(&virt_spin_lock_key);
}
-struct static_key paravirt_steal_enabled;
-struct static_key paravirt_steal_rq_enabled;
-
static u64 native_steal_clock(int cpu)
{
return 0;
diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 5683383d2305..d360ded2ef39 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -8,6 +8,7 @@
#include <linux/gfp.h>
#include <linux/slab.h>
#include <linux/static_call.h>
+#include <linux/sched/cputime.h>
#include <asm/paravirt.h>
#include <asm/xen/hypervisor.h>
diff --git a/include/linux/sched/cputime.h b/include/linux/sched/cputime.h
index 5f8fd5b24a2e..e90efaf6d26e 100644
--- a/include/linux/sched/cputime.h
+++ b/include/linux/sched/cputime.h
@@ -2,6 +2,7 @@
#ifndef _LINUX_SCHED_CPUTIME_H
#define _LINUX_SCHED_CPUTIME_H
+#include <linux/static_call_types.h>
#include <linux/sched/signal.h>
/*
@@ -180,4 +181,21 @@ static inline void prev_cputime_init(struct prev_cputime *prev)
extern unsigned long long
task_sched_runtime(struct task_struct *task);
+#ifdef CONFIG_PARAVIRT
+struct static_key;
+extern struct static_key paravirt_steal_enabled;
+extern struct static_key paravirt_steal_rq_enabled;
+
+#ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
+u64 dummy_steal_clock(int cpu);
+
+DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
+
+static inline u64 paravirt_steal_clock(int cpu)
+{
+ return static_call(pv_steal_clock)(cpu);
+}
+#endif
+#endif
+
#endif /* _LINUX_SCHED_CPUTIME_H */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index be00629f0ba4..e723226e4e11 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -767,6 +767,11 @@ struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf)
* RQ-clock updating methods:
*/
+/* Use CONFIG_PARAVIRT as this will avoid more #ifdef in arch code. */
+#ifdef CONFIG_PARAVIRT
+struct static_key paravirt_steal_rq_enabled;
+#endif
+
static void update_rq_clock_task(struct rq *rq, s64 delta)
{
/*
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 7097de2c8cda..ed8f71e08047 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -251,6 +251,19 @@ void __account_forceidle_time(struct task_struct *p, u64 delta)
* ticks are not redelivered later. Due to that, this function may on
* occasion account more time than the calling functions think elapsed.
*/
+#ifdef CONFIG_PARAVIRT
+struct static_key paravirt_steal_enabled;
+
+#ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
+static u64 native_steal_clock(int cpu)
+{
+ return 0;
+}
+
+DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
+#endif
+#endif
+
static __always_inline u64 steal_account_process_time(u64 maxtime)
{
#ifdef CONFIG_PARAVIRT
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 6442441b46d7..fdf3021bdf7d 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -82,7 +82,7 @@ struct rt_rq;
struct sched_group;
struct cpuidle_state;
-#ifdef CONFIG_PARAVIRT
+#if defined(CONFIG_PARAVIRT) && !defined(CONFIG_HAVE_PV_STEAL_CLOCK_GEN)
# include <asm/paravirt.h>
#endif
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 07/14] arm/paravirt: use common code for paravirt_steal_clock()
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (4 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 06/14] sched: move clock related paravirt code to kernel/sched Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 08/14] arm64/paravirt: " Juergen Gross
` (8 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, virtualization, x86
Cc: Juergen Gross, Russell King, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Stefano Stabellini,
Oleksandr Tyshchenko, linux-arm-kernel, xen-devel
Remove the arch specific variant of paravirt_steal_clock() and use
the common one instead.
This allows to remove paravirt.c and paravirt.h from arch/arm.
Until all archs supporting Xen have been switched to the common code
of paravirt_steal_clock(), drivers/xen/time.c needs to include
asm/paravirt.h for those archs, while this is not necessary for arm
any longer.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/arm/Kconfig | 1 +
arch/arm/include/asm/paravirt.h | 18 ------------------
arch/arm/kernel/Makefile | 1 -
arch/arm/kernel/paravirt.c | 20 --------------------
drivers/xen/time.c | 2 ++
5 files changed, 3 insertions(+), 39 deletions(-)
delete mode 100644 arch/arm/include/asm/paravirt.h
delete mode 100644 arch/arm/kernel/paravirt.c
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b1f3df39ed40..48c3a36a63f8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1338,6 +1338,7 @@ config UACCESS_WITH_MEMCPY
config PARAVIRT
bool "Enable paravirtualization code"
+ select HAVE_PV_STEAL_CLOCK_GEN
help
This changes the kernel so it can modify itself when it is run
under a hypervisor, potentially improving performance significantly
diff --git a/arch/arm/include/asm/paravirt.h b/arch/arm/include/asm/paravirt.h
deleted file mode 100644
index 69da4bdcf856..000000000000
--- a/arch/arm/include/asm/paravirt.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_ARM_PARAVIRT_H
-#define _ASM_ARM_PARAVIRT_H
-
-#ifdef CONFIG_PARAVIRT
-#include <linux/static_call_types.h>
-
-u64 dummy_steal_clock(int cpu);
-
-DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
-
-static inline u64 paravirt_steal_clock(int cpu)
-{
- return static_call(pv_steal_clock)(cpu);
-}
-#endif
-
-#endif
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index afc9de7ef9a1..b36cf0cfd4a7 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -83,7 +83,6 @@ AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt
obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o
obj-$(CONFIG_VDSO) += vdso.o
obj-$(CONFIG_EFI) += efi.o
-obj-$(CONFIG_PARAVIRT) += paravirt.o
obj-y += head$(MMUEXT).o
obj-$(CONFIG_DEBUG_LL) += debug.o
diff --git a/arch/arm/kernel/paravirt.c b/arch/arm/kernel/paravirt.c
deleted file mode 100644
index 3895a5578852..000000000000
--- a/arch/arm/kernel/paravirt.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- *
- * Copyright (C) 2013 Citrix Systems
- *
- * Author: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
- */
-
-#include <linux/export.h>
-#include <linux/jump_label.h>
-#include <linux/types.h>
-#include <linux/static_call.h>
-#include <asm/paravirt.h>
-
-static u64 native_steal_clock(int cpu)
-{
- return 0;
-}
-
-DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index d360ded2ef39..53b12f5ac465 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -10,7 +10,9 @@
#include <linux/static_call.h>
#include <linux/sched/cputime.h>
+#ifndef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
#include <asm/paravirt.h>
+#endif
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 08/14] arm64/paravirt: use common code for paravirt_steal_clock()
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (5 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 07/14] arm/paravirt: use common code for paravirt_steal_clock() Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 09/14] loongarch/paravirt: " Juergen Gross
` (7 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, virtualization, x86
Cc: Juergen Gross, Catalin Marinas, Will Deacon, Ajay Kaher,
Alexey Makhalov, Broadcom internal kernel review list,
linux-arm-kernel
Remove the arch specific variant of paravirt_steal_clock() and use
the common one instead.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/paravirt.h | 10 ----------
arch/arm64/kernel/paravirt.c | 7 -------
3 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index e9bbfacc35a6..08abcd353cf4 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1582,6 +1582,7 @@ config CC_HAVE_SHADOW_CALL_STACK
config PARAVIRT
bool "Enable paravirtualization code"
+ select HAVE_PV_STEAL_CLOCK_GEN
help
This changes the kernel so it can modify itself when it is run
under a hypervisor, potentially improving performance significantly
diff --git a/arch/arm64/include/asm/paravirt.h b/arch/arm64/include/asm/paravirt.h
index c9f7590baacb..cb037e742372 100644
--- a/arch/arm64/include/asm/paravirt.h
+++ b/arch/arm64/include/asm/paravirt.h
@@ -3,16 +3,6 @@
#define _ASM_ARM64_PARAVIRT_H
#ifdef CONFIG_PARAVIRT
-#include <linux/static_call_types.h>
-
-u64 dummy_steal_clock(int cpu);
-
-DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
-
-static inline u64 paravirt_steal_clock(int cpu)
-{
- return static_call(pv_steal_clock)(cpu);
-}
int __init pv_time_init(void);
diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c
index 943b60ce12f4..572efb96b23f 100644
--- a/arch/arm64/kernel/paravirt.c
+++ b/arch/arm64/kernel/paravirt.c
@@ -25,13 +25,6 @@
#include <asm/pvclock-abi.h>
#include <asm/smp_plat.h>
-static u64 native_steal_clock(int cpu)
-{
- return 0;
-}
-
-DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
-
struct pv_time_stolen_time_region {
struct pvclock_vcpu_stolen_time __rcu *kaddr;
};
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 09/14] loongarch/paravirt: use common code for paravirt_steal_clock()
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (6 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 08/14] arm64/paravirt: " Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 10/14] riscv/paravirt: " Juergen Gross
` (6 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, loongarch, virtualization, x86
Cc: Juergen Gross, Huacai Chen, WANG Xuerui, Ajay Kaher,
Alexey Makhalov, Broadcom internal kernel review list
Remove the arch specific variant of paravirt_steal_clock() and use
the common one instead.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/loongarch/Kconfig | 1 +
arch/loongarch/include/asm/paravirt.h | 10 ----------
arch/loongarch/kernel/paravirt.c | 7 -------
3 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index f0abc38c40ac..06bebad41c6f 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -678,6 +678,7 @@ source "kernel/livepatch/Kconfig"
config PARAVIRT
bool "Enable paravirtualization code"
depends on AS_HAS_LVZ_EXTENSION
+ select HAVE_PV_STEAL_CLOCK_GEN
help
This changes the kernel so it can modify itself when it is run
under a hypervisor, potentially improving performance significantly
diff --git a/arch/loongarch/include/asm/paravirt.h b/arch/loongarch/include/asm/paravirt.h
index d219ea0d98ac..0111f0ad5f73 100644
--- a/arch/loongarch/include/asm/paravirt.h
+++ b/arch/loongarch/include/asm/paravirt.h
@@ -4,16 +4,6 @@
#ifdef CONFIG_PARAVIRT
-#include <linux/static_call_types.h>
-
-u64 dummy_steal_clock(int cpu);
-DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
-
-static inline u64 paravirt_steal_clock(int cpu)
-{
- return static_call(pv_steal_clock)(cpu);
-}
-
int __init pv_ipi_init(void);
int __init pv_time_init(void);
int __init pv_spinlock_init(void);
diff --git a/arch/loongarch/kernel/paravirt.c b/arch/loongarch/kernel/paravirt.c
index 8caaa94fed1a..c5e526098c0b 100644
--- a/arch/loongarch/kernel/paravirt.c
+++ b/arch/loongarch/kernel/paravirt.c
@@ -13,13 +13,6 @@ static int has_steal_clock;
static DEFINE_PER_CPU(struct kvm_steal_time, steal_time) __aligned(64);
DEFINE_STATIC_KEY_FALSE(virt_spin_lock_key);
-static u64 native_steal_clock(int cpu)
-{
- return 0;
-}
-
-DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
-
static bool steal_acc = true;
static int __init parse_no_stealacc(char *arg)
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 10/14] riscv/paravirt: use common code for paravirt_steal_clock()
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (7 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 09/14] loongarch/paravirt: " Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 11/14] x86/paravirt: " Juergen Gross
` (5 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, linux-riscv, virtualization, x86
Cc: Juergen Gross, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list
Remove the arch specific variant of paravirt_steal_clock() and use
the common one instead.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/paravirt.h | 10 ----------
arch/riscv/kernel/paravirt.c | 7 -------
3 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 51dcd8eaa243..8a7573aebaca 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -1108,6 +1108,7 @@ config COMPAT
config PARAVIRT
bool "Enable paravirtualization code"
depends on RISCV_SBI
+ select HAVE_PV_STEAL_CLOCK_GEN
help
This changes the kernel so it can modify itself when it is run
under a hypervisor, potentially improving performance significantly
diff --git a/arch/riscv/include/asm/paravirt.h b/arch/riscv/include/asm/paravirt.h
index 17e5e39c72c0..c49c55b266f3 100644
--- a/arch/riscv/include/asm/paravirt.h
+++ b/arch/riscv/include/asm/paravirt.h
@@ -3,16 +3,6 @@
#define _ASM_RISCV_PARAVIRT_H
#ifdef CONFIG_PARAVIRT
-#include <linux/static_call_types.h>
-
-u64 dummy_steal_clock(int cpu);
-
-DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
-
-static inline u64 paravirt_steal_clock(int cpu)
-{
- return static_call(pv_steal_clock)(cpu);
-}
int __init pv_time_init(void);
diff --git a/arch/riscv/kernel/paravirt.c b/arch/riscv/kernel/paravirt.c
index d3c334f16172..5f56be79cd06 100644
--- a/arch/riscv/kernel/paravirt.c
+++ b/arch/riscv/kernel/paravirt.c
@@ -23,13 +23,6 @@
#include <asm/paravirt.h>
#include <asm/sbi.h>
-static u64 native_steal_clock(int cpu)
-{
- return 0;
-}
-
-DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
-
static bool steal_acc = true;
static int __init parse_no_stealacc(char *arg)
{
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 11/14] x86/paravirt: use common code for paravirt_steal_clock()
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (8 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 10/14] riscv/paravirt: " Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c Juergen Gross
` (4 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization
Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Boris Ostrovsky,
Stefano Stabellini, Oleksandr Tyshchenko, xen-devel
Remove the arch specific variant of paravirt_steal_clock() and use
the common one instead.
With alol archs supporting Xen now having been switched to the common
variant, including paravirt.h can be dropped from drivers/xen/time.c.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/Kconfig | 1 +
arch/x86/include/asm/paravirt.h | 7 -------
arch/x86/kernel/paravirt.c | 6 ------
arch/x86/xen/time.c | 1 +
drivers/xen/time.c | 3 ---
5 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 07bf67b849b7..0f8abf96cc39 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -784,6 +784,7 @@ if HYPERVISOR_GUEST
config PARAVIRT
bool "Enable paravirtualization code"
depends on HAVE_STATIC_CALL
+ select HAVE_PV_STEAL_CLOCK_GEN
help
This changes the kernel so it can modify itself when it is run
under a hypervisor, potentially improving performance significantly
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 491cb7e037bf..37d7494ce146 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -21,10 +21,8 @@ struct mm_struct;
#include <linux/static_call_types.h>
#include <asm/frame.h>
-u64 dummy_steal_clock(int cpu);
u64 dummy_sched_clock(void);
-DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);
DECLARE_STATIC_CALL(pv_sched_clock, dummy_sched_clock);
void paravirt_set_sched_clock(u64 (*func)(void));
@@ -39,11 +37,6 @@ bool pv_is_native_spin_unlock(void);
__visible bool __native_vcpu_is_preempted(long cpu);
bool pv_is_native_vcpu_is_preempted(void);
-static inline u64 paravirt_steal_clock(int cpu)
-{
- return static_call(pv_steal_clock)(cpu);
-}
-
#ifdef CONFIG_PARAVIRT_SPINLOCKS
void __init paravirt_set_cap(void);
#endif
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index a3ba4747be1c..42991d471bf3 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -60,12 +60,6 @@ void __init native_pv_lock_init(void)
static_branch_enable(&virt_spin_lock_key);
}
-static u64 native_steal_clock(int cpu)
-{
- return 0;
-}
-
-DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock);
void paravirt_set_sched_clock(u64 (*func)(void))
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 96521b1874ac..e4754b2fa900 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/pvclock_gtod.h>
#include <linux/timekeeper_internal.h>
+#include <linux/sched/cputime.h>
#include <asm/pvclock.h>
#include <asm/xen/hypervisor.h>
diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 53b12f5ac465..0b18d8a5a2dd 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -10,9 +10,6 @@
#include <linux/static_call.h>
#include <linux/sched/cputime.h>
-#ifndef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
-#include <asm/paravirt.h>
-#endif
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (9 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 11/14] x86/paravirt: " Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 13/14] x86/paravirt: allow pv-calls outside paravirt.h Juergen Gross
` (3 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization, kvm, linux-hyperv
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin,
Paolo Bonzini, Vitaly Kuznetsov, Boris Ostrovsky,
K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
Daniel Lezcano, xen-devel
The only user of paravirt_sched_clock() is in tsc.c, so move the code
from paravirt.c and paravirt.h to tsc.c.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/paravirt.h | 12 ------------
arch/x86/include/asm/timer.h | 1 +
arch/x86/kernel/kvmclock.c | 1 +
arch/x86/kernel/paravirt.c | 7 -------
arch/x86/kernel/tsc.c | 10 +++++++++-
arch/x86/xen/time.c | 1 +
drivers/clocksource/hyperv_timer.c | 2 ++
7 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 37d7494ce146..bd050ceaae00 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -18,20 +18,8 @@ struct mm_struct;
#ifndef __ASSEMBLER__
#include <linux/types.h>
#include <linux/cpumask.h>
-#include <linux/static_call_types.h>
#include <asm/frame.h>
-u64 dummy_sched_clock(void);
-
-DECLARE_STATIC_CALL(pv_sched_clock, dummy_sched_clock);
-
-void paravirt_set_sched_clock(u64 (*func)(void));
-
-static __always_inline u64 paravirt_sched_clock(void)
-{
- return static_call(pv_sched_clock)();
-}
-
__visible void __native_queued_spin_unlock(struct qspinlock *lock);
bool pv_is_native_spin_unlock(void);
__visible bool __native_vcpu_is_preempted(long cpu);
diff --git a/arch/x86/include/asm/timer.h b/arch/x86/include/asm/timer.h
index 23baf8c9b34c..fda18bcb19b4 100644
--- a/arch/x86/include/asm/timer.h
+++ b/arch/x86/include/asm/timer.h
@@ -12,6 +12,7 @@ extern void recalibrate_cpu_khz(void);
extern int no_timer_check;
extern bool using_native_sched_clock(void);
+void paravirt_set_sched_clock(u64 (*func)(void));
/*
* We use the full linear equation: f(x) = a + b*x, in order to allow
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index ca0a49eeac4a..b5991d53fc0e 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -19,6 +19,7 @@
#include <linux/cc_platform.h>
#include <asm/hypervisor.h>
+#include <asm/timer.h>
#include <asm/x86_init.h>
#include <asm/kvmclock.h>
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 42991d471bf3..4e37db8073f9 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -60,13 +60,6 @@ void __init native_pv_lock_init(void)
static_branch_enable(&virt_spin_lock_key);
}
-DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock);
-
-void paravirt_set_sched_clock(u64 (*func)(void))
-{
- static_call_update(pv_sched_clock, func);
-}
-
static noinstr void pv_native_safe_halt(void)
{
native_safe_halt();
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 87e749106dda..554b54783a04 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -266,19 +266,27 @@ u64 native_sched_clock_from_tsc(u64 tsc)
/* We need to define a real function for sched_clock, to override the
weak default version */
#ifdef CONFIG_PARAVIRT
+DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock);
+
noinstr u64 sched_clock_noinstr(void)
{
- return paravirt_sched_clock();
+ return static_call(pv_sched_clock)();
}
bool using_native_sched_clock(void)
{
return static_call_query(pv_sched_clock) == native_sched_clock;
}
+
+void paravirt_set_sched_clock(u64 (*func)(void))
+{
+ static_call_update(pv_sched_clock, func);
+}
#else
u64 sched_clock_noinstr(void) __attribute__((alias("native_sched_clock")));
bool using_native_sched_clock(void) { return true; }
+void paravirt_set_sched_clock(u64 (*func)(void)) { }
#endif
notrace u64 sched_clock(void)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index e4754b2fa900..6f9f665bb7ae 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -19,6 +19,7 @@
#include <linux/sched/cputime.h>
#include <asm/pvclock.h>
+#include <asm/timer.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
#include <asm/xen/cpuid.h>
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 2edc13ca184e..6397a7ba4a98 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -535,6 +535,8 @@ static __always_inline void hv_setup_sched_clock(void *sched_clock)
sched_clock_register(sched_clock, 64, NSEC_PER_SEC);
}
#elif defined CONFIG_PARAVIRT
+#include <asm/timer.h>
+
static __always_inline void hv_setup_sched_clock(void *sched_clock)
{
/* We're on x86/x64 *and* using PV ops */
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 13/14] x86/paravirt: allow pv-calls outside paravirt.h
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (10 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 6:34 ` [PATCH 14/14] x86/pvlocks: move paravirt spinlock functions into qspinlock.h Juergen Gross
` (2 subsequent siblings)
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin
In order to prepare for defining paravirt functions outside of
paravirt.h, don't #undef the paravirt call macros.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/paravirt.h | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index bd050ceaae00..13c0e4e65467 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -589,22 +589,6 @@ static __always_inline unsigned long arch_local_irq_save(void)
}
#endif
-
-/* Make sure as little as possible of this mess escapes. */
-#undef PARAVIRT_CALL
-#undef __PVOP_CALL
-#undef __PVOP_VCALL
-#undef PVOP_VCALL0
-#undef PVOP_CALL0
-#undef PVOP_VCALL1
-#undef PVOP_CALL1
-#undef PVOP_VCALL2
-#undef PVOP_CALL2
-#undef PVOP_VCALL3
-#undef PVOP_CALL3
-#undef PVOP_VCALL4
-#undef PVOP_CALL4
-
extern void default_banner(void);
void native_pv_lock_init(void) __init;
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 14/14] x86/pvlocks: move paravirt spinlock functions into qspinlock.h
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (11 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 13/14] x86/paravirt: allow pv-calls outside paravirt.h Juergen Gross
@ 2025-09-11 6:34 ` Juergen Gross
2025-09-11 7:48 ` [PATCH 00/14] paravirt: cleanup and reorg Peter Zijlstra
2026-02-20 4:10 ` patchwork-bot+linux-riscv
14 siblings, 0 replies; 17+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, virtualization
Cc: Juergen Gross, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin
Instead of having the pv spinlock function definitions in paravirt.h,
move them into qspinlock.h where the arch specific functions for
qspinlocks are defined already.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/paravirt.h | 58 --------------------------------
arch/x86/include/asm/qspinlock.h | 49 +++++++++++++++++++++++++--
2 files changed, 47 insertions(+), 60 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 13c0e4e65467..78097a7e4214 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -20,15 +20,6 @@ struct mm_struct;
#include <linux/cpumask.h>
#include <asm/frame.h>
-__visible void __native_queued_spin_unlock(struct qspinlock *lock);
-bool pv_is_native_spin_unlock(void);
-__visible bool __native_vcpu_is_preempted(long cpu);
-bool pv_is_native_vcpu_is_preempted(void);
-
-#ifdef CONFIG_PARAVIRT_SPINLOCKS
-void __init paravirt_set_cap(void);
-#endif
-
/* The paravirtualized I/O functions */
static inline void slow_down_io(void)
{
@@ -525,43 +516,6 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
}
#endif
-#if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
-
-static __always_inline void pv_queued_spin_lock_slowpath(struct qspinlock *lock,
- u32 val)
-{
- PVOP_VCALL2(lock.queued_spin_lock_slowpath, lock, val);
-}
-
-static __always_inline void pv_queued_spin_unlock(struct qspinlock *lock)
-{
- PVOP_ALT_VCALLEE1(lock.queued_spin_unlock, lock,
- "movb $0, (%%" _ASM_ARG1 ");",
- ALT_NOT(X86_FEATURE_PVUNLOCK));
-}
-
-static __always_inline void pv_wait(u8 *ptr, u8 val)
-{
- PVOP_VCALL2(lock.wait, ptr, val);
-}
-
-static __always_inline void pv_kick(int cpu)
-{
- PVOP_VCALL1(lock.kick, cpu);
-}
-
-static __always_inline bool pv_vcpu_is_preempted(long cpu)
-{
- return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
- "xor %%" _ASM_AX ", %%" _ASM_AX ";",
- ALT_NOT(X86_FEATURE_VCPUPREEMPT));
-}
-
-void __raw_callee_save___native_queued_spin_unlock(struct qspinlock *lock);
-bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
-
-#endif /* SMP && PARAVIRT_SPINLOCKS */
-
#ifdef CONFIG_PARAVIRT_XXL
static __always_inline unsigned long arch_local_save_flags(void)
{
@@ -590,7 +544,6 @@ static __always_inline unsigned long arch_local_irq_save(void)
#endif
extern void default_banner(void);
-void native_pv_lock_init(void) __init;
#else /* __ASSEMBLER__ */
@@ -615,12 +568,6 @@ void native_pv_lock_init(void) __init;
#endif /* __ASSEMBLER__ */
#else /* CONFIG_PARAVIRT */
# define default_banner x86_init_noop
-
-#ifndef __ASSEMBLER__
-static inline void native_pv_lock_init(void)
-{
-}
-#endif
#endif /* !CONFIG_PARAVIRT */
#ifndef __ASSEMBLER__
@@ -636,10 +583,5 @@ static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
}
#endif
-#ifndef CONFIG_PARAVIRT_SPINLOCKS
-static inline void paravirt_set_cap(void)
-{
-}
-#endif
#endif /* __ASSEMBLER__ */
#endif /* _ASM_X86_PARAVIRT_H */
diff --git a/arch/x86/include/asm/qspinlock.h b/arch/x86/include/asm/qspinlock.h
index 68da67df304d..376f89aa1d4c 100644
--- a/arch/x86/include/asm/qspinlock.h
+++ b/arch/x86/include/asm/qspinlock.h
@@ -28,12 +28,33 @@ static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lo
}
#ifdef CONFIG_PARAVIRT_SPINLOCKS
+void __init paravirt_set_cap(void);
extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
extern void __pv_init_lock_hash(void);
extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
extern void __raw_callee_save___pv_queued_spin_unlock(struct qspinlock *lock);
extern bool nopvspin;
+static __always_inline void pv_queued_spin_lock_slowpath(struct qspinlock *lock,
+ u32 val)
+{
+ PVOP_VCALL2(lock.queued_spin_lock_slowpath, lock, val);
+}
+
+static __always_inline void pv_queued_spin_unlock(struct qspinlock *lock)
+{
+ PVOP_ALT_VCALLEE1(lock.queued_spin_unlock, lock,
+ "movb $0, (%%" _ASM_ARG1 ");",
+ ALT_NOT(X86_FEATURE_PVUNLOCK));
+}
+
+static __always_inline bool pv_vcpu_is_preempted(long cpu)
+{
+ return PVOP_ALT_CALLEE1(bool, lock.vcpu_is_preempted, cpu,
+ "xor %%" _ASM_AX ", %%" _ASM_AX ";",
+ ALT_NOT(X86_FEATURE_VCPUPREEMPT));
+}
+
#define queued_spin_unlock queued_spin_unlock
/**
* queued_spin_unlock - release a queued spinlock
@@ -62,9 +83,31 @@ static inline bool vcpu_is_preempted(long cpu)
{
return pv_vcpu_is_preempted(cpu);
}
-#endif
+
+#else /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline void paravirt_set_cap(void) { }
+#endif /* !CONFIG_PARAVIRT_SPINLOCKS */
#ifdef CONFIG_PARAVIRT
+void __init native_pv_lock_init(void);
+__visible void __native_queued_spin_unlock(struct qspinlock *lock);
+bool pv_is_native_spin_unlock(void);
+__visible bool __native_vcpu_is_preempted(long cpu);
+bool pv_is_native_vcpu_is_preempted(void);
+
+static __always_inline void pv_wait(u8 *ptr, u8 val)
+{
+ PVOP_VCALL2(lock.wait, ptr, val);
+}
+
+static __always_inline void pv_kick(int cpu)
+{
+ PVOP_VCALL1(lock.kick, cpu);
+}
+
+void __raw_callee_save___native_queued_spin_unlock(struct qspinlock *lock);
+bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
+
/*
* virt_spin_lock_key - disables by default the virt_spin_lock() hijack.
*
@@ -109,7 +152,9 @@ static inline bool virt_spin_lock(struct qspinlock *lock)
return true;
}
-#endif /* CONFIG_PARAVIRT */
+#else /* CONFIG_PARAVIRT */
+static inline void native_pv_lock_init(void) { }
+#endif /* !CONFIG_PARAVIRT */
#include <asm-generic/qspinlock.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 00/14] paravirt: cleanup and reorg
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (12 preceding siblings ...)
2025-09-11 6:34 ` [PATCH 14/14] x86/pvlocks: move paravirt spinlock functions into qspinlock.h Juergen Gross
@ 2025-09-11 7:48 ` Peter Zijlstra
2025-09-11 8:00 ` Jürgen Groß
2026-02-20 4:10 ` patchwork-bot+linux-riscv
14 siblings, 1 reply; 17+ messages in thread
From: Peter Zijlstra @ 2025-09-11 7:48 UTC (permalink / raw)
To: Juergen Gross
Cc: linux-kernel, x86, linux-hyperv, virtualization, loongarch,
linuxppc-dev, linux-riscv, kvm, Andy Lutomirski, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin,
K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Will Deacon,
Boqun Feng, Waiman Long, Jiri Kosina, Josh Poimboeuf, Pawan Gupta,
Boris Ostrovsky, xen-devel, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Russell King,
Catalin Marinas, Huacai Chen, WANG Xuerui, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, linux-arm-kernel,
Paolo Bonzini, Vitaly Kuznetsov, Stefano Stabellini,
Oleksandr Tyshchenko, Daniel Lezcano
On Thu, Sep 11, 2025 at 08:34:19AM +0200, Juergen Gross wrote:
> Some cleanups and reorg of paravirt code and headers:
>
> - The first 2 patches should be not controversial at all, as they
> remove just some no longer needed #include and struct forward
> declarations.
>
> - The 3rd patch is removing CONFIG_PARAVIRT_DEBUG, which IMO has
> no real value, as it just changes a crash to a BUG() (the stack
> trace will basically be the same). As the maintainer of the main
> paravirt user (Xen) I have never seen this crash/BUG() to happen.
>
> - The 4th patch is just a movement of code.
>
> - I don't know for what reason asm/paravirt_api_clock.h was added,
> as all archs supporting it do it exactly in the same way. Patch
> 5 is removing it.
>
> - Patches 6-12 are streamlining the paravirt clock interfaces by
> using a common implementation across architectures where possible
> and by moving the related code into common sched code, as this is
> where it should live.
>
> - Patches 13+14 are more like RFC material: patch 13 is doing some
> preparation work to enable patch 14 to move all spinlock related
> paravirt functions into qspinlock.h. If this approach is accepted,
> I'd like to continue with this work by moving most (or all?)
> paravirt functions from paravirt.h into the headers where their
> native counterparts are defined. This is meant to keep the native
> and paravirt function definitions together in one place and
> hopefully to be able to reduce the include hell with paravirt.
>
> Juergen Gross (14):
> x86/paravirt: remove not needed includes of paravirt.h
> x86/paravirt: remove some unneeded struct declarations
> x86/paravirt: remove PARAVIRT_DEBUG config option
> x86/paravirt: move thunk macros to paravirt_types.h
> paravirt: remove asm/paravirt_api_clock.h
> sched: move clock related paravirt code to kernel/sched
> arm/paravirt: use common code for paravirt_steal_clock()
> arm64/paravirt: use common code for paravirt_steal_clock()
> loongarch/paravirt: use common code for paravirt_steal_clock()
> riscv/paravirt: use common code for paravirt_steal_clock()
> x86/paravirt: use common code for paravirt_steal_clock()
> x86/paravirt: move paravirt_sched_clock() related code into tsc.c
> x86/paravirt: allow pv-calls outside paravirt.h
> x86/pvlocks: move paravirt spinlock functions into qspinlock.h
With the note that tip typically likes a capital after the prefix, like:
x86/paravirt: Remove unneeded includes of paravirt.h
For 1-12:
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Now, as to the last two, I'm not sure. Leaking those macros out of PV
isn't particularly nice, then again, not the end of the world either.
Just not sure.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 00/14] paravirt: cleanup and reorg
2025-09-11 7:48 ` [PATCH 00/14] paravirt: cleanup and reorg Peter Zijlstra
@ 2025-09-11 8:00 ` Jürgen Groß
0 siblings, 0 replies; 17+ messages in thread
From: Jürgen Groß @ 2025-09-11 8:00 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, x86, linux-hyperv, virtualization, loongarch,
linuxppc-dev, linux-riscv, kvm, Andy Lutomirski, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin,
K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Will Deacon,
Boqun Feng, Waiman Long, Jiri Kosina, Josh Poimboeuf, Pawan Gupta,
Boris Ostrovsky, xen-devel, Ajay Kaher, Alexey Makhalov,
Broadcom internal kernel review list, Russell King,
Catalin Marinas, Huacai Chen, WANG Xuerui, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, linux-arm-kernel,
Paolo Bonzini, Vitaly Kuznetsov, Stefano Stabellini,
Oleksandr Tyshchenko, Daniel Lezcano
[-- Attachment #1.1.1: Type: text/plain, Size: 3443 bytes --]
On 11.09.25 09:48, Peter Zijlstra wrote:
> On Thu, Sep 11, 2025 at 08:34:19AM +0200, Juergen Gross wrote:
>> Some cleanups and reorg of paravirt code and headers:
>>
>> - The first 2 patches should be not controversial at all, as they
>> remove just some no longer needed #include and struct forward
>> declarations.
>>
>> - The 3rd patch is removing CONFIG_PARAVIRT_DEBUG, which IMO has
>> no real value, as it just changes a crash to a BUG() (the stack
>> trace will basically be the same). As the maintainer of the main
>> paravirt user (Xen) I have never seen this crash/BUG() to happen.
>>
>> - The 4th patch is just a movement of code.
>>
>> - I don't know for what reason asm/paravirt_api_clock.h was added,
>> as all archs supporting it do it exactly in the same way. Patch
>> 5 is removing it.
>>
>> - Patches 6-12 are streamlining the paravirt clock interfaces by
>> using a common implementation across architectures where possible
>> and by moving the related code into common sched code, as this is
>> where it should live.
>>
>> - Patches 13+14 are more like RFC material: patch 13 is doing some
>> preparation work to enable patch 14 to move all spinlock related
>> paravirt functions into qspinlock.h. If this approach is accepted,
>> I'd like to continue with this work by moving most (or all?)
>> paravirt functions from paravirt.h into the headers where their
>> native counterparts are defined. This is meant to keep the native
>> and paravirt function definitions together in one place and
>> hopefully to be able to reduce the include hell with paravirt.
>>
>> Juergen Gross (14):
>> x86/paravirt: remove not needed includes of paravirt.h
>> x86/paravirt: remove some unneeded struct declarations
>> x86/paravirt: remove PARAVIRT_DEBUG config option
>> x86/paravirt: move thunk macros to paravirt_types.h
>> paravirt: remove asm/paravirt_api_clock.h
>> sched: move clock related paravirt code to kernel/sched
>> arm/paravirt: use common code for paravirt_steal_clock()
>> arm64/paravirt: use common code for paravirt_steal_clock()
>> loongarch/paravirt: use common code for paravirt_steal_clock()
>> riscv/paravirt: use common code for paravirt_steal_clock()
>> x86/paravirt: use common code for paravirt_steal_clock()
>> x86/paravirt: move paravirt_sched_clock() related code into tsc.c
>> x86/paravirt: allow pv-calls outside paravirt.h
>> x86/pvlocks: move paravirt spinlock functions into qspinlock.h
>
> With the note that tip typically likes a capital after the prefix, like:
>
> x86/paravirt: Remove unneeded includes of paravirt.h
Noted, thanks.
>
> For 1-12:
>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>
>
> Now, as to the last two, I'm not sure. Leaking those macros out of PV
> isn't particularly nice, then again, not the end of the world either.
> Just not sure.
Yes, that's why I didn't continue with all of the other potential movement of
paravirt functions. I want some feedback first. :-)
Its a tradeoff between having functions with / without paravirt in one file
against hiding the paravirt stuff from "normal" readers (not writers, as those
probably need to touch the paravirt variant, too).
BTW, I think the macro leaking isn't the main problem. There are other macros
leaking already.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 00/14] paravirt: cleanup and reorg
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
` (13 preceding siblings ...)
2025-09-11 7:48 ` [PATCH 00/14] paravirt: cleanup and reorg Peter Zijlstra
@ 2026-02-20 4:10 ` patchwork-bot+linux-riscv
14 siblings, 0 replies; 17+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-02-20 4:10 UTC (permalink / raw)
To: =?utf-8?b?SsO8cmdlbiBHcm/DnyA8amdyb3NzQHN1c2UuY29tPg==?=
Cc: linux-riscv, linux-kernel, x86, linux-hyperv, virtualization,
loongarch, linuxppc-dev, kvm, luto, tglx, mingo, bp, dave.hansen,
hpa, kys, haiyangz, wei.liu, decui, peterz, will, boqun.feng,
longman, jikos, jpoimboe, pawan.kumar.gupta, boris.ostrovsky,
xen-devel, ajay.kaher, alexey.makhalov, bcm-kernel-feedback-list,
linux, catalin.marinas, chenhuacai, kernel, maddy, mpe, npiggin,
christophe.leroy, paul.walmsley, palmer, aou, alex, juri.lelli,
vincent.guittot, dietmar.eggemann, rostedt, bsegall, mgorman,
vschneid, linux-arm-kernel, pbonzini, vkuznets, sstabellini,
oleksandr_tyshchenko, daniel.lezcano
Hello:
This series was applied to riscv/linux.git (fixes)
by Borislav Petkov (AMD) <bp@alien8.de>:
On Thu, 11 Sep 2025 08:34:19 +0200 you wrote:
> Some cleanups and reorg of paravirt code and headers:
>
> - The first 2 patches should be not controversial at all, as they
> remove just some no longer needed #include and struct forward
> declarations.
>
> - The 3rd patch is removing CONFIG_PARAVIRT_DEBUG, which IMO has
> no real value, as it just changes a crash to a BUG() (the stack
> trace will basically be the same). As the maintainer of the main
> paravirt user (Xen) I have never seen this crash/BUG() to happen.
>
> [...]
Here is the summary with links:
- [05/14] paravirt: remove asm/paravirt_api_clock.h
https://git.kernel.org/riscv/c/68b10fd40d49
- [06/14] sched: move clock related paravirt code to kernel/sched
(no matching commit)
- [10/14] riscv/paravirt: use common code for paravirt_steal_clock()
https://git.kernel.org/riscv/c/ee9ffcf99f07
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 17+ messages in thread