Re: [patch] perf_event_open.2: 3.19 PERF_SAMPLE_REGS_INTR support

Stephane Eranian
2015-03-02T20:26:13Z

vince,

On Mon, Mar 2, 2015 at 2:31 PM, Vince Weaver <vincent.weaver@maine.edu> wrote:
>
> On Sun, 1 Mar 2015, Stephane Eranian wrote:
>
> > You need to describe your test better. Are you saying that the register values
> > you were seeing with REGS_USER, REGS_INTR, precise_ip > 0 are all
> > the same? That is certainly not impossible. If your PMU interrupts are all
> > at the user level, then REGS_INTR = REGS_USER. With precise_ip > 0,
> > you will get the machine state on retirement of the sampled instruction.
> > But if you have no sampling skid without precise_ip, then both states
> > the REGS_INTR and REGS_INTR+precise_ip>0 could be identical.
>
> If you enable both PERF_SAMPLE_REGS_USER and PERF_SAMPLE_REGS_INTR
> then you will get in the PERF_RECORD_SAMPLE results for both user
> and intr. However they will be identical, always, because
> the kernel code just checks if PERF_SAMPLE_REGS_INTR was given and
> then returns the PEBS state for both.
>
If the PMU interrupt occurred at the user level, then this makes sense.
both perf_sample_regs_user() and perf_sample_regs_intr() use the
same pt_regs() which has the user state.

I think your comment is more along the lines that REGS_USER should not receive
PEBS machine state. Problem is that there is only one set of pt_regs passed to
__intel_pmu_pebs_event(). And if REGS_INTR is set, then the pt_regs
registers are
indeed overwritten with PEBS captured state. To avoid the issue, we
would have to
carry around two sets of pt_regs.

> My test was expecting that if you specified PERF_SAMPLE_REGS_USER and
> PERF_SAMPLE_REGS_INTR then for the PERF_SAMPLE_REGS_USER values you'd
> get the same results as when PERF_SAMPLE_REGS_INTR were not specified, but
> that's not the case.
>
This could certainly be fixed with two sets of pt_regs to make the results more
consisten when REGS_USER and REGS_INTR + precise are used.

>
> This is an obscure corner case, but I found the results unexpected.
>
> Vince