Skip to content

Commit 04782e6

Browse files
coltonlewisIngo Molnar
authored andcommitted
perf/core: Hoist perf_instruction_pointer() and perf_misc_flags()
For clarity, rename the arch-specific definitions of these functions to perf_arch_* to denote they are arch-specifc. Define the generic-named functions in one place where they can call the arch-specific ones as needed. Signed-off-by: Colton Lewis <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Acked-by: Thomas Richter <[email protected]> Acked-by: Mark Rutland <[email protected]> Acked-by: Madhavan Srinivasan <[email protected]> Acked-by: Kan Liang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e33ed36 commit 04782e6

File tree

10 files changed

+38
-25
lines changed

10 files changed

+38
-25
lines changed

arch/arm64/include/asm/perf_event.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
#ifdef CONFIG_PERF_EVENTS
1313
struct pt_regs;
14-
extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
15-
extern unsigned long perf_misc_flags(struct pt_regs *regs);
16-
#define perf_misc_flags(regs) perf_misc_flags(regs)
14+
extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs);
15+
extern unsigned long perf_arch_misc_flags(struct pt_regs *regs);
16+
#define perf_arch_misc_flags(regs) perf_misc_flags(regs)
1717
#define perf_arch_bpf_user_pt_regs(regs) &regs->user_regs
1818
#endif
1919

arch/arm64/kernel/perf_callchain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
3939
arch_stack_walk(callchain_trace, entry, current, regs);
4040
}
4141

42-
unsigned long perf_instruction_pointer(struct pt_regs *regs)
42+
unsigned long perf_arch_instruction_pointer(struct pt_regs *regs)
4343
{
4444
if (perf_guest_state())
4545
return perf_guest_get_ip();
4646

4747
return instruction_pointer(regs);
4848
}
4949

