opensubscriber
   Find in this group all groups
 
Unknown more information…

f : freebsd-hackers@freebsd.org 12 March 2012 • 8:39PM -0400

Re: pmc(3): when are the counters updated?
by Vitaly Magerya

REPLY TO AUTHOR
 
REPLY TO GROUP




Fabien Thomas wrote:
>> So, what's going on here? Is this the intended behavior, or can it
>> be changed? And how do I get accurate readings?
>
> If i remember well:
> The current code will get real HW PMC if the PMC is running and attached to owner.
> The first case is not true in your code so you get the saved value which is updated at
> process switch out time.
>
> I think you can do:
> pmc_read
> pmc_stop.

Changing the code to this:

    [...]
    pmc_read(pmcid, &value);
    pmc_stop(pmcid);
    printf("reading #1: %lu\n", (unsigned long)value);
    pmc_read(pmcid, &value);
    printf("reading #2: %lu\n", (unsigned long)value);
    sleep(1);
    pmc_read(pmcid, &value);
    printf("reading #3: %lu\n", (unsigned long)value);
    [...]

Gives me this output:

    reading #1: 15039441
    reading #2: 0
    reading #3: 15084037

So, it seems that you are correct; pmc_read reports current values if
the PMC is not stopped, after which it's updated on context switches.
_______________________________________________
freebsd-hackers@free... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@free..."

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.