Skip to content

Commit 84af21d

Browse files
sean-jcPeter Zijlstra
authored andcommitted
perf: Drop dead and useless guest "support" from arm, csky, nds32 and riscv
Drop "support" for guest callbacks from architectures that don't implement the guest callbacks. Future patches will convert the callbacks to static_call; rather than churn a bunch of arch code (that was presumably copy+pasted from x86), remove it wholesale as it's useless and at best wasting cycles. A future patch will also add a Kconfig to force architcture to opt into the callbacks to make it more difficult for uses "support" to sneak in in the future. No functional change intended. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2934e3d commit 84af21d

File tree

4 files changed

+8
-84
lines changed

4 files changed

+8
-84
lines changed

arch/arm/kernel/perf_callchain.c

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,8 @@ user_backtrace(struct frame_tail __user *tail,
6262
void
6363
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
6464
{
65-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
6665
struct frame_tail __user *tail;
6766

68-
if (guest_cbs && guest_cbs->is_in_guest()) {
69-
/* We don't support guest os callchain now */
70-
return;
71-
}
72-
7367
perf_callchain_store(entry, regs->ARM_pc);
7468

7569
if (!current->mm)
@@ -99,44 +93,25 @@ callchain_trace(struct stackframe *fr,
9993
void
10094
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
10195
{
102-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
10396
struct stackframe fr;
10497

105-
if (guest_cbs && guest_cbs->is_in_guest()) {
106-
/* We don't support guest os callchain now */
107-
return;
108-
}
109-
11098
arm_get_current_stackframe(regs, &fr);
11199
walk_stackframe(&fr, callchain_trace, entry);
112100
}
113101

114102
unsigned long perf_instruction_pointer(struct pt_regs *regs)
115103
{
116-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
117-
118-
if (guest_cbs && guest_cbs->is_in_guest())
119-
return guest_cbs->get_guest_ip();
120-
121104
return instruction_pointer(regs);
122105
}
123106

124107
unsigned long perf_misc_flags(struct pt_regs *regs)
125108
{
126-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
127109
int misc = 0;
128110

129-
if (guest_cbs && guest_cbs->is_in_guest()) {
130-
if (guest_cbs->is_user_mode())
131-
misc |= PERF_RECORD_MISC_GUEST_USER;
132-
else
133-
misc |= PERF_RECORD_MISC_GUEST_KERNEL;
134-
} else {
135-
if (user_mode(regs))
136-
misc |= PERF_RECORD_MISC_USER;
137-
else
138-
misc |= PERF_RECORD_MISC_KERNEL;
139-
}
111+
if (user_mode(regs))
112+
misc |= PERF_RECORD_MISC_USER;
113+
else
114+
misc |= PERF_RECORD_MISC_KERNEL;
140115

141116
return misc;
142117
}

arch/csky/kernel/perf_callchain.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,8 @@ static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry,
8686
void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
8787
struct pt_regs *regs)
8888
{
89-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
9089
unsigned long fp = 0;
9190

92-
/* C-SKY does not support virtualization. */
93-
if (guest_cbs && guest_cbs->is_in_guest())
94-
return;
95-
9691
fp = regs->regs[4];
9792
perf_callchain_store(entry, regs->pc);
9893

@@ -111,15 +106,8 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
111106
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
112107
struct pt_regs *regs)
113108
{
114-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
115109
struct stackframe fr;
116110

117-
/* C-SKY does not support virtualization. */
118-
if (guest_cbs && guest_cbs->is_in_guest()) {
119-
pr_warn("C-SKY does not support perf in guest mode!");
120-
return;
121-
}
122-
123111
fr.fp = regs->regs[4];
124112
fr.lr = regs->lr;
125113
walk_stackframe(&fr, entry);

arch/nds32/kernel/perf_event_cpu.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,6 @@ void
13631363
perf_callchain_user(struct perf_callchain_entry_ctx *entry,
13641364
struct pt_regs *regs)
13651365
{
1366-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
13671366
unsigned long fp = 0;
13681367
unsigned long gp = 0;
13691368
unsigned long lp = 0;
@@ -1372,11 +1371,6 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry,
13721371

13731372
leaf_fp = 0;
13741373

1375-
if (guest_cbs && guest_cbs->is_in_guest()) {
1376-
/* We don't support guest os callchain now */
1377-
return;
1378-
}
1379-
13801374
perf_callchain_store(entry, regs->ipc);
13811375
fp = regs->fp;
13821376
gp = regs->gp;
@@ -1480,13 +1474,8 @@ void
14801474
perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
14811475
struct pt_regs *regs)
14821476
{
1483-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
14841477
struct stackframe fr;
14851478

1486-
if (guest_cbs && guest_cbs->is_in_guest()) {
1487-
/* We don't support guest os callchain now */
1488-
return;
1489-
}
14901479
fr.fp = regs->fp;
14911480
fr.lp = regs->lp;
14921481
fr.sp = regs->sp;
@@ -1495,32 +1484,17 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
14951484

14961485
unsigned long perf_instruction_pointer(struct pt_regs *regs)
14971486
{
1498-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
1499-
1500-
/* However, NDS32 does not support virtualization */
1501-
if (guest_cbs && guest_cbs->is_in_guest())
1502-
return guest_cbs->get_guest_ip();
1503-
15041487
return instruction_pointer(regs);
15051488
}
15061489

15071490
unsigned long perf_misc_flags(struct pt_regs *regs)
15081491
{
1509-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
15101492
int misc = 0;
15111493

1512-
/* However, NDS32 does not support virtualization */
1513-
if (guest_cbs && guest_cbs->is_in_guest()) {
1514-
if (guest_cbs->is_user_mode())
1515-
misc |= PERF_RECORD_MISC_GUEST_USER;
1516-
else
1517-
misc |= PERF_RECORD_MISC_GUEST_KERNEL;
1518-
} else {
1519-
if (user_mode(regs))
1520-
misc |= PERF_RECORD_MISC_USER;
1521-
else
1522-
misc |= PERF_RECORD_MISC_KERNEL;
1523-
}
1494+
if (user_mode(regs))
1495+
misc |= PERF_RECORD_MISC_USER;
1496+
else
1497+
misc |= PERF_RECORD_MISC_KERNEL;
15241498

15251499
return misc;
15261500
}

arch/riscv/kernel/perf_callchain.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,8 @@ static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry,
5656
void perf_callchain_user(struct perf_callchain_entry_ctx *entry,
5757
struct pt_regs *regs)
5858
{
59-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
6059
unsigned long fp = 0;
6160

62-
/* RISC-V does not support perf in guest mode. */
63-
if (guest_cbs && guest_cbs->is_in_guest())
64-
return;
65-
6661
fp = regs->s0;
6762
perf_callchain_store(entry, regs->epc);
6863

@@ -79,13 +74,5 @@ static bool fill_callchain(void *entry, unsigned long pc)
7974
void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
8075
struct pt_regs *regs)
8176
{
82-
struct perf_guest_info_callbacks *guest_cbs = perf_get_guest_cbs();
83-
84-
/* RISC-V does not support perf in guest mode. */
85-
if (guest_cbs && guest_cbs->is_in_guest()) {
86-
pr_warn("RISC-V does not support perf in guest mode!");
87-
return;
88-
}
89-
9077
walk_stackframe(NULL, regs, fill_callchain, entry);
9178
}

0 commit comments

Comments
 (0)