linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about resetting a sampling counter in kernel
@ 2012-02-12 18:37 heechul Yun
  2012-02-15 13:00 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: heechul Yun @ 2012-02-12 18:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Vince Weaver, Peter Zijlstra

Hello,

I have a question about controlling performance counter in kernel.

I created a kernel counter which generates an interrupt at every
10000 cache-misses as shown below.

struct perf_event_attr sched_perf_hw_attr = {
     .type = PERF_TYPE_HARDWARE,
     .config = PERF_COUNT_HW_CACHE_MISSES,
     .sample_period = 10000,
     .size = sizeof(struct perf_event_attr),
     .pinned = 1,
     .disbled = 1,
}

event = perf_event_create_kernel_counter(&sched_perf_hw_attr, cpu,
       NULL, event_overflow_callback, NULL);

What I would like to do is to "reset" the counter before the
overflow interrupt occurs (e.g, reset at 5000th event),
and then to restart the sampling from 0.

I found perf_event_enable() and perf_event_disable() only
start/stop the counting but couln't figure out how to reset the
sampling as I described above.

I would be really thankful if you explain how I can efficiently reset the
sampling counter.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question about resetting a sampling counter in kernel
  2012-02-12 18:37 Question about resetting a sampling counter in kernel heechul Yun
@ 2012-02-15 13:00 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2012-02-15 13:00 UTC (permalink / raw)
  To: heechul Yun; +Cc: linux-kernel, Vince Weaver

On Sun, 2012-02-12 at 12:37 -0600, heechul Yun wrote:
> Hello,
> 
> I have a question about controlling performance counter in kernel.
> 
> I created a kernel counter which generates an interrupt at every
> 10000 cache-misses as shown below.
> 
> struct perf_event_attr sched_perf_hw_attr = {
>      .type = PERF_TYPE_HARDWARE,
>      .config = PERF_COUNT_HW_CACHE_MISSES,
>      .sample_period = 10000,
>      .size = sizeof(struct perf_event_attr),
>      .pinned = 1,
>      .disbled = 1,
> }
> 
> event = perf_event_create_kernel_counter(&sched_perf_hw_attr, cpu,
>        NULL, event_overflow_callback, NULL);
> 
> What I would like to do is to "reset" the counter before the
> overflow interrupt occurs (e.g, reset at 5000th event),
> and then to restart the sampling from 0.
> 
> I found perf_event_enable() and perf_event_disable() only
> start/stop the counting but couln't figure out how to reset the
> sampling as I described above.
> 
> I would be really thankful if you explain how I can efficiently reset the
> sampling counter.

Expose and use perf_event_reset().

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-15 13:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-12 18:37 Question about resetting a sampling counter in kernel heechul Yun
2012-02-15 13:00 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).