Messages in this thread Patch in this message |  | | | Subject | Re: [PATCH 3/7] perf_counter: ioctl(PERF_COUNTER_IOC_RESET) | | From | Peter Zijlstra <> | | Date | Tue, 05 May 2009 20:42:56 +0200 |
| |
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)
|  |