lkml.org 
[lkml]   [2009]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH 3/7] perf_counter: ioctl(PERF_COUNTER_IOC_RESET)
From
Date
On Tue, 2009-05-05 at 11:31 -0700, Corey Ashford wrote:
> Hi Peter,
>
> Peter Zijlstra wrote:
>
> > +static void perf_counter_reset(struct perf_counter *counter)
> > +{
> > + atomic_set(&counter->count, 0);
> > +}
> > +
>
>
> Thanks for posting a patch for this issue.
>
> As Ingo said, I think the hardware counter needs to be reset as well as
> the value saved in the perf_counter struct.
>

I don't think that's needed, we calculate a delta between prev_count and
the current read and use that to increment counter->count. Therefore
when we reset counter->count we should not need to touch the hardware
counter.

However, I do think we need the below, first read the hardware counter
to ensure that delta spoken of above is as close to zero as possible
when we reset.

And update the user-page bits.

---
Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1299,7 +1299,9 @@ static unsigned int perf_poll(struct fil

static void perf_counter_reset(struct perf_counter *counter)
{
+ (void)perf_counter_read(counter);
atomic_set(&counter->count, 0);
+ perf_counter_update_userpage(counter);
}

static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)



\
 
 \ /
  Last update: 2009-05-05 20:45    [from the cache]
©2003-2011 Jasper Spaans