* [PATCH 00/14] paravirt: cleanup and reorg
@ 2025-09-11 6:34 Juergen Gross
2025-09-11 6:34 ` [PATCH 01/14] x86/paravirt: remove not needed includes of paravirt.h Juergen Gross
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, linux-hyperv, virtualization, loongarch,
linuxppc-dev, linux-riscv, kvm
Cc: Juergen Gross, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, H. Peter Anvin, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Peter Zijlstra, 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
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
arch/Kconfig | 3 +
arch/arm/Kconfig | 1 +
arch/arm/include/asm/paravirt.h | 22 ---
arch/arm/include/asm/paravirt_api_clock.h | 1 -
arch/arm/kernel/Makefile | 1 -
arch/arm/kernel/paravirt.c | 23 ---
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/paravirt.h | 14 --
arch/arm64/include/asm/paravirt_api_clock.h | 1 -
arch/arm64/kernel/paravirt.c | 11 +-
arch/loongarch/Kconfig | 1 +
arch/loongarch/include/asm/paravirt.h | 13 --
.../include/asm/paravirt_api_clock.h | 1 -
arch/loongarch/kernel/paravirt.c | 10 +-
arch/powerpc/include/asm/paravirt.h | 3 -
arch/powerpc/include/asm/paravirt_api_clock.h | 2 -
arch/powerpc/platforms/pseries/setup.c | 4 +-
arch/riscv/Kconfig | 1 +
arch/riscv/include/asm/paravirt.h | 14 --
arch/riscv/include/asm/paravirt_api_clock.h | 1 -
arch/riscv/kernel/paravirt.c | 11 +-
arch/x86/Kconfig | 8 +-
arch/x86/entry/entry_64.S | 1 -
arch/x86/entry/vsyscall/vsyscall_64.c | 1 -
arch/x86/hyperv/hv_spinlock.c | 1 -
arch/x86/include/asm/apic.h | 4 -
arch/x86/include/asm/highmem.h | 1 -
arch/x86/include/asm/mmu_context.h | 1 -
arch/x86/include/asm/mshyperv.h | 1 -
arch/x86/include/asm/paravirt.h | 166 ------------------
arch/x86/include/asm/paravirt_api_clock.h | 1 -
arch/x86/include/asm/paravirt_types.h | 82 +++++++--
arch/x86/include/asm/pgtable_32.h | 1 -
arch/x86/include/asm/qspinlock.h | 49 +++++-
arch/x86/include/asm/spinlock.h | 1 -
arch/x86/include/asm/timer.h | 1 +
arch/x86/include/asm/tlbflush.h | 4 -
arch/x86/kernel/apm_32.c | 1 -
arch/x86/kernel/callthunks.c | 1 -
arch/x86/kernel/cpu/bugs.c | 1 -
arch/x86/kernel/cpu/vmware.c | 1 +
arch/x86/kernel/kvm.c | 1 +
arch/x86/kernel/kvmclock.c | 1 +
arch/x86/kernel/paravirt.c | 16 --
arch/x86/kernel/tsc.c | 10 +-
arch/x86/kernel/vsmp_64.c | 1 -
arch/x86/kernel/x86_init.c | 1 -
arch/x86/lib/cache-smp.c | 1 -
arch/x86/mm/init.c | 1 -
arch/x86/xen/spinlock.c | 1 -
arch/x86/xen/time.c | 2 +
drivers/clocksource/hyperv_timer.c | 2 +
drivers/xen/time.c | 2 +-
include/linux/sched/cputime.h | 18 ++
kernel/sched/core.c | 5 +
kernel/sched/cputime.c | 13 ++
kernel/sched/sched.h | 3 +-
57 files changed, 182 insertions(+), 362 deletions(-)
delete mode 100644 arch/arm/include/asm/paravirt.h
delete mode 100644 arch/arm/include/asm/paravirt_api_clock.h
delete mode 100644 arch/arm/kernel/paravirt.c
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
--
2.51.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 01/14] x86/paravirt: remove not needed includes of paravirt.h
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 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c Juergen Gross
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Juergen Gross @ 2025-09-11 6:34 UTC (permalink / raw)
To: linux-kernel, x86, linux-hyperv
Cc: Juergen Gross, Andy Lutomirski, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, H. Peter Anvin, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Peter Zijlstra, Will Deacon,
Boqun Feng, Waiman Long, Jiri Kosina, Josh Poimboeuf, Pawan Gupta,
Boris Ostrovsky, xen-devel
In some places asm/paravirt.h is included without really being needed.
Remove the related #include statements.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/entry/entry_64.S | 1 -
arch/x86/entry/vsyscall/vsyscall_64.c | 1 -
arch/x86/hyperv/hv_spinlock.c | 1 -
arch/x86/include/asm/apic.h | 4 ----
arch/x86/include/asm/highmem.h | 1 -
arch/x86/include/asm/mmu_context.h | 1 -
arch/x86/include/asm/mshyperv.h | 1 -
arch/x86/include/asm/pgtable_32.h | 1 -
arch/x86/include/asm/spinlock.h | 1 -
arch/x86/include/asm/tlbflush.h | 4 ----
arch/x86/kernel/apm_32.c | 1 -
arch/x86/kernel/callthunks.c | 1 -
arch/x86/kernel/cpu/bugs.c | 1 -
arch/x86/kernel/vsmp_64.c | 1 -
arch/x86/kernel/x86_init.c | 1 -
arch/x86/lib/cache-smp.c | 1 -
arch/x86/mm/init.c | 1 -
arch/x86/xen/spinlock.c | 1 -
18 files changed, 24 deletions(-)
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index ed04a968cc7d..7a82305405af 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -30,7 +30,6 @@
#include <asm/hw_irq.h>
#include <asm/page_types.h>
#include <asm/irqflags.h>
-#include <asm/paravirt.h>
#include <asm/percpu.h>
#include <asm/asm.h>
#include <asm/smap.h>
diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
index c9103a6fa06e..53e50b506471 100644
--- a/arch/x86/entry/vsyscall/vsyscall_64.c
+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
@@ -37,7 +37,6 @@
#include <asm/unistd.h>
#include <asm/fixmap.h>
#include <asm/traps.h>
-#include <asm/paravirt.h>
#define CREATE_TRACE_POINTS
#include "vsyscall_trace.h"
diff --git a/arch/x86/hyperv/hv_spinlock.c b/arch/x86/hyperv/hv_spinlock.c
index 81b006601370..2a3c2afb0154 100644
--- a/arch/x86/hyperv/hv_spinlock.c
+++ b/arch/x86/hyperv/hv_spinlock.c
@@ -13,7 +13,6 @@
#include <linux/spinlock.h>
#include <asm/mshyperv.h>
-#include <asm/paravirt.h>
#include <asm/apic.h>
#include <asm/msr.h>
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 07ba4935e873..e1de090e51dd 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -90,10 +90,6 @@ static inline bool apic_from_smp_config(void)
/*
* Basic functions accessing APICs.
*/
-#ifdef CONFIG_PARAVIRT
-#include <asm/paravirt.h>
-#endif
-
static inline void native_apic_mem_write(u32 reg, u32 v)
{
volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h
index 585bdadba47d..decfaaf52326 100644
--- a/arch/x86/include/asm/highmem.h
+++ b/arch/x86/include/asm/highmem.h
@@ -24,7 +24,6 @@
#include <linux/interrupt.h>
#include <linux/threads.h>
#include <asm/tlbflush.h>
-#include <asm/paravirt.h>
#include <asm/fixmap.h>
#include <asm/pgtable_areas.h>
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 73bf3b1b44e8..ee15657d25b3 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -9,7 +9,6 @@
#include <trace/events/tlb.h>
#include <asm/tlbflush.h>
-#include <asm/paravirt.h>
#include <asm/debugreg.h>
#include <asm/gsseg.h>
#include <asm/desc.h>
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index abc4659f5809..a9ab46fcb6a1 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -7,7 +7,6 @@
#include <linux/msi.h>
#include <linux/io.h>
#include <asm/nospec-branch.h>
-#include <asm/paravirt.h>
#include <asm/msr.h>
#include <hyperv/hvhdk.h>
diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
index b612cc57a4d3..acea0cfa2460 100644
--- a/arch/x86/include/asm/pgtable_32.h
+++ b/arch/x86/include/asm/pgtable_32.h
@@ -16,7 +16,6 @@
#ifndef __ASSEMBLER__
#include <asm/processor.h>
#include <linux/threads.h>
-#include <asm/paravirt.h>
#include <linux/bitops.h>
#include <linux/list.h>
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 5b6bc7016c22..934632b78d09 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -7,7 +7,6 @@
#include <asm/page.h>
#include <asm/processor.h>
#include <linux/compiler.h>
-#include <asm/paravirt.h>
#include <asm/bitops.h>
/*
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index 00daedfefc1b..238a6b807da5 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -300,10 +300,6 @@ static inline void mm_clear_asid_transition(struct mm_struct *mm) { }
static inline bool mm_in_asid_transition(struct mm_struct *mm) { return false; }
#endif /* CONFIG_BROADCAST_TLB_FLUSH */
-#ifdef CONFIG_PARAVIRT
-#include <asm/paravirt.h>
-#endif
-
#define flush_tlb_mm(mm) \
flush_tlb_mm_range(mm, 0UL, TLB_FLUSH_ALL, 0UL, true)
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index b37ab1095707..3175d7c134e9 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -229,7 +229,6 @@
#include <linux/uaccess.h>
#include <asm/desc.h>
#include <asm/olpc.h>
-#include <asm/paravirt.h>
#include <asm/reboot.h>
#include <asm/nospec-branch.h>
#include <asm/ibt.h>
diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index a951333c5995..e37728f70322 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -15,7 +15,6 @@
#include <asm/insn.h>
#include <asm/kexec.h>
#include <asm/nospec-branch.h>
-#include <asm/paravirt.h>
#include <asm/sections.h>
#include <asm/switch_to.h>
#include <asm/sync_core.h>
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index af838b8d845c..00ac4a58542a 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -25,7 +25,6 @@
#include <asm/fpu/api.h>
#include <asm/msr.h>
#include <asm/vmx.h>
-#include <asm/paravirt.h>
#include <asm/cpu_device_id.h>
#include <asm/e820/api.h>
#include <asm/hypervisor.h>
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index 73511332bb67..25625e3fc183 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -18,7 +18,6 @@
#include <asm/apic.h>
#include <asm/pci-direct.h>
#include <asm/io.h>
-#include <asm/paravirt.h>
#include <asm/setup.h>
#define TOPOLOGY_REGISTER_OFFSET 0x10
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 0a2bbd674a6d..02ca90378bf9 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -12,7 +12,6 @@
#include <asm/acpi.h>
#include <asm/bios_ebda.h>
-#include <asm/paravirt.h>
#include <asm/pci_x86.h>
#include <asm/mpspec.h>
#include <asm/setup.h>
diff --git a/arch/x86/lib/cache-smp.c b/arch/x86/lib/cache-smp.c
index c5c60d07308c..ae5a5dfd33c7 100644
--- a/arch/x86/lib/cache-smp.c
+++ b/arch/x86/lib/cache-smp.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#include <asm/paravirt.h>
#include <linux/smp.h>
#include <linux/export.h>
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index bb57e93b4caf..f52ebcac50d9 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -27,7 +27,6 @@
#include <asm/pti.h>
#include <asm/text-patching.h>
#include <asm/memtype.h>
-#include <asm/paravirt.h>
#include <asm/mmu_context.h>
/*
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index 8e4efe0fb6f9..fe56646d6919 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -8,7 +8,6 @@
#include <linux/slab.h>
#include <linux/atomic.h>
-#include <asm/paravirt.h>
#include <asm/qspinlock.h>
#include <xen/events.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ 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
2025-09-11 6:34 ` [PATCH 01/14] x86/paravirt: remove not needed includes of 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
3 siblings, 0 replies; 6+ 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] 6+ 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
2025-09-11 6:34 ` [PATCH 01/14] x86/paravirt: remove not needed includes of paravirt.h Juergen Gross
2025-09-11 6:34 ` [PATCH 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c 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
3 siblings, 1 reply; 6+ 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] 6+ 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; 6+ 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] 6+ 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
` (2 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
3 siblings, 0 replies; 6+ 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] 6+ messages in thread
end of thread, other threads:[~2026-02-20 4:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11 6:34 [PATCH 00/14] paravirt: cleanup and reorg Juergen Gross
2025-09-11 6:34 ` [PATCH 01/14] x86/paravirt: remove not needed includes of paravirt.h Juergen Gross
2025-09-11 6:34 ` [PATCH 12/14] x86/paravirt: move paravirt_sched_clock() related code into tsc.c Juergen Gross
2025-09-11 7:48 ` [PATCH 00/14] paravirt: cleanup and reorg Peter Zijlstra
2025-09-11 8:00 ` Jürgen Groß
2026-02-20 4:10 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox