Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 257095
b: refs/heads/master
c: 5d67be9
h: refs/heads/master
i:
  257093: 0a3b7d7
  257091: 2581407
  257087: f4a6645
v: v3
  • Loading branch information
Anton Blanchard authored and Ingo Molnar committed Jul 5, 2011
1 parent 2f2db9c commit fa0e4d4
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9f8b6a6cf0ee78de87ebe1e87f54bec1c1741ef7
refs/heads/master: 5d67be97f8903d05ce53597fb5f3bc25a45e8026
6 changes: 6 additions & 0 deletions trunk/tools/perf/Documentation/perf-annotate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ OPTIONS
used. This interfaces starts by centering on the line with more
samples, TAB/UNTAB cycles through the lines with more samples.

-c::
--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
be provided as a comma-separated list with no space: 0,1. Ranges of
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.

SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-report[1]
6 changes: 6 additions & 0 deletions trunk/tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ OPTIONS
--symfs=<directory>::
Look for files with symbols relative to this directory.

-c::
--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
be provided as a comma-separated list with no space: 0,1. Ranges of
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.

SEE ALSO
--------
linkperf:perf-stat[1]
6 changes: 6 additions & 0 deletions trunk/tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ OPTIONS
--hide-call-graph::
When printing symbols do not display call chain.

-c::
--cpu:: Only report samples for the list of CPUs provided. Multiple CPUs can
be provided as a comma-separated list with no space: 0,1. Ranges of
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.

SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script-perl[1],
Expand Down
15 changes: 15 additions & 0 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "util/hist.h"
#include "util/session.h"

#include <linux/bitmap.h>

static char const *input_name = "perf.data";

static bool force, use_tui, use_stdio;
Expand All @@ -38,6 +40,9 @@ static bool print_line;

static const char *sym_hist_filter;

static const char *cpu_list;
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);

static int perf_evlist__add_sample(struct perf_evlist *evlist,
struct perf_sample *sample,
struct perf_evsel *evsel,
Expand Down Expand Up @@ -90,6 +95,9 @@ static int process_sample_event(union perf_event *event,
return -1;
}

if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0;

if (!al.filtered &&
perf_evlist__add_sample(session->evlist, sample, evsel, &al)) {
pr_warning("problem incrementing symbol count, "
Expand Down Expand Up @@ -177,6 +185,12 @@ static int __cmd_annotate(void)
if (session == NULL)
return -ENOMEM;

if (cpu_list) {
ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap);
if (ret)
goto out_delete;
}

ret = perf_session__process_events(session, &event_ops);
if (ret)
goto out_delete;
Expand Down Expand Up @@ -252,6 +266,7 @@ static const struct option options[] = {
"print matching source lines (may be slow)"),
OPT_BOOLEAN('P', "full-paths", &full_paths,
"Don't shorten the displayed pathnames"),
OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
OPT_END()
};

Expand Down
15 changes: 15 additions & 0 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "util/sort.h"
#include "util/hist.h"

#include <linux/bitmap.h>

static char const *input_name = "perf.data";

static bool force, use_tui, use_stdio;
Expand All @@ -49,6 +51,9 @@ static char callchain_default_opt[] = "fractal,0.5,callee";
static bool inverted_callchain;
static symbol_filter_t annotate_init;

static const char *cpu_list;
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);

static int perf_session__add_hist_entry(struct perf_session *session,
struct addr_location *al,
struct perf_sample *sample,
Expand Down Expand Up @@ -117,6 +122,9 @@ static int process_sample_event(union perf_event *event,
if (al.filtered || (hide_unresolved && al.sym == NULL))
return 0;

if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0;

if (al.map != NULL)
al.map->dso->hit = 1;

Expand Down Expand Up @@ -263,6 +271,12 @@ static int __cmd_report(void)
if (session == NULL)
return -ENOMEM;

if (cpu_list) {
ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap);
if (ret)
goto out_delete;
}

if (show_threads)
perf_read_values_init(&show_threads_values);

Expand Down Expand Up @@ -473,6 +487,7 @@ static const struct option options[] = {
"Only display entries resolved to a symbol"),
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
"Look for files with symbols relative to this directory"),
OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
OPT_END()
};

Expand Down
13 changes: 13 additions & 0 deletions trunk/tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "util/util.h"
#include "util/evlist.h"
#include "util/evsel.h"
#include <linux/bitmap.h>

static char const *script_name;
static char const *generate_script_lang;
Expand All @@ -21,6 +22,8 @@ static u64 last_timestamp;
static u64 nr_unordered;
extern const struct option record_options[];
static bool no_callchain;
static const char *cpu_list;
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);

enum perf_output_field {
PERF_OUTPUT_COMM = 1U << 0,
Expand Down Expand Up @@ -453,6 +456,10 @@ static int process_sample_event(union perf_event *event,
last_timestamp = sample->time;
return 0;
}

if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
return 0;

scripting_ops->process_event(event, sample, evsel, session, thread);

session->hists.stats.total_period += sample->period;
Expand Down Expand Up @@ -1075,6 +1082,7 @@ static const struct option options[] = {
OPT_CALLBACK('f', "fields", NULL, "str",
"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr",
parse_output_fields),
OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),

OPT_END()
};
Expand Down Expand Up @@ -1255,6 +1263,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
if (session == NULL)
return -ENOMEM;

if (cpu_list) {
if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap))
return -1;
}

if (!no_callchain)
symbol_conf.use_callchain = true;
else
Expand Down
38 changes: 38 additions & 0 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "session.h"
#include "sort.h"
#include "util.h"
#include "cpumap.h"

static int perf_session__open(struct perf_session *self, bool force)
{
Expand Down Expand Up @@ -1282,3 +1283,40 @@ void perf_session__print_ip(union perf_event *event,
}
}
}

int perf_session__cpu_bitmap(struct perf_session *session,
const char *cpu_list, unsigned long *cpu_bitmap)
{
int i;
struct cpu_map *map;

for (i = 0; i < PERF_TYPE_MAX; ++i) {
struct perf_evsel *evsel;

evsel = perf_session__find_first_evtype(session, i);
if (!evsel)
continue;

if (!(evsel->attr.sample_type & PERF_SAMPLE_CPU)) {
pr_err("File does not contain CPU events. "
"Remove -c option to proceed.\n");
return -1;
}
}

map = cpu_map__new(cpu_list);

for (i = 0; i < map->nr; i++) {
int cpu = map->map[i];

if (cpu >= MAX_NR_CPUS) {
pr_err("Requested CPU %d too large. "
"Consider raising MAX_NR_CPUS\n", cpu);
return -1;
}

set_bit(cpu, cpu_bitmap);
}

return 0;
}
3 changes: 3 additions & 0 deletions trunk/tools/perf/util/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,7 @@ void perf_session__print_ip(union perf_event *event,
struct perf_session *session,
int print_sym, int print_dso);

int perf_session__cpu_bitmap(struct perf_session *session,
const char *cpu_list, unsigned long *cpu_bitmap);

#endif /* __PERF_SESSION_H */

0 comments on commit fa0e4d4

Please sign in to comment.