On Fri, Nov 20, 2009 at 12:06 AM, Corey Ashford
<cjash...@linux.vnet.ibm.com> wrote:
>
> Hi Stephane,
>
> I am testing an implementation of libpfm4, and ran into some curious
> behavior with the plm field in the perf_event_attr structure.  The code
> makes it appear to be intentional, but I thought I'd run this by you to see
> if it's what you had intended.
>
> If I specify an event, such as PM_RUN_CYC:i, and I don't specify any u,k, or
> h modifiers, none of the exclude_* bits in the perf_events attribute record
> get set.  This seems ok; users may want to have events counted in all
> privilege levels by default.
>
> However, if I specify "PM_RUN_CYC:i:k=0", saying I don't want kernel
> samples, I actually get all samples, because of this code:
>
>        if (perf_attrs.plm) {
>                hw->exclude_user = !(perf_attrs.plm & PFM_PLM3);
>                hw->exclude_kernel = !(perf_attrs.plm & PFM_PLM0);
>                hw->exclude_hv = !(perf_attrs.plm & PFM_PLMH);
>        }
>
> perf_attrs.plm is set to zero, if I set k=0.  If I were using this
> interface, I'd probably want hw->exclude_kernel to be set to 1.
>
You are right, I think there is a problem there.

I think it is okay to have by default: measure everything

The problem is that there is something missing in perf_attrs.
One way to make it work could be to have
perf_attrs.plm = PLM0|PLM3 to match the default settings and
then have the model specific code, toggle this if the plm is not set.
For instance,

      if (!reg.sel_os)
            perf_attrs.plm &= ~PLM0

So you would do:
     perf.attrs = PLM0|PLM3;
     excl_u = excl_k = 0;

    get_encoding(, ..., &perf_attrs);

    if (!(perf_attrs.plm & PLM0))
            excl_k = 1

    if (!(perf_attrs.plm & PLM3))
            excl_u = 1

> Do you agree?  Should the behavior be changed?
>
Yes.

> Regards,
>
> - Corey
>
> Corey Ashford
> Software Engineer
> IBM Linux Technology Center, Linux Toolchain
> Beaverton, OR
> 503-578-3507
> cjash...@us.ibm.com
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to