Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234338
b: refs/heads/master
c: f08199d
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Jan 22, 2011
1 parent b76d13e commit d9d579e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 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: 5c581041cf97aa7980b442de81ddea8273d6dcde
refs/heads/master: f08199d314458610d4ca52f8e86e0a4ec7a7bc54
4 changes: 2 additions & 2 deletions trunk/tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
PERF_FORMAT_TOTAL_TIME_RUNNING;

if (system_wide)
return perf_evsel__open_per_cpu(evsel, cpus);
return perf_evsel__open_per_cpu(evsel, cpus, false);

attr->inherit = !no_inherit;
if (target_pid == -1 && target_tid == -1) {
attr->disabled = 1;
attr->enable_on_exec = 1;
}

return perf_evsel__open_per_thread(evsel, threads);
return perf_evsel__open_per_thread(evsel, threads, false);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions trunk/tools/perf/builtin-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static int test__open_syscall_event(void)
goto out_thread_map_delete;
}

if (perf_evsel__open_per_thread(evsel, threads) < 0) {
if (perf_evsel__open_per_thread(evsel, threads, false) < 0) {
pr_debug("failed to open counter: %s, "
"tweak /proc/sys/kernel/perf_event_paranoid?\n",
strerror(errno));
Expand Down Expand Up @@ -364,7 +364,7 @@ static int test__open_syscall_event_on_all_cpus(void)
goto out_thread_map_delete;
}

if (perf_evsel__open(evsel, cpus, threads) < 0) {
if (perf_evsel__open(evsel, cpus, threads, false) < 0) {
pr_debug("failed to open counter: %s, "
"tweak /proc/sys/kernel/perf_event_paranoid?\n",
strerror(errno));
Expand Down
27 changes: 17 additions & 10 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int __perf_evsel__read(struct perf_evsel *evsel,
}

static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads)
struct thread_map *threads, bool group)
{
int cpu, thread;

Expand All @@ -137,12 +137,18 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
return -1;

for (cpu = 0; cpu < cpus->nr; cpu++) {
int group_fd = -1;

for (thread = 0; thread < threads->nr; thread++) {
FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr,
threads->map[thread],
cpus->map[cpu], -1, 0);
cpus->map[cpu],
group_fd, 0);
if (FD(evsel, cpu, thread) < 0)
goto out_close;

if (group && group_fd == -1)
group_fd = FD(evsel, cpu, thread);
}
}

Expand Down Expand Up @@ -175,10 +181,9 @@ static struct {
.threads = { -1, },
};

int perf_evsel__open(struct perf_evsel *evsel,
struct cpu_map *cpus, struct thread_map *threads)
int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads, bool group)
{

if (cpus == NULL) {
/* Work around old compiler warnings about strict aliasing */
cpus = &empty_cpu_map.map;
Expand All @@ -187,15 +192,17 @@ int perf_evsel__open(struct perf_evsel *evsel,
if (threads == NULL)
threads = &empty_thread_map.map;

return __perf_evsel__open(evsel, cpus, threads);
return __perf_evsel__open(evsel, cpus, threads, group);
}

int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus)
int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
struct cpu_map *cpus, bool group)
{
return __perf_evsel__open(evsel, cpus, &empty_thread_map.map);
return __perf_evsel__open(evsel, cpus, &empty_thread_map.map, group);
}

int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads)
int perf_evsel__open_per_thread(struct perf_evsel *evsel,
struct thread_map *threads, bool group)
{
return __perf_evsel__open(evsel, &empty_cpu_map.map, threads);
return __perf_evsel__open(evsel, &empty_cpu_map.map, threads, group);
}
10 changes: 6 additions & 4 deletions trunk/tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
void perf_evsel__free_fd(struct perf_evsel *evsel);
void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads);

int perf_evsel__open_per_cpu(struct perf_evsel *evsel, struct cpu_map *cpus);
int perf_evsel__open_per_thread(struct perf_evsel *evsel, struct thread_map *threads);
int perf_evsel__open(struct perf_evsel *evsel,
struct cpu_map *cpus, struct thread_map *threads);
int perf_evsel__open_per_cpu(struct perf_evsel *evsel,
struct cpu_map *cpus, bool group);
int perf_evsel__open_per_thread(struct perf_evsel *evsel,
struct thread_map *threads, bool group);
int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
struct thread_map *threads, bool group);

#define perf_evsel__match(evsel, t, c) \
(evsel->attr.type == PERF_TYPE_##t && \
Expand Down

0 comments on commit d9d579e

Please sign in to comment.