Skip to content

Commit 39965af

Browse files
jgross1bp3tk0v
authored andcommitted
x86/paravirt: Move paravirt_sched_clock() related code into tsc.c
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> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260105110520.21356-13-jgross@suse.com
1 parent 589f41f commit 39965af

7 files changed

Lines changed: 14 additions & 20 deletions

File tree

arch/x86/include/asm/paravirt.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,8 @@
1414
#ifndef __ASSEMBLER__
1515
#include <linux/types.h>
1616
#include <linux/cpumask.h>
17-
#include <linux/static_call_types.h>
1817
#include <asm/frame.h>
1918

20-
u64 dummy_sched_clock(void);
21-
22-
DECLARE_STATIC_CALL(pv_sched_clock, dummy_sched_clock);
23-
24-
void paravirt_set_sched_clock(u64 (*func)(void));
25-
26-
static __always_inline u64 paravirt_sched_clock(void)
27-
{
28-
return static_call(pv_sched_clock)();
29-
}
30-
3119
__visible void __native_queued_spin_unlock(struct qspinlock *lock);
3220
bool pv_is_native_spin_unlock(void);
3321
__visible bool __native_vcpu_is_preempted(long cpu);

arch/x86/include/asm/timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extern void recalibrate_cpu_khz(void);
1212
extern int no_timer_check;
1313

1414
extern bool using_native_sched_clock(void);
15+
void paravirt_set_sched_clock(u64 (*func)(void));
1516

1617
/*
1718
* We use the full linear equation: f(x) = a + b*x, in order to allow

arch/x86/kernel/kvmclock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/cc_platform.h>
2020

2121
#include <asm/hypervisor.h>
22+
#include <asm/timer.h>
2223
#include <asm/x86_init.h>
2324
#include <asm/kvmclock.h>
2425

arch/x86/kernel/paravirt.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ void __init native_pv_lock_init(void)
6060
static_branch_enable(&virt_spin_lock_key);
6161
}
6262

63-
DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock);
64-
65-
void paravirt_set_sched_clock(u64 (*func)(void))
66-
{
67-
static_call_update(pv_sched_clock, func);
68-
}
69-
7063
static noinstr void pv_native_safe_halt(void)
7164
{
7265
native_safe_halt();

arch/x86/kernel/tsc.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,27 @@ u64 native_sched_clock_from_tsc(u64 tsc)
267267
/* We need to define a real function for sched_clock, to override the
268268
weak default version */
269269
#ifdef CONFIG_PARAVIRT
270+
DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock);
271+
270272
noinstr u64 sched_clock_noinstr(void)
271273
{
272-
return paravirt_sched_clock();
274+
return static_call(pv_sched_clock)();
273275
}
274276

275277
bool using_native_sched_clock(void)
276278
{
277279
return static_call_query(pv_sched_clock) == native_sched_clock;
278280
}
281+
282+
void paravirt_set_sched_clock(u64 (*func)(void))
283+
{
284+
static_call_update(pv_sched_clock, func);
285+
}
279286
#else
280287
u64 sched_clock_noinstr(void) __attribute__((alias("native_sched_clock")));
281288

282289
bool using_native_sched_clock(void) { return true; }
290+
void paravirt_set_sched_clock(u64 (*func)(void)) { }
283291
#endif
284292

285293
notrace u64 sched_clock(void)

arch/x86/xen/time.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/sched/cputime.h>
2020

2121
#include <asm/pvclock.h>
22+
#include <asm/timer.h>
2223
#include <asm/xen/hypervisor.h>
2324
#include <asm/xen/hypercall.h>
2425
#include <asm/xen/cpuid.h>

drivers/clocksource/hyperv_timer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ static __always_inline void hv_setup_sched_clock(void *sched_clock)
535535
sched_clock_register(sched_clock, 64, NSEC_PER_SEC);
536536
}
537537
#elif defined CONFIG_PARAVIRT
538+
#include <asm/timer.h>
539+
538540
static __always_inline void hv_setup_sched_clock(void *sched_clock)
539541
{
540542
/* We're on x86/x64 *and* using PV ops */

0 commit comments

Comments
 (0)