2012-02-22 01:59:38

by Yuanfang Chen

[permalink] [raw]
Subject: perf record: can I specify multiple events and use different sample-after value

Hi all,

I'm trying use perf tool from the linux kernel package to measure
several raw PMU events. In the manpage of perf-record there is an "-l"
option (Scale counter values), which is useful for my case because I
want to know the total counter value, not just sample count. However
it seems the -l is not recognized, is this expected? How can I get a
total count?

Another question is that how can I specify multiple events and use
different sample-after value for each of them? like perf record -c
10000,2000000,2000000 -e r2d4,r03c,r0c0

thank you


2012-02-22 06:01:30

by Namhyung Kim

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

2012-02-22 10:59 AM, Yuanfang Chen wrote:
> Hi all,
>

Hi,


> I'm trying use perf tool from the linux kernel package to measure
> several raw PMU events. In the manpage of perf-record there is an "-l"
> option (Scale counter values), which is useful for my case because I
> want to know the total counter value, not just sample count. However
> it seems the -l is not recognized, is this expected? How can I get a
> total count?
>

"perf report --show-total-period" will be your friend.

BTW, it seems you were using old version of perf (and kernel too, maybe).
I have no idea if your perf wouldn't support the option. :)

The "-l" option was meaningful only if you specified events more than the
actual number of counters in the PMU.


> Another question is that how can I specify multiple events and use
> different sample-after value for each of them? like perf record -c
> 10000,2000000,2000000 -e r2d4,r03c,r0c0
>

It's not possible now. You should run a number of instances of perf for
that purpose AFAIK.


Thanks,
Namhyung

2012-02-22 11:40:37

by Namhyung Kim

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

Namhyung Kim <[email protected]> wrote:
>
> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>> Hi all,
>>
>
> Hi,
>
>
>> I'm trying use perf tool from the linux kernel package to measure
>> several raw PMU events. In the manpage of perf-record there is an "-l"
>> option (Scale counter values), which is useful for my case because I
>> want to know the total counter value, not just sample count. However
>> it seems the -l is not recognized, is this expected? How can I get a
>> total count?
>>
>
> "perf report --show-total-period" will be your friend.
>

Or else, why not simply run "perf stat"?

Thanks,
Namhyung

2012-02-22 18:57:33

by Yuanfang Chen

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On Wed, Feb 22, 2012 at 1:01 AM, Namhyung Kim <[email protected]> wrote:
> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>>
>> Hi all,
>>
>
> Hi,
>
>
>
>> I'm trying use perf tool from the linux kernel package to measure
>> several raw PMU events. In the manpage of perf-record there is an "-l"
>> option (Scale counter values), which is useful for my case because I
>> want to know the total counter value, not just sample count. However
>> it seems the -l is not recognized, is this expected? How can I get a
>> total count?
>>
>
> "perf report --show-total-period" will be your friend.
>
> BTW, it seems you were using old version of perf (and kernel too, maybe).
> I have no idea if your perf wouldn't support the option. :)

You are right. my perf version is 3.0.0, just updated to 3.3.0-rc4.
--show-total-period works now.

>
> The "-l" option was meaningful only if you specified events more than the
> actual number of counters in the PMU.

So -l is for multiplexing?

>
>
>
>> Another question is that how can I specify multiple events and use
>> different sample-after value for each of them? like perf record -c
>> 10000,2000000,2000000 -e r2d4,r03c,r0c0
>>
>
> It's not possible now. You should run a number of instances of perf for
> that purpose AFAIK.
>
>
> Thanks,
> Namhyung

2012-02-22 19:03:31

by Yuanfang Chen

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On Wed, Feb 22, 2012 at 6:40 AM, Namhyung Kim <[email protected]> wrote:
> Namhyung Kim <[email protected]> wrote:
>>
>> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>>> Hi all,
>>>
>>
>> Hi,
>>
>>
>>> I'm trying use perf tool from the linux kernel package to measure
>>> several raw PMU events. In the manpage of perf-record there is an "-l"
>>> option (Scale counter values), which is useful for my case because I
>>> want to know the total counter value, not just sample count. However
>>> it seems the -l is not recognized, is this expected? How can I get a
>>> total count?
>>>
>>
>> "perf report --show-total-period" will be your friend.
>>
>
> Or else, why not simply run "perf stat"?

My purpose is to get some PMU counter value during each time interval,
only perf record can do this. When using perf record -F, I have to add
up all period value for some event in a some interval to get that
value. When perf record -c, things get a easier, just (sample count x
sample after value) will do, only hassle is to get sample count in
some time interval. However, perf record don't have an option to do
this.

>
> Thanks,
> Namhyung

2012-02-23 07:25:00

by Namhyung Kim

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

