Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191200
b: refs/heads/master
c: f921281
h: refs/heads/master
v: v3
  • Loading branch information
Frederic Weisbecker committed Apr 15, 2010
1 parent ac7e5f7 commit fddb973
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 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: bdef3b02ceeb97f5f67fcfa6dff13c4e70b34fb7
refs/heads/master: f92128193094c288bc315db1694fafeaeb7ee1d0
36 changes: 22 additions & 14 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ enum write_mode_t {

static int *fd[MAX_NR_CPUS][MAX_COUNTERS];

static unsigned int user_interval = UINT_MAX;
static long default_interval = 0;

static int nr_cpus = 0;
static unsigned int page_size;
static unsigned int mmap_pages = 128;
static unsigned int user_freq = UINT_MAX;
static int freq = 1000;
static int output;
static const char *output_name = "perf.data";
Expand Down Expand Up @@ -255,10 +257,19 @@ static void create_counter(int counter, int cpu)
if (nr_counters > 1)
attr->sample_type |= PERF_SAMPLE_ID;

if (freq) {
attr->sample_type |= PERF_SAMPLE_PERIOD;
attr->freq = 1;
attr->sample_freq = freq;
/*
* We default some events to a 1 default interval. But keep
* it a weak assumption overridable by the user.
*/
if (!attr->sample_period || (user_freq != UINT_MAX &&
user_interval != UINT_MAX)) {
if (freq) {
attr->sample_type |= PERF_SAMPLE_PERIOD;
attr->freq = 1;
attr->sample_freq = freq;
} else {
attr->sample_period = default_interval;
}
}

if (no_samples)
Expand Down Expand Up @@ -689,13 +700,13 @@ static const struct option options[] = {
"CPU to profile on"),
OPT_BOOLEAN('f', "force", &force,
"overwrite existing data file (deprecated)"),
OPT_LONG('c', "count", &default_interval,
OPT_LONG('c', "count", &user_interval,
"event period to sample"),
OPT_STRING('o', "output", &output_name, "file",
"output file name"),
OPT_BOOLEAN('i', "inherit", &inherit,
"child tasks inherit counters"),
OPT_INTEGER('F', "freq", &freq,
OPT_INTEGER('F', "freq", &user_freq,
"profile at this frequency"),
OPT_INTEGER('m', "mmap-pages", &mmap_pages,
"number of mmap data pages"),
Expand All @@ -716,7 +727,6 @@ static const struct option options[] = {

int cmd_record(int argc, const char **argv, const char *prefix __used)
{
int counter;
int i,j;

argc = parse_options(argc, argv, options, record_usage,
Expand Down Expand Up @@ -774,6 +784,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
if (!event_array)
return -ENOMEM;

if (user_interval != UINT_MAX)
default_interval = user_interval;
if (user_freq != UINT_MAX)
freq = user_freq;

/*
* User specified count overrides default frequency.
*/
Expand All @@ -786,12 +801,5 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
exit(EXIT_FAILURE);
}

for (counter = 0; counter < nr_counters; counter++) {
if (attrs[counter].sample_period)
continue;

attrs[counter].sample_period = default_interval;
}

return __cmd_record(argc, argv);
}
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ parse_single_tracepoint_event(char *sys_name,
attr->sample_type |= PERF_SAMPLE_TIME;
attr->sample_type |= PERF_SAMPLE_CPU;

attr->sample_period = 1;

snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path,
sys_name, evt_name);

Expand Down

0 comments on commit fddb973

Please sign in to comment.