[PATCH v8 5/5] perf: Correct perf sampling with guest VMs

2024-11-13 Thread Colton Lewis
still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. Signed-off-by: Colton Lewis Acked-by: Mark Rutland Acked-by: Kan Liang Reviewed-by: Oliver Upton --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c

[PATCH v8 4/5] x86: perf: Refactor misc flag assignments

2024-11-13 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis Acked-by: Kan Liang Reviewed-by: Oliver Upton --- arch/x86/events/core.c| 59 ++- arch/x86/include

[PATCH v8 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-11-13 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis Acked-by: Madhavan Srinivasan Reviewed-by: Oliver Upton --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c

[PATCH v8 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-11-13 Thread Colton Lewis
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 Acked-by: Thomas Richter Acked-by: Mark Rutland

[PATCH v8 1/5] arm: perf: Drop unused functions

2024-11-13 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis Acked-by: Will Deacon Reviewed-by: Ol

[PATCH v8 0/5] Correct perf sampling with Guest VMs

2024-11-13 Thread Colton Lewis
llsyms][k] handle_mm_fault 0.74% dirty_log_perf_ [kernel.kallsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop unused functions perf: Hoist perf_instruction_pointer() and perf_misc_flags() powerpc: perf: Use perf_arch_instruction_pointer() x86: perf: Refactor misc flag as

Re: [PATCH v7 4/5] x86: perf: Refactor misc flag assignments

2024-11-13 Thread Colton Lewis
Colton Lewis writes: Peter Zijlstra writes: On Fri, Nov 08, 2024 at 08:20:44PM +0100, Peter Zijlstra wrote: Isn't the below more or less what you want? static unsigned long misc_flags(struct pt_regs *regs) { unsigned long flags = 0; if (regs-&

Re: [PATCH v7 4/5] x86: perf: Refactor misc flag assignments

2024-11-13 Thread Colton Lewis
Peter Zijlstra writes: On Fri, Nov 08, 2024 at 08:20:44PM +0100, Peter Zijlstra wrote: Isn't the below more or less what you want? static unsigned long misc_flags(struct pt_regs *regs) { unsigned long flags = 0; if (regs->flags & PERF_EFLAGS_EXACT) flags

Re: [PATCH v7 4/5] x86: perf: Refactor misc flag assignments

2024-11-08 Thread Colton Lewis
Peter Zijlstra writes: On Thu, Nov 07, 2024 at 07:03:35PM +, Colton Lewis wrote: Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis Reviewed-by: Oliver Upton --- arch/x86/events

[PATCH v7 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-11-07 Thread Colton Lewis
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 Acked-by: Thomas Richter Acked-by: Mark Rutland

[PATCH v7 4/5] x86: perf: Refactor misc flag assignments

2024-11-07 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis Reviewed-by: Oliver Upton --- arch/x86/events/core.c| 32 +++ arch/x86/include/asm/perf_event.h | 2

[PATCH v7 1/5] arm: perf: Drop unused functions

2024-11-07 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis Acked-by: Will Deacon Reviewed-by: Ol

[PATCH v7 5/5] perf: Correct perf sampling with guest VMs

2024-11-07 Thread Colton Lewis
still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. Signed-off-by: Colton Lewis Acked-by: Mark Rutland Reviewed-by: Oliver Upton --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c | 28

[PATCH v7 0/5] Correct perf sampling with Guest VMs

2024-11-07 Thread Colton Lewis
perf_ [kernel.kallsyms][k] __srcu_read_lock 1.03% dirty_log_perf_ [kernel.kallsyms][k] get_page_from_freelist 1.01% dirty_log_perf_ [kernel.kallsyms][k] __pte_offset_map_lock 0.82% dirty_log_perf_ [kernel.kallsyms][k] handle_mm_fault 0.74% dirty_log_perf_ [kernel.kallsyms]

[PATCH v7 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-11-07 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis Acked-by: Madhavan Srinivasan Reviewed-by: Oliver Upton --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c

[PATCH v6 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-11-05 Thread Colton Lewis
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 Acked-by: Thomas Richter Acked-by: Mark Rutland

[PATCH v6 5/5] perf: Correct perf sampling with guest VMs

2024-11-05 Thread Colton Lewis
still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. Signed-off-by: Colton Lewis Acked-by: Mark Rutland Reviewed-by: Oliver Upton --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c | 28

[PATCH v6 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-11-05 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis Acked-by: Madhavan Srinivasan Reviewed-by: Oliver Upton --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c

[PATCH v6 1/5] arm: perf: Drop unused functions

2024-11-05 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis Reviewed-by: Oliver Upton --- arch/arm/i

[PATCH v6 4/5] x86: perf: Refactor misc flag assignments

2024-11-05 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis Reviewed-by: Oliver Upton --- arch/x86/events/core.c| 31 +++ arch/x86/include/asm/perf_event.h | 2

[PATCH v6 0/5] Correct perf sampling with Guest VMs

2024-11-05 Thread Colton Lewis
perf_ [kernel.kallsyms][k] get_page_from_freelist 1.01% dirty_log_perf_ [kernel.kallsyms][k] __pte_offset_map_lock 0.82% dirty_log_perf_ [kernel.kallsyms][k] handle_mm_fault 0.74% dirty_log_perf_ [kernel.kallsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop

Re: [PATCH v5 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-23 Thread Colton Lewis
Thomas Richter writes: On 9/20/24 19:47, Colton Lewis wrote: 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

[PATCH v5 5/5] perf: Correct perf sampling with guest VMs

2024-09-20 Thread Colton Lewis
still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c | 28 arch/x86/events/core.c | 16

[PATCH v5 4/5] x86: perf: Refactor misc flag assignments

2024-09-20 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c| 31 +++ arch/x86/include/asm/perf_event.h | 2 ++ 2 files changed, 25

[PATCH v5 0/5] Correct perf sampling with Guest VMs

2024-09-20 Thread Colton Lewis
perf_ [kernel.kallsyms][k] get_page_from_freelist 1.01% dirty_log_perf_ [kernel.kallsyms][k] __pte_offset_map_lock 0.82% dirty_log_perf_ [kernel.kallsyms][k] handle_mm_fault 0.74% dirty_log_perf_ [kernel.kallsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop

[PATCH v5 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-09-20 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions

[PATCH v5 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-20 Thread Colton Lewis
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 --- arch/arm64/include/asm/perf_event.h

[PATCH v5 1/5] arm: perf: Drop unused functions

2024-09-20 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis --- arch/arm/include/asm/perf_ev

[PATCH v4 5/5] perf: Correct perf sampling with guest VMs

2024-09-19 Thread Colton Lewis
still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c | 28 arch/x86/events/core.c | 16

[PATCH v4 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-09-19 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions

[PATCH v4 4/5] x86: perf: Refactor misc flag assignments

2024-09-19 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c| 31 +++ arch/x86/include/asm/perf_event.h | 2 ++ 2 files changed, 25

[PATCH v4 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-19 Thread Colton Lewis
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 --- arch/arm64/include/asm/perf_event.h

[PATCH v4 0/5] Correct perf sampling with Guest VMs

2024-09-19 Thread Colton Lewis
ty_log_perf_ [kernel.kallsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop unused functions perf: Hoist perf_instruction_pointer() and perf_misc_flags() powerpc: perf: Use perf_arch_instruction_pointer() x86: perf: Refactor misc flag assignments perf: Correct perf sampling wit

[PATCH v4 1/5] arm: perf: Drop unused functions

2024-09-19 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis --- arch/arm/include/asm/perf_ev

Re: [PATCH v3 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-19 Thread Colton Lewis
Madhavan Srinivasan writes: On 9/13/24 2:21 AM, Colton Lewis wrote: 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

[PATCH v3 5/5] perf: Correct perf sampling with guest VMs

2024-09-12 Thread Colton Lewis
still misattribute a PMI that arrived in the host as a guest event depending on KVM arch and vendor behavior. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c | 28 arch/x86/events/core.c | 16

[PATCH v3 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-09-12 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions

[PATCH v3 0/5] Correct perf sampling with Guest VMs

2024-09-12 Thread Colton Lewis
allsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop unused functions perf: Hoist perf_instruction_pointer() and perf_misc_flags() powerpc: perf: Use perf_arch_instruction_pointer() x86: perf: Refactor misc flag assignments perf: Correct perf sampling with guest VMs arc

[PATCH v3 4/5] x86: perf: Refactor misc flag assignments

2024-09-12 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c| 31 +++ arch/x86/include/asm/perf_event.h | 2 ++ 2 files changed, 25

[PATCH v3 1/5] arm: perf: Drop unused functions

2024-09-12 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis --- arch/arm/include/asm/perf_ev

[PATCH v3 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-12 Thread Colton Lewis
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 --- arch/arm64/include/asm/perf_event.h

Re: [PATCH v2 5/5] perf: Correct perf sampling with guest VMs

2024-09-12 Thread Colton Lewis
Sean Christopherson writes: On Wed, Sep 11, 2024, Colton Lewis wrote: Previously any PMU overflow interrupt that fired while a VCPU was loaded was recorded as a guest event whether it truly was or not. This resulted in nonsense perf recordings that did not honor perf_event_attr.exclude_guest

[PATCH v2 5/5] perf: Correct perf sampling with guest VMs

2024-09-11 Thread Colton Lewis
sampling logic to only record guest samples for events with exclude_guest clear. This way any host-only events with exclude_guest set will never see unexpected guest samples. The behaviour of events with exclude_guest clear is unchanged. Signed-off-by: Colton Lewis --- arch/arm64/include/asm

[PATCH v2 4/5] x86: perf: Refactor misc flag assignments

2024-09-11 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c| 31 +++ arch/x86/include/asm/perf_event.h | 2 ++ 2 files changed, 25

[PATCH v2 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-09-11 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions

[PATCH v2 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-11 Thread Colton Lewis
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 --- arch/arm64/include/asm/perf_event.h

[PATCH v2 0/5] Correct perf sampling with Guest VMs

2024-09-11 Thread Colton Lewis
perf_ [kernel.kallsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop unused functions perf: Hoist perf_instruction_pointer() and perf_misc_flags() powerpc: perf: Use perf_arch_instruction_pointer() x86: perf: Refactor misc flag assignments perf: Correct perf sampling with gu

[PATCH v2 1/5] arm: perf: Drop unused functions

2024-09-11 Thread Colton Lewis
For arm's implementation, perf_instruction_pointer() and perf_misc_flags() are equivalent to the generic versions in include/linux/perf_event.h so arch/arm doesn't need to provide its own versions. Drop them here. Signed-off-by: Colton Lewis --- arch/arm/include/asm/perf_ev

Re: [PATCH 4/5] x86: perf: Refactor misc flag assignments

2024-09-11 Thread Colton Lewis
Ingo Molnar writes: * Colton Lewis wrote: Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c| 31 +++ arch/x86

Re: [PATCH 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-11 Thread Colton Lewis
Ingo Molnar writes: * Colton Lewis wrote: --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6915,6 +6915,16 @@ void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); #endif +unsigned long

Re: [PATCH 5/5] perf: Correct perf sampling with guest VMs

2024-09-11 Thread Colton Lewis
Mark Rutland writes: On Wed, Sep 04, 2024 at 08:41:33PM +, Colton Lewis wrote: Previously any PMU overflow interrupt that fired while a VCPU was loaded was recorded as a guest event whether it truly was or not. This resulted in nonsense perf recordings that did not honor

Re: [PATCH 1/5] arm: perf: Drop unused functions

2024-09-11 Thread Colton Lewis
Mark Rutland writes: On Wed, Sep 04, 2024 at 08:41:29PM +, Colton Lewis wrote: perf_instruction_pointer() and perf_misc_flags() aren't used anywhere in this particular perf implementation. Drop them. I think it'd be better to say that arch/arm's implementation of these i

[PATCH 5/5] perf: Correct perf sampling with guest VMs

2024-09-04 Thread Colton Lewis
that plumbing to record perf events correctly even when VCPUs are loaded. Signed-off-by: Colton Lewis --- arch/arm64/include/asm/perf_event.h | 4 arch/arm64/kernel/perf_callchain.c | 28 arch/x86/events/core.c | 16 include/linux

[PATCH 3/5] powerpc: perf: Use perf_arch_instruction_pointer()

2024-09-04 Thread Colton Lewis
Make sure powerpc uses the arch-specific function now that those have been reorganized. Signed-off-by: Colton Lewis --- arch/powerpc/perf/callchain.c| 2 +- arch/powerpc/perf/callchain_32.c | 2 +- arch/powerpc/perf/callchain_64.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions

[PATCH 4/5] x86: perf: Refactor misc flag assignments

2024-09-04 Thread Colton Lewis
Break the assignment logic for misc flags into their own respective functions to reduce the complexity of the nested logic. Signed-off-by: Colton Lewis --- arch/x86/events/core.c| 31 +++ arch/x86/include/asm/perf_event.h | 2 ++ 2 files changed, 25

[PATCH 2/5] perf: Hoist perf_instruction_pointer() and perf_misc_flags()

2024-09-04 Thread Colton Lewis
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 --- arch/arm64/include/asm/perf_event.h

[PATCH 0/5] Correct perf sampling with guest VMs

2024-09-04 Thread Colton Lewis
ault 0.74% dirty_log_perf_ [kernel.kallsyms] [k] mas_state_walk Colton Lewis (5): arm: perf: Drop unused functions perf: Hoist perf_instruction_pointer() and perf_misc_flags() powerpc: perf: Use perf_arch_instruction_pointer() x86: perf: Refactor misc flag assignments perf: Correct perf samp

[PATCH 1/5] arm: perf: Drop unused functions

2024-09-04 Thread Colton Lewis
perf_instruction_pointer() and perf_misc_flags() aren't used anywhere in this particular perf implementation. Drop them. Signed-off-by: Colton Lewis --- arch/arm/include/asm/perf_event.h | 7 --- arch/arm/kernel/perf_callchain.c | 17 - 2 files changed, 24 dele