* Sampling hardware counter values with timers @ 2016-05-13 4:00 Keno Fischer 2016-05-13 13:40 ` Andi Kleen 0 siblings, 1 reply; 5+ messages in thread From: Keno Fischer @ 2016-05-13 4:00 UTC (permalink / raw) To: linux-perf-users Hello everyone, I was wondering if it is possible (either using the `perf` user space tool or using the perf_events API) to periodically sample the value of a hardware counter (in my particular case I'd like to sample the retired-branch-counter). I know it is possible to do the opposite (i.e. sample a timestamp every specified number of branches), but I wasn't able to see an easy way to sample the hardware counter at a specified frequency. Is this possible? Thanks, Keno ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Sampling hardware counter values with timers 2016-05-13 4:00 Sampling hardware counter values with timers Keno Fischer @ 2016-05-13 13:40 ` Andi Kleen 2016-05-13 14:44 ` Keno Fischer 0 siblings, 1 reply; 5+ messages in thread From: Andi Kleen @ 2016-05-13 13:40 UTC (permalink / raw) To: Keno Fischer; +Cc: linux-perf-users Keno Fischer <kfischer@college.harvard.edu> writes: > Hello everyone, > > I was wondering if it is possible (either using the `perf` user space > tool or using the perf_events API) to periodically sample the value of > a hardware counter (in my particular case I'd like to sample the > retired-branch-counter). I know it is possible to do the opposite > (i.e. sample a timestamp every specified number of branches), but I > wasn't able to see an easy way to sample the hardware counter at a > specified frequency. Is this possible? perf record works this way by default. The counter period is dynamically adjusted for a given frequency. The default frequency is 1000. You can set it with -F. Another alternative is to use perf stat -I ... if you only need the counts. -Andi ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Sampling hardware counter values with timers 2016-05-13 13:40 ` Andi Kleen @ 2016-05-13 14:44 ` Keno Fischer 2016-05-13 17:42 ` Vince Weaver 0 siblings, 1 reply; 5+ messages in thread From: Keno Fischer @ 2016-05-13 14:44 UTC (permalink / raw) To: Andi Kleen; +Cc: linux-perf-users Hi Andi, Thanks. I know that perf sample works this way, but I didn't think it was possible to have it sample a specified counter. Is it? `perf stat -I` looks exactly like what I need, but it looks like the maximum frequency is 10Hz. I was hoping for a higher frequency (& ideally something that doesn't require switching back into user space and calling `read`). Thanks, Keno On Fri, May 13, 2016 at 9:40 AM, Andi Kleen <andi@firstfloor.org> wrote: > Keno Fischer <kfischer@college.harvard.edu> writes: > >> Hello everyone, >> >> I was wondering if it is possible (either using the `perf` user space >> tool or using the perf_events API) to periodically sample the value of >> a hardware counter (in my particular case I'd like to sample the >> retired-branch-counter). I know it is possible to do the opposite >> (i.e. sample a timestamp every specified number of branches), but I >> wasn't able to see an easy way to sample the hardware counter at a >> specified frequency. Is this possible? > > perf record works this way by default. The counter period is dynamically > adjusted for a given frequency. The default frequency is 1000. > You can set it with -F. > > Another alternative is to use perf stat -I ... if you only need the counts. > > -Andi ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Sampling hardware counter values with timers 2016-05-13 14:44 ` Keno Fischer @ 2016-05-13 17:42 ` Vince Weaver 2016-05-13 18:26 ` Keno Fischer 0 siblings, 1 reply; 5+ messages in thread From: Vince Weaver @ 2016-05-13 17:42 UTC (permalink / raw) To: Keno Fischer; +Cc: Andi Kleen, linux-perf-users On Fri, 13 May 2016, Keno Fischer wrote: > Thanks. I know that perf sample works this way, but I didn't think it > was possible to have it sample a specified counter. Is it? `perf stat > -I` looks exactly like what I need, but it looks like the maximum > frequency is 10Hz. I was hoping for a higher frequency (& ideally > something that > doesn't require switching back into user space and calling `read`). you can easily hack perf -I to sample faster than 10Hz, but if you sample much more often than that you're going to start ending up with a lot of perf_event measurement overhead in your data. Vince ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Sampling hardware counter values with timers 2016-05-13 17:42 ` Vince Weaver @ 2016-05-13 18:26 ` Keno Fischer 0 siblings, 0 replies; 5+ messages in thread From: Keno Fischer @ 2016-05-13 18:26 UTC (permalink / raw) To: Vince Weaver; +Cc: Andi Kleen, linux-perf-users Thanks Vince, I figured I could do something like that, but I was indeed concerned about the performance overhead, esp. since it seems like the way I'd have to structure it is to have a user space timer interrupt which then `read`s the perf counter. Since perf can sample e.g. the ip at sufficiently high frequencies, I was hoping there was some mechanism that would allow me to do the same for the retired branch counter. For some background to this question, I'm hoping to use this in combination with mozilla's record/replay framework (BTW, your work on deterministic perf counters has come in super handy several times here, Vince). rr identifies program points by combinations of (retired-branch-counter, ip), so I was hoping to be able to correlate those program points with actual time elapsed. Keno On Fri, May 13, 2016 at 1:42 PM, Vince Weaver <vincent.weaver@maine.edu> wrote: > On Fri, 13 May 2016, Keno Fischer wrote: > >> Thanks. I know that perf sample works this way, but I didn't think it >> was possible to have it sample a specified counter. Is it? `perf stat >> -I` looks exactly like what I need, but it looks like the maximum >> frequency is 10Hz. I was hoping for a higher frequency (& ideally >> something that >> doesn't require switching back into user space and calling `read`). > > you can easily hack perf -I to sample faster than 10Hz, but if you sample > much more often than that you're going to start ending up with a lot of > perf_event measurement overhead in your data. > > Vince ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-13 18:26 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-13 4:00 Sampling hardware counter values with timers Keno Fischer 2016-05-13 13:40 ` Andi Kleen 2016-05-13 14:44 ` Keno Fischer 2016-05-13 17:42 ` Vince Weaver 2016-05-13 18:26 ` Keno Fischer
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.