50-
unsigned long perf_misc_flags(struct pt_regs *regs)
50+
unsigned long perf_arch_misc_flags(struct pt_regs *regs)
5151
{
5252
unsigned int guest_state = perf_guest_state();
5353
int misc = 0;

arch/powerpc/include/asm/perf_event_server.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ struct power_pmu {
102102
int __init register_power_pmu(struct power_pmu *pmu);
103103

104104
struct pt_regs;
105-
extern unsigned long perf_misc_flags(struct pt_regs *regs);
106-
extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
105+
extern unsigned long perf_arch_misc_flags(struct pt_regs *regs);
106+
extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs);
107107
extern unsigned long int read_bhrb(int n);
108108

109109
/*
110110
* Only override the default definitions in include/linux/perf_event.h
111111
* if we have hardware PMU support.
112112
*/
113113
#ifdef CONFIG_PPC_PERF_CTRS
114-
#define perf_misc_flags(regs) perf_misc_flags(regs)
114+
#define perf_arch_misc_flags(regs) perf_arch_misc_flags(regs)
115115
#endif
116116

117117
/*

arch/powerpc/perf/core-book3s.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
23322332
* Called from generic code to get the misc flags (i.e. processor mode)
23332333
* for an event_id.
23342334
*/
2335-
unsigned long perf_misc_flags(struct pt_regs *regs)
2335+
unsigned long perf_arch_misc_flags(struct pt_regs *regs)
23362336
{
23372337
u32 flags = perf_get_misc_flags(regs);
23382338

@@ -2346,7 +2346,7 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
23462346
* Called from generic code to get the instruction pointer
23472347
* for an event_id.
23482348
*/
2349-
unsigned long perf_instruction_pointer(struct pt_regs *regs)
2349+
unsigned long perf_arch_instruction_pointer(struct pt_regs *regs)
23502350
{
23512351
unsigned long siar = mfspr(SPRN_SIAR);
23522352

arch/s390/include/asm/perf_event.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ extern ssize_t cpumf_events_sysfs_show(struct device *dev,
3737

3838
/* Perf callbacks */
3939
struct pt_regs;
40-
extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
41-
extern unsigned long perf_misc_flags(struct pt_regs *regs);
42-
#define perf_misc_flags(regs) perf_misc_flags(regs)
40+
extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs);
41+
extern unsigned long perf_arch_misc_flags(struct pt_regs *regs);
42+
#define perf_arch_misc_flags(regs) perf_arch_misc_flags(regs)
4343
#define perf_arch_bpf_user_pt_regs(regs) &regs->user_regs
4444

4545
/* Perf pt_regs extension for sample-data-entry indicators */

arch/s390/kernel/perf_event.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static unsigned long instruction_pointer_guest(struct pt_regs *regs)
5757
return sie_block(regs)->gpsw.addr;
5858
}
5959

60-
unsigned long perf_instruction_pointer(struct pt_regs *regs)
60+
unsigned long perf_arch_instruction_pointer(struct pt_regs *regs)
6161
{
6262
return is_in_guest(regs) ? instruction_pointer_guest(regs)
6363
: instruction_pointer(regs);
@@ -84,7 +84,7 @@ static unsigned long perf_misc_flags_sf(struct pt_regs *regs)
8484
return flags;
8585
}
8686

87-
unsigned long perf_misc_flags(struct pt_regs *regs)
87+
unsigned long perf_arch_misc_flags(struct pt_regs *regs)
8888
{
8989
/* Check if the cpum_sf PMU has created the pt_regs structure.
9090
* In this case, perf misc flags can be easily extracted. Otherwise,

arch/x86/events/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,15 +3003,15 @@ static unsigned long code_segment_base(struct pt_regs *regs)
30033003
return 0;
30043004
}
30053005

3006-
unsigned long perf_instruction_pointer(struct pt_regs *regs)
3006+
unsigned long perf_arch_instruction_pointer(struct pt_regs *regs)
30073007
{
30083008
if (perf_guest_state())
30093009
return perf_guest_get_ip();
30103010

30113011
return regs->ip + code_segment_base(regs);
30123012
}
30133013

3014-
unsigned long perf_misc_flags(struct pt_regs *regs)
3014+
unsigned long perf_arch_misc_flags(struct pt_regs *regs)
30153015
{
30163016
unsigned int guest_state = perf_guest_state();
30173017
int misc = 0;

arch/x86/include/asm/perf_event.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,15 @@ struct x86_perf_regs {
536536
u64 *xmm_regs;
537537
};
538538

539-
extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
540-
extern unsigned long perf_misc_flags(struct pt_regs *regs);
541-
#define perf_misc_flags(regs) perf_misc_flags(regs)
539+
extern unsigned long perf_arch_instruction_pointer(struct pt_regs *regs);
540+
extern unsigned long perf_arch_misc_flags(struct pt_regs *regs);
541+
#define perf_arch_misc_flags(regs) perf_arch_misc_flags(regs)
542542

543543
#include <asm/stacktrace.h>
544544

545545
/*
546-
* We abuse bit 3 from flags to pass exact information, see perf_misc_flags
547-
* and the comment with PERF_EFLAGS_EXACT.
546+
* We abuse bit 3 from flags to pass exact information, see
547+
* perf_arch_misc_flags() and the comment with PERF_EFLAGS_EXACT.
548548
*/
549549
#define perf_arch_fetch_caller_regs(regs, __ip) { \
550550
(regs)->ip = (__ip); \

include/linux/perf_event.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,10 +1676,13 @@ extern void perf_tp_event(u16 event_type, u64 count, void *record,
16761676
struct task_struct *task);
16771677
extern void perf_bp_event(struct perf_event *event, void *data);
16781678

1679-
#ifndef perf_misc_flags
1680-
# define perf_misc_flags(regs) \
1679+
extern unsigned long perf_misc_flags(struct pt_regs *regs);
1680+
extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
1681+
1682+
#ifndef perf_arch_misc_flags
1683+
# define perf_arch_misc_flags(regs) \
16811684
(user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL)
1682-
# define perf_instruction_pointer(regs) instruction_pointer(regs)
1685+
# define perf_arch_instruction_pointer(regs) instruction_pointer(regs)
16831686
#endif
16841687
#ifndef perf_arch_bpf_user_pt_regs
16851688
# define perf_arch_bpf_user_pt_regs(regs) regs

kernel/events/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7026,6 +7026,16 @@ void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
70267026
EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks);
70277027
#endif
70287028

7029+
unsigned long perf_misc_flags(struct pt_regs *regs)
7030+
{
7031+
return perf_arch_misc_flags(regs);
7032+
}
7033+
7034+
unsigned long perf_instruction_pointer(struct pt_regs *regs)
7035+
{
7036+
return perf_arch_instruction_pointer(regs);
7037+
}
7038+
70297039
static void
70307040
perf_output_sample_regs(struct perf_output_handle *handle,
70317041
struct pt_regs *regs, u64 mask)

0 commit comments

Comments
 (0)