Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349899
b: refs/heads/master
c: 7be5ebe
h: refs/heads/master
i:
  349897: c109d3e
  349895: c060851
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Dec 10, 2012
1 parent 3b3bf06 commit 149a3ea
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 24 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: 3f067dcab711c2df7eefcfc5b3aa9a0e2b5f7d42
refs/heads/master: 7be5ebe8767eaa482e18f566de5f56c1519abf59
2 changes: 1 addition & 1 deletion trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static int perf_record__open(struct perf_record *rec)
*/
opts->sample_id_all_missing = true;
if (!opts->sample_time && !opts->raw_samples && !time_needed)
attr->sample_type &= ~PERF_SAMPLE_TIME;
perf_evsel__reset_sample_bit(pos, TIME);

goto retry_sample_id;
}
Expand Down
11 changes: 6 additions & 5 deletions trunk/tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,24 +901,25 @@ static void perf_top__start_counters(struct perf_top *top)
list_for_each_entry(counter, &evlist->entries, node) {
struct perf_event_attr *attr = &counter->attr;

attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
perf_evsel__set_sample_bit(counter, IP);
perf_evsel__set_sample_bit(counter, TID);

if (top->freq) {
attr->sample_type |= PERF_SAMPLE_PERIOD;
perf_evsel__set_sample_bit(counter, PERIOD);
attr->freq = 1;
attr->sample_freq = top->freq;
}

if (evlist->nr_entries > 1) {
attr->sample_type |= PERF_SAMPLE_ID;
perf_evsel__set_sample_bit(counter, ID);
attr->read_format |= PERF_FORMAT_ID;
}

if (perf_target__has_cpu(&top->target))
attr->sample_type |= PERF_SAMPLE_CPU;
perf_evsel__set_sample_bit(counter, CPU);

if (symbol_conf.use_callchain)
attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
perf_evsel__set_sample_bit(counter, CALLCHAIN);

attr->mmap = 1;
attr->comm = 1;
Expand Down
6 changes: 3 additions & 3 deletions trunk/tools/perf/tests/perf-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ int test__PERF_RECORD(void)
* Config the evsels, setting attr->comm on the first one, etc.
*/
evsel = perf_evlist__first(evlist);
evsel->attr.sample_type |= PERF_SAMPLE_CPU;
evsel->attr.sample_type |= PERF_SAMPLE_TID;
evsel->attr.sample_type |= PERF_SAMPLE_TIME;
perf_evsel__set_sample_bit(evsel, CPU);
perf_evsel__set_sample_bit(evsel, TID);
perf_evsel__set_sample_bit(evsel, TIME);
perf_evlist__config_attrs(evlist, &opts);

err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask);
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void perf_evlist__config_attrs(struct perf_evlist *evlist,
perf_evsel__config(evsel, opts);

if (evlist->nr_entries > 1)
evsel->attr.sample_type |= PERF_SAMPLE_ID;
perf_evsel__set_sample_bit(evsel, ID);
}
}

Expand Down
45 changes: 32 additions & 13 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ void hists__init(struct hists *hists)
pthread_mutex_init(&hists->lock, NULL);
}

void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit)
{
if (!(evsel->attr.sample_type & bit)) {
evsel->attr.sample_type |= bit;
evsel->sample_size += sizeof(u64);
}
}

void __perf_evsel__reset_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit)
{
if (evsel->attr.sample_type & bit) {
evsel->attr.sample_type &= ~bit;
evsel->sample_size -= sizeof(u64);
}
}

void perf_evsel__init(struct perf_evsel *evsel,
struct perf_event_attr *attr, int idx)
{
Expand Down Expand Up @@ -445,7 +463,8 @@ void perf_evsel__config(struct perf_evsel *evsel,
PERF_FORMAT_TOTAL_TIME_RUNNING |
PERF_FORMAT_ID;

attr->sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
perf_evsel__set_sample_bit(evsel, IP);
perf_evsel__set_sample_bit(evsel, TID);

/*
* We default some events to a 1 default interval. But keep
Expand All @@ -454,7 +473,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
if (!attr->sample_period || (opts->user_freq != UINT_MAX &&
opts->user_interval != ULLONG_MAX)) {
if (opts->freq) {
attr->sample_type |= PERF_SAMPLE_PERIOD;
perf_evsel__set_sample_bit(evsel, PERIOD);
attr->freq = 1;
attr->sample_freq = opts->freq;
} else {
Expand All @@ -469,45 +488,45 @@ void perf_evsel__config(struct perf_evsel *evsel,
attr->inherit_stat = 1;

if (opts->sample_address) {
attr->sample_type |= PERF_SAMPLE_ADDR;
perf_evsel__set_sample_bit(evsel, ADDR);
attr->mmap_data = track;
}

if (opts->call_graph) {
attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
perf_evsel__set_sample_bit(evsel, CALLCHAIN);

if (opts->call_graph == CALLCHAIN_DWARF) {
attr->sample_type |= PERF_SAMPLE_REGS_USER |
PERF_SAMPLE_STACK_USER;
perf_evsel__set_sample_bit(evsel, REGS_USER);
perf_evsel__set_sample_bit(evsel, STACK_USER);
attr->sample_regs_user = PERF_REGS_MASK;
attr->sample_stack_user = opts->stack_dump_size;
attr->exclude_callchain_user = 1;
}
}

if (perf_target__has_cpu(&opts->target))
attr->sample_type |= PERF_SAMPLE_CPU;
perf_evsel__set_sample_bit(evsel, CPU);

if (opts->period)
attr->sample_type |= PERF_SAMPLE_PERIOD;
perf_evsel__set_sample_bit(evsel, PERIOD);

if (!opts->sample_id_all_missing &&
(opts->sample_time || !opts->no_inherit ||
perf_target__has_cpu(&opts->target)))
attr->sample_type |= PERF_SAMPLE_TIME;
perf_evsel__set_sample_bit(evsel, TIME);

if (opts->raw_samples) {
attr->sample_type |= PERF_SAMPLE_TIME;
attr->sample_type |= PERF_SAMPLE_RAW;
attr->sample_type |= PERF_SAMPLE_CPU;
perf_evsel__set_sample_bit(evsel, TIME);
perf_evsel__set_sample_bit(evsel, RAW);
perf_evsel__set_sample_bit(evsel, CPU);
}

if (opts->no_delay) {
attr->watermark = 0;
attr->wakeup_events = 1;
}
if (opts->branch_stack) {
attr->sample_type |= PERF_SAMPLE_BRANCH_STACK;
perf_evsel__set_sample_bit(evsel, BRANCH_STACK);
attr->branch_sample_type = opts->branch_stack;
}

Expand Down
11 changes: 11 additions & 0 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ void perf_evsel__free_fd(struct perf_evsel *evsel);
void perf_evsel__free_id(struct perf_evsel *evsel);
void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);

void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit);
void __perf_evsel__reset_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit);

#define perf_evsel__set_sample_bit(evsel, bit) \
__perf_evsel__set_sample_bit(evsel, PERF_SAMPLE_##bit)

#define perf_evsel__reset_sample_bit(evsel, bit) \
__perf_evsel__reset_sample_bit(evsel, PERF_SAMPLE_##bit)

int perf_evsel__set_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
const char *filter);

Expand Down

0 comments on commit 149a3ea

Please sign in to comment.