mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: perf_counter: resetting a event counter
Date: Tue, 5 May 2009 08:52:06 +0200	[thread overview]
Message-ID: <20090505065206.GB27191@elte.hu> (raw)
In-Reply-To: <49FF68EF.40300@linux.vnet.ibm.com>


* Corey Ashford <cjashfor@linux.vnet.ibm.com> wrote:

> Hi,
>
> In implementing the PAPI_reset function, whose purpose is to reset 
> all of the counters in an event set, I found that [it appears] 
> there is no straight-forward way to implement this function using 
> "Performance Couunters for Linux".  My current implementation just 
> closes the counters and reopens them again.  This is not a elegant 
> solution, nor is the other alternative that occurred to me: 
> maintain a "virtual" counter in user space, maintained using a 
> base count, which is subtracted off of the current perf_counter 
> value of a particular counter.
>
> Is there a way that I missed to reset an event counter?  If not, 
> I'd like to request that a new ioctl command be added to support 
> this ability.

We already have such ioctl actions:

        case PERF_COUNTER_IOC_ENABLE:
        case PERF_COUNTER_IOC_DISABLE:
        case PERF_COUNTER_IOC_REFRESH:

It would be a pretty natural addition to also have a reset method 
there. Would you like to take a stab at it and send a patch? A 
first-level approximation would be to do something like:

	perf_counter_disable(counter);
	atomic64_set(&counter->count, 0);
	perf_counter_enable(counter);

btw, the reset code should probably take the counter->mutex lock as 
well, because parallel resets done from multiple contexts are 
otherwise not well-defined.

	Ingo

  reply	other threads:[~2009-05-05  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-04 22:15 Corey Ashford
2009-05-05  6:52 ` Ingo Molnar [this message]
2009-05-05  7:34   ` Peter Zijlstra
2009-05-05  7:42     ` Ingo Molnar

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=20090505065206.GB27191@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    /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

all inboxes | Powered by JetHome®