Re: [RFC PATCH] perf/core: don't sample kernel regs upon skid
From: Mark Rutland
Date: Thu Aug 02 2018 - 12:03:07 EST
On Wed, Jul 11, 2018 at 06:59:28AM +0100, Mark Rutland wrote:
> On Mon, Jul 09, 2018 at 06:42:29PM -0400, Boris Ostrovsky wrote:
> > On 07/02/2018 12:02 PM, Mark Rutland wrote:
> > > On Mon, Jul 02, 2018 at 05:46:55PM +0200, Peter Zijlstra wrote:
> > >> On Mon, Jul 02, 2018 at 04:12:50PM +0100, Mark Rutland wrote:
> > >>> +static struct pt_regs *perf_get_sample_regs(struct perf_event *event,
> > >>> + struct pt_regs *regs)
> > >>> +{
> > >>> + /*
> > >>> + * Due to interrupt latency (AKA "skid"), we may enter the kernel
> > >>> + * before taking an overflow, even if the PMU is only counting user
> > >>> + * events.
> > >>> + *
> > >>> + * If we're not counting kernel events, always use the user regs when
> > >>> + * sampling.
> > >>> + *
> > >>> + * TODO: what do we do about sampling a guest's registers? The IP is
> > >>> + * special-cased, but for the rest of the regs they'll get the
> > >>> + * user/kernel regs depending on whether exclude_kernel is set, which
> > >>> + * is nonsensical.
> > >>> + *
> > >>> + * We can't get at the full set of regs in all cases (e.g. Xen's PV PMU
> > >>> + * can't provide the GPRs), so should we just zero the GPRs when in a
> > >>> + * guest? Or skip outputting the regs in perf_output_sample?
> > >> Seems daft Xen cannot provide registers; why is that? Boris?
> > > The xen_pmu_regs structure simply doesn't have them, so I assume there's
> > > no API to get them.
> > >
> > > Given we don't currently sample the guest regs, I'd be tempted to just
> > > zero them for now, or skip the sample at output time (if that doesn't
> > > break some other case).
> I think this is going to become a series rather than a single patch, but I can
> have a go. I need to get my head around how the various cases interact with
> each other.
As a heads-up, due to sabbatical leave I'm probably not going to have
the chance to dig into this until September.
If someone else is able to take a look at this, that would be great.
Otherwise, I'm happy to take a look once I get back.
Thanks,
Mark.