On 2024-11-06 2:53 p.m., Oliver Upton wrote: > On Wed, Nov 06, 2024 at 11:07:53AM -0500, Liang, Kan wrote: >>> +#ifndef perf_arch_guest_misc_flags >>> +static inline unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) >>> +{ >>> + unsigned long guest_state = perf_guest_state(); >>> + >>> + if (guest_state & PERF_GUEST_USER) >>> + return PERF_RECORD_MISC_GUEST_USER; >>> + >>> + if (guest_state & PERF_GUEST_ACTIVE) >>> + return PERF_RECORD_MISC_GUEST_KERNEL; >> >> Is there by any chance to add a PERF_GUEST_KERNEL flag in KVM? > > Why do we need another flag? As it stands today, the vCPU is either in > user mode or kernel mode. > >> The PERF_GUEST_ACTIVE flag check looks really confusing. > > Perhaps instead: > > static inline unsigned long perf_arch_guest_misc_flags(struct pt_regs *regs) > { > unsigned long guest_state = perf_guest_state(); > > if (!(guest_state & PERF_GUEST_ACTIVE)) > return 0; > > return (guest_state & PERF_GUEST_USER) ? PERF_RECORD_MISC_GUEST_USER : > PERF_RECORD_MISC_GUEST_KERNEL; > } Yes, this one is much clear. Can a similar change be done for the x86 perf_arch_guest_misc_flags() in the previous patch? Thanks, Kan