perf tools: Fix counter sample frequency breakage

Commit 42e59d7d19 switched to a default sample frequency of
1KHz, which overrides any user supplied count, causing sched, top
and timechart to miss events due to their discrete events
being flagged PERF_SAMPLE_PERIOD.

Override default sample frequency when the user profides a
period count, and make both record and top honor that user
supplied option.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arjan van de Ven <arjan@infradead.org>
LKML-Reference: <1255326963.15107.2.camel@marge.simson.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Mike Galbraith
2009-10-12 07:56:03 +02:00
committed by Ingo Molnar
parent fe9081cc9b
commit 7e4ff9e3e8
2 changed files with 34 additions and 8 deletions

View File

@@ -26,7 +26,7 @@
static int fd[MAX_NR_CPUS][MAX_COUNTERS];
static long default_interval = 100000;
static long default_interval = 0;
static int nr_cpus = 0;
static unsigned int page_size;
@@ -730,6 +730,18 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
attrs[0].config = PERF_COUNT_HW_CPU_CYCLES;
}
/*
* User specified count overrides default frequency.
*/
if (default_interval)
freq = 0;
else if (freq) {
default_interval = freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
exit(EXIT_FAILURE);
}
for (counter = 0; counter < nr_counters; counter++) {
if (attrs[counter].sample_period)
continue;