Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169486
b: refs/heads/master
c: 7e4ff9e
h: refs/heads/master
v: v3
  • Loading branch information
Mike Galbraith authored and Ingo Molnar committed Oct 12, 2009
1 parent 4b98fed commit 4e57fe1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fe9081cc9bdabb0be953a39ad977cea14e35bce5
refs/heads/master: 7e4ff9e3e8f88de8a8536f43294cd32b4e7d9123
14 changes: 13 additions & 1 deletion trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 21 additions & 7 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static int fd[MAX_NR_CPUS][MAX_COUNTERS];

static int system_wide = 0;

static int default_interval = 100000;
static int default_interval = 0;

static int count_filter = 5;
static int print_entries = 15;
Expand Down Expand Up @@ -975,7 +975,13 @@ static void start_counter(int i, int counter)
attr = attrs + counter;

attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
attr->freq = freq;

if (freq) {
attr->sample_type |= PERF_SAMPLE_PERIOD;
attr->freq = 1;
attr->sample_freq = freq;
}

attr->inherit = (cpu < 0) && inherit;

try_again:
Expand Down Expand Up @@ -1130,11 +1136,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
if (argc)
usage_with_options(top_usage, options);

if (freq) {
default_interval = freq;
freq = 1;
}

/* CPU and PID are mutually exclusive */
if (target_pid != -1 && profile_cpu != -1) {
printf("WARNING: PID switch overriding CPU\n");
Expand All @@ -1151,6 +1152,19 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
parse_symbols();
parse_source(sym_filter_entry);


/*
* 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);
}

/*
* Fill in the ones not specifically initialized via -c:
*/
Expand Down

0 comments on commit 4e57fe1

Please sign in to comment.