2012-02-23 4:03 AM, Yuanfang Chen wrote:
> On Wed, Feb 22, 2012 at 6:40 AM, Namhyung Kim <[email protected]> wrote:
>> Namhyung Kim <[email protected]> wrote:
>>> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>>>> I'm trying use perf tool from the linux kernel package to measure
>>>> several raw PMU events. In the manpage of perf-record there is an "-l"
>>>> option (Scale counter values), which is useful for my case because I
>>>> want to know the total counter value, not just sample count. However
>>>> it seems the -l is not recognized, is this expected? How can I get a
>>>> total count?
>>>
>>> "perf report --show-total-period" will be your friend.
>>
>> Or else, why not simply run "perf stat"?
>
> My purpose is to get some PMU counter value during each time interval,
> only perf record can do this. When using perf record -F, I have to add
> up all period value for some event in a some interval to get that
> value. When perf record -c, things get a easier, just (sample count x
> sample after value) will do, only hassle is to get sample count in
> some time interval. However, perf record don't have an option to do
> this.
>

I still don't get it. Why "perf stat -e <events> -p <pid> -- sleep <interval>"
doesn't work for you? It will show you the value, won't it?

Thanks,
Namhyung

2012-02-23 07:40:46

by Namhyung Kim

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

2012-02-23 3:57 AM, Yuanfang Chen wrote:
> On Wed, Feb 22, 2012 at 1:01 AM, Namhyung Kim <[email protected]> wrote:
>> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>> The "-l" option was meaningful only if you specified events more than the
>> actual number of counters in the PMU.
>
> So -l is for multiplexing?
>

The "-l" option is no longer supported in perf record/report and multiplexing
is always enabled by default, if needed. That would be the same even for old
versions AFAIK, and "-l" option just controlled whether it'd scale or not the
counter value which is taken from already multiplexed events.


Thanks,
Namhyung

2012-02-23 18:52:12

by Yuanfang Chen

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On Thu, Feb 23, 2012 at 1:51 PM, Yuanfang Chen <[email protected]> wrote:
> On Thu, Feb 23, 2012 at 2:24 AM, Namhyung Kim <[email protected]> wrote:
>> 2012-02-23 4:03 AM, Yuanfang Chen wrote:
>>>
>>> On Wed, Feb 22, 2012 at 6:40 AM, Namhyung Kim <[email protected]> wrote:
>>>>
>>>> Namhyung Kim <[email protected]> wrote:
>>>>>
>>>>> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>>>>>>
>>>>>> I'm trying use perf tool from the linux kernel package to measure
>>>>>> several raw PMU events. In the manpage of perf-record there is an "-l"
>>>>>> option (Scale counter values), which is useful for my case because I
>>>>>> want to know the total counter value, not just sample count. However
>>>>>> it seems the -l is not recognized, is this expected? How can I get a
>>>>>> total count?
>>>>>
>>>>>
>>>>> "perf report --show-total-period" will be your friend.
>>>>
>>>>
>>>> Or else, why not simply run "perf stat"?
>>>
>>>
>>> My purpose is to get some PMU counter value during each time interval,
>>> only perf record can do this. When using perf record -F, I have to add
>>> up all period value for some event in a some interval to get that
>>> value. When perf record -c, things get a easier, just (sample count x
>>> sample after value) will do, only hassle is to get sample count in
>>> some time interval. However, perf record don't have an option to do
>>> this.
>>>
>>
>> I still don't get it. Why "perf stat -e <events> -p <pid> -- sleep
>> <interval>"
>> doesn't work for you? It will show you the value, won't it?
>
> say my application(not an existing process, so -p <pid> does not
> work.) run for 10 seconds. I want the r03c, r2d4 value during each
> second.  So there will be two values for each event in one second.

oops, forgot to forward. :-)

>
>>
>> Thanks,
>> Namhyung

2012-02-23 18:57:14

by Yuanfang Chen

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On Thu, Feb 23, 2012 at 2:40 AM, Namhyung Kim <[email protected]> wrote:
> 2012-02-23 3:57 AM, Yuanfang Chen wrote:
>>
>> On Wed, Feb 22, 2012 at 1:01 AM, Namhyung Kim <[email protected]>
>> wrote:
>>>
>>> 2012-02-22 10:59 AM, Yuanfang Chen wrote:
>>> The "-l" option was meaningful only if you specified events more than the
>>> actual number of counters in the PMU.
>>
>>
>> So -l is for multiplexing?
>>
>
> The "-l" option is no longer supported in perf record/report and
> multiplexing is always enabled by default, if needed. That would be the same
> even for old versions AFAIK, and "-l" option just controlled whether it'd
> scale or not the counter value which is taken from already multiplexed
> events.
>

My question may sounds silly, but why to scale the counter value? Why
it is deprecated now?

Thank you,
yuanfang

>
> Thanks,
> Namhyung

2012-02-23 19:08:49

by David Ahern

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On 2/23/12 11:52 AM, Yuanfang Chen wrote:
>>
>> say my application(not an existing process, so -p<pid> does not
>> work.) run for 10 seconds. I want the r03c, r2d4 value during each
>> second. So there will be two values for each event in one second.
>
> oops, forgot to forward. :-)

you are looking for something like this?
http://www.spinics.net/lists/linux-perf-users/msg00211.html

David

2012-02-24 22:41:07

by Yuanfang Chen

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On Thu, Feb 23, 2012 at 2:08 PM, David Ahern <[email protected]> wrote:
> On 2/23/12 11:52 AM, Yuanfang Chen wrote:
>>>
>>>
>>> say my application(not an existing process, so -p<pid>  does not
>>> work.) run for 10 seconds. I want the r03c, r2d4 value during each
>>> second.  So there will be two values for each event in one second.
>>
>>
>> oops, forgot to forward. :-)
>
>
> you are looking for something like this?
> http://www.spinics.net/lists/linux-perf-users/msg00211.html

Exactly !!

I think I'll settle with perf record for now. Still, unlike trace
event, sample count is not meaningful for PMU event. Output of "perf
script" does not include period value. One line of code will do the
work.

lude 17342 750118.202915: raw 0x3c: 86754 ffffffff8115f6b9
__mem_cgroup_commit_char
lude 17342 750118.203025: raw 0x3c: 1027634 ffffffff811344b9
__mem_cgroup_commit_char

86754, 1027634 is the period value. But I'm not sure which is the PMU
value, is it just period value, or period x sample after. If so, what
is the sample after value?

thank you,
yuanfang

>
> David
>

2012-02-27 03:23:25

by David Ahern

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On 2/24/12 3:41 PM, Yuanfang Chen wrote:
> I think I'll settle with perf record for now. Still, unlike trace
> event, sample count is not meaningful for PMU event. Output of "perf
> script" does not include period value. One line of code will do the
> work.
>
> lude 17342 750118.202915: raw 0x3c: 86754 ffffffff8115f6b9
> __mem_cgroup_commit_char
> lude 17342 750118.203025: raw 0x3c: 1027634 ffffffff811344b9
> __mem_cgroup_commit_char
>
> 86754, 1027634 is the period value. But I'm not sure which is the PMU
> value, is it just period value, or period x sample after. If so, what
> is the sample after value?

You lost me. You modified perf-script to print the period?

Are you asking for the PMU counter value for 0x3c?

What perf commands are you running?

David

2012-02-27 13:58:44

by Yuanfang Chen

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On Mon, Feb 27, 2012 at 8:56 AM, Yuanfang Chen <[email protected]> wrote:
>
> On Feb 26, 2012 10:23 PM, "David Ahern" <[email protected]> wrote:
>>
>> On 2/24/12 3:41 PM, Yuanfang Chen wrote:
>>>
>>> I think I'll settle with perf record for now. Still, unlike trace
>>> event, sample count is not meaningful for PMU event. Output of "perf
>>> script" does not include period value. One line of code will do the
>>> work.
>>>
>>> lude 17342 750118.202915: raw 0x3c: 86754      ffffffff8115f6b9
>>> __mem_cgroup_commit_char
>>> lude 17342 750118.203025: raw 0x3c: 1027634   ffffffff811344b9
>>> __mem_cgroup_commit_char
>>>
>>> 86754, 1027634 is the period value. But I'm not sure which is the PMU
>>> value, is it just period value, or period x sample after. If so, what
>>> is the sample after value?
>>
>>
>> You lost me. You modified perf-script to print the period?
>>
>> Are you asking for the PMU counter value for 0x3c?

yes

>>
>> What perf commands are you running?

perf script
(with no options)

>
>>
>> David

2012-02-27 14:42:13

by David Ahern

[permalink] [raw]
Subject: Re: perf record: can I specify multiple events and use different sample-after value

On 2/27/12 6:58 AM, Yuanfang Chen wrote:
> On Mon, Feb 27, 2012 at 8:56 AM, Yuanfang Chen<[email protected]> wrote:
>>
>> On Feb 26, 2012 10:23 PM, "David Ahern"<[email protected]> wrote:
>>>
>>> On 2/24/12 3:41 PM, Yuanfang Chen wrote:
>>>>
>>>> I think I'll settle with perf record for now. Still, unlike trace
>>>> event, sample count is not meaningful for PMU event. Output of "perf
>>>> script" does not include period value. One line of code will do the
>>>> work.
>>>>
>>>> lude 17342 750118.202915: raw 0x3c: 86754 ffffffff8115f6b9
>>>> __mem_cgroup_commit_char
>>>> lude 17342 750118.203025: raw 0x3c: 1027634 ffffffff811344b9
>>>> __mem_cgroup_commit_char
>>>>
>>>> 86754, 1027634 is the period value. But I'm not sure which is the PMU
>>>> value, is it just period value, or period x sample after. If so, what
>>>> is the sample after value?
>>>
>>>
>>> You lost me. You modified perf-script to print the period?
>>>
>>> Are you asking for the PMU counter value for 0x3c?
>
> yes

perf-record does not get counter values when samples are genereated.

>
>>>
>>> What perf commands are you running?
>
> perf script
> (with no options)

record command?

I don't see what the 86754 and 1902764 values are in your example output
above.


David