[PATCH v6 5/5] perf: Correct perf sampling with guest VMs
Oliver Upton
oliver.upton at linux.dev
Wed Nov 6 11:53:07 PST 2024
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;
}
--
Thanks,
Oliver
More information about the linux-arm-kernel
mailing list