Skip to content

Commit e6b2aa6

Browse files
jgross1bp3tk0v
authored andcommitted
sched: Move clock related paravirt code to kernel/sched
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 selected by an arch in case it wants to use that common variant. 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-7-jgross@suse.com
1 parent 68b10fd commit e6b2aa6

20 files changed

Lines changed: 47 additions & 40 deletions

File tree

arch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,9 @@ config HAVE_IRQ_TIME_ACCOUNTING
10561056
Archs need to ensure they use a high enough resolution clock to
10571057
support irq time accounting and then call enable_sched_clock_irqtime().
10581058

1059+
config HAVE_PV_STEAL_CLOCK_GEN
1060+
bool
1061+
10591062
config HAVE_MOVE_PUD
10601063
bool
10611064
help

arch/arm/include/asm/paravirt.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifdef CONFIG_PARAVIRT
66
#include <linux/static_call_types.h>
77

8-
struct static_key;
9-
extern struct static_key paravirt_steal_enabled;
10-
extern struct static_key paravirt_steal_rq_enabled;
11-
128
u64 dummy_steal_clock(int cpu);
139

1410
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

arch/arm/kernel/paravirt.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#include <linux/static_call.h>
1313
#include <asm/paravirt.h>
1414

15-
struct static_key paravirt_steal_enabled;
16-
struct static_key paravirt_steal_rq_enabled;
17-
1815
static u64 native_steal_clock(int cpu)
1916
{
2017
return 0;

arch/arm64/include/asm/paravirt.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifdef CONFIG_PARAVIRT
66
#include <linux/static_call_types.h>
77

8-
struct static_key;
9-
extern struct static_key paravirt_steal_enabled;
10-
extern struct static_key paravirt_steal_rq_enabled;
11-
128
u64 dummy_steal_clock(int cpu);
139

1410
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

arch/arm64/kernel/paravirt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
#include <linux/slab.h>
2020
#include <linux/types.h>
2121
#include <linux/static_call.h>
22+
#include <linux/sched/cputime.h>
2223

2324
#include <asm/paravirt.h>
2425
#include <asm/pvclock-abi.h>
2526
#include <asm/smp_plat.h>
2627

27-
struct static_key paravirt_steal_enabled;
28-
struct static_key paravirt_steal_rq_enabled;
29-
3028
static u64 native_steal_clock(int cpu)
3129
{
3230
return 0;

arch/loongarch/include/asm/paravirt.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#ifdef CONFIG_PARAVIRT
66

77
#include <linux/static_call_types.h>
8-
struct static_key;
9-
extern struct static_key paravirt_steal_enabled;
10-
extern struct static_key paravirt_steal_rq_enabled;
118

129
u64 dummy_steal_clock(int cpu);
1310
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

arch/loongarch/kernel/paravirt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
#include <linux/kvm_para.h>
77
#include <linux/reboot.h>
88
#include <linux/static_call.h>
9+
#include <linux/sched/cputime.h>
910
#include <asm/paravirt.h>
1011

1112
static int has_steal_clock;
12-
struct static_key paravirt_steal_enabled;
13-
struct static_key paravirt_steal_rq_enabled;
1413
static DEFINE_PER_CPU(struct kvm_steal_time, steal_time) __aligned(64);
1514
DEFINE_STATIC_KEY_FALSE(virt_spin_lock_key);
1615

arch/powerpc/include/asm/paravirt.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ static inline bool is_shared_processor(void)
2323
}
2424

2525
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
26-
extern struct static_key paravirt_steal_enabled;
27-
extern struct static_key paravirt_steal_rq_enabled;
28-
2926
u64 pseries_paravirt_steal_clock(int cpu);
3027

3128
static inline u64 paravirt_steal_clock(int cpu)

arch/powerpc/platforms/pseries/setup.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <linux/memblock.h>
4343
#include <linux/swiotlb.h>
4444
#include <linux/seq_buf.h>
45+
#include <linux/sched/cputime.h>
4546

4647
#include <asm/mmu.h>
4748
#include <asm/processor.h>
@@ -83,9 +84,6 @@ DEFINE_STATIC_KEY_FALSE(shared_processor);
8384
EXPORT_SYMBOL(shared_processor);
8485

8586
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
86-
struct static_key paravirt_steal_enabled;
87-
struct static_key paravirt_steal_rq_enabled;
88-
8987
static bool steal_acc = true;
9088
static int __init parse_no_stealacc(char *arg)
9189
{

arch/riscv/include/asm/paravirt.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#ifdef CONFIG_PARAVIRT
66
#include <linux/static_call_types.h>
77

8-
struct static_key;
9-
extern struct static_key paravirt_steal_enabled;
10-
extern struct static_key paravirt_steal_rq_enabled;
11-
128
u64 dummy_steal_clock(int cpu);
139

1410
DECLARE_STATIC_CALL(pv_steal_clock, dummy_steal_clock);

0 commit comments

Comments
 (0)