The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: heechul Yun <heechul@illinois.edu>
Cc: linux-kernel@vger.kernel.org, Vince Weaver <vweaver1@eecs.utk.edu>
Subject: Re: Question about resetting a sampling counter in kernel
Date: Wed, 15 Feb 2012 14:00:54 +0100	[thread overview]
Message-ID: <1329310854.2293.79.camel@twins> (raw)
In-Reply-To: <CAN_5kQB+BjPc5Sj=a-4B80-6t5D3C4WkvP6bz_BRcMd6LKAzqw@mail.gmail.com>

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().

      reply	other threads:[~2012-02-15 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-12 18:37 Question about resetting a sampling counter in kernel heechul Yun
2012-02-15 13:00 ` Peter Zijlstra [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329310854.2293.79.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=heechul@illinois.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vweaver1@eecs.utk.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox