Skip to content

Commit

Permalink
perf target: Shorten perf_target__ to target__
Browse files Browse the repository at this point in the history
Getting unwieldly long, for this app domain should be descriptive enough
and the use of __ to separate the class from the method names should
help with avoiding clashes with other code bases.

Reported-by: David Ahern <[email protected]>
Suggested-by: Ingo Molnar <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Nov 12, 2013
1 parent 48095b7 commit 602ad87
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 109 deletions.
6 changes: 3 additions & 3 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1510,13 +1510,13 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
/*
* target related setups
*/
err = perf_target__validate(&kvm->opts.target);
err = target__validate(&kvm->opts.target);
if (err) {
perf_target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ);
target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
}

if (perf_target__none(&kvm->opts.target))
if (target__none(&kvm->opts.target))
kvm->opts.target.system_wide = true;


Expand Down
14 changes: 7 additions & 7 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* (apart from group members) have enable_on_exec=1 set,
* so don't spoil it by prematurely enabling them.
*/
if (!perf_target__none(&opts->target))
if (!target__none(&opts->target))
perf_evlist__enable(evsel_list);

/*
Expand Down Expand Up @@ -535,7 +535,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* die with the process and we wait for that. Thus no need to
* disable events in this case.
*/
if (done && !disabled && !perf_target__none(&opts->target)) {
if (done && !disabled && !target__none(&opts->target)) {
perf_evlist__disable(evsel_list);
disabled = true;
}
Expand Down Expand Up @@ -906,7 +906,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)

argc = parse_options(argc, argv, record_options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc && perf_target__none(&rec->opts.target))
if (!argc && target__none(&rec->opts.target))
usage_with_options(record_usage, record_options);

if (nr_cgroups && !rec->opts.target.system_wide) {
Expand Down Expand Up @@ -936,17 +936,17 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
goto out_symbol_exit;
}

err = perf_target__validate(&rec->opts.target);
err = target__validate(&rec->opts.target);
if (err) {
perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
}

err = perf_target__parse_uid(&rec->opts.target);
err = target__parse_uid(&rec->opts.target);
if (err) {
int saved_errno = errno;

perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
ui__error("%s", errbuf);

err = -saved_errno;
Expand Down
21 changes: 10 additions & 11 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ enum {

static struct perf_evlist *evsel_list;

static struct perf_target target = {
static struct target target = {
.uid = UINT_MAX,
};

Expand Down Expand Up @@ -294,11 +294,10 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)

attr->inherit = !no_inherit;

if (perf_target__has_cpu(&target))
if (target__has_cpu(&target))
return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));

if (!perf_target__has_task(&target) &&
perf_evsel__is_group_leader(evsel)) {
if (!target__has_task(&target) && perf_evsel__is_group_leader(evsel)) {
attr->disabled = 1;
if (!initial_delay)
attr->enable_on_exec = 1;
Expand Down Expand Up @@ -1236,7 +1235,7 @@ static void print_stat(int argc, const char **argv)
fprintf(output, "\'system wide");
else if (target.cpu_list)
fprintf(output, "\'CPU(s) %s", target.cpu_list);
else if (!perf_target__has_task(&target)) {
else if (!target__has_task(&target)) {
fprintf(output, "\'%s", argv[0]);
for (i = 1; i < argc; i++)
fprintf(output, " %s", argv[i]);
Expand Down Expand Up @@ -1667,7 +1666,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
} else if (big_num_opt == 0) /* User passed --no-big-num */
big_num = false;

if (!argc && perf_target__none(&target))
if (!argc && target__none(&target))
usage_with_options(stat_usage, options);

if (run_count < 0) {
Expand All @@ -1680,8 +1679,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
}

/* no_aggr, cgroup are for system-wide only */
if ((aggr_mode != AGGR_GLOBAL || nr_cgroups)
&& !perf_target__has_cpu(&target)) {
if ((aggr_mode != AGGR_GLOBAL || nr_cgroups) &&
!target__has_cpu(&target)) {
fprintf(stderr, "both cgroup and no-aggregation "
"modes only available in system-wide mode\n");

Expand All @@ -1694,14 +1693,14 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
if (add_default_attributes())
goto out;

perf_target__validate(&target);
target__validate(&target);

if (perf_evlist__create_maps(evsel_list, &target) < 0) {
if (perf_target__has_task(&target)) {
if (target__has_task(&target)) {
pr_err("Problems finding threads of monitor\n");
parse_options_usage(stat_usage, options, "p", 1);
parse_options_usage(NULL, options, "t", 1);
} else if (perf_target__has_cpu(&target)) {
} else if (target__has_cpu(&target)) {
perror("failed to parse CPUs map");
parse_options_usage(stat_usage, options, "C", 1);
parse_options_usage(NULL, options, "a", 1);
Expand Down
14 changes: 7 additions & 7 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ static int __cmd_top(struct perf_top *top)
* XXX 'top' still doesn't start workloads like record, trace, but should,
* so leave the check here.
*/
if (!perf_target__none(&opts->target))
if (!target__none(&opts->target))
perf_evlist__enable(top->evlist);

/* Wait for a minimal set of events before starting the snapshot */
Expand Down Expand Up @@ -1053,7 +1053,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
.sym_pcnt_filter = 5,
};
struct perf_record_opts *opts = &top.record_opts;
struct perf_target *target = &opts->target;
struct target *target = &opts->target;
const struct option options[] = {
OPT_CALLBACK('e', "event", &top.evlist, "event",
"event selector. use 'perf list' to list available events",
Expand Down Expand Up @@ -1169,24 +1169,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)

setup_browser(false);

status = perf_target__validate(target);
status = target__validate(target);
if (status) {
perf_target__strerror(target, status, errbuf, BUFSIZ);
target__strerror(target, status, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
}

status = perf_target__parse_uid(target);
status = target__parse_uid(target);
if (status) {
int saved_errno = errno;

perf_target__strerror(target, status, errbuf, BUFSIZ);
target__strerror(target, status, errbuf, BUFSIZ);
ui__error("%s", errbuf);

status = -saved_errno;
goto out_delete_evlist;
}

if (perf_target__none(target))
if (target__none(target))
target->system_wide = true;

if (perf_evlist__create_maps(top.evlist, target) < 0)
Expand Down
10 changes: 5 additions & 5 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2327,21 +2327,21 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
}
}

err = perf_target__validate(&trace.opts.target);
err = target__validate(&trace.opts.target);
if (err) {
perf_target__strerror(&trace.opts.target, err, bf, sizeof(bf));
target__strerror(&trace.opts.target, err, bf, sizeof(bf));
fprintf(trace.output, "%s", bf);
goto out_close;
}

err = perf_target__parse_uid(&trace.opts.target);
err = target__parse_uid(&trace.opts.target);
if (err) {
perf_target__strerror(&trace.opts.target, err, bf, sizeof(bf));
target__strerror(&trace.opts.target, err, bf, sizeof(bf));
fprintf(trace.output, "%s", bf);
goto out_close;
}

if (!argc && perf_target__none(&trace.opts.target))
if (!argc && target__none(&trace.opts.target))
trace.opts.target.system_wide = true;

if (input_name)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ enum perf_call_graph_mode {
};

struct perf_record_opts {
struct perf_target target;
struct target target;
int call_graph;
bool group;
bool inherit_stat;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/task-exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int test__task_exit(void)
union perf_event *event;
struct perf_evsel *evsel;
struct perf_evlist *evlist;
struct perf_target target = {
struct target target = {
.uid = UINT_MAX,
.uses_mmap = true,
};
Expand Down
12 changes: 5 additions & 7 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,18 +811,17 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
return perf_evlist__mmap_per_cpu(evlist, prot, mask);
}

int perf_evlist__create_maps(struct perf_evlist *evlist,
struct perf_target *target)
int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
{
evlist->threads = thread_map__new_str(target->pid, target->tid,
target->uid);

if (evlist->threads == NULL)
return -1;

if (perf_target__has_task(target))
if (target__has_task(target))
evlist->cpus = cpu_map__dummy_new();
else if (!perf_target__has_cpu(target) && !target->uses_mmap)
else if (!target__has_cpu(target) && !target->uses_mmap)
evlist->cpus = cpu_map__dummy_new();
else
evlist->cpus = cpu_map__new(target->cpu_list);
Expand Down Expand Up @@ -1031,8 +1030,7 @@ int perf_evlist__open(struct perf_evlist *evlist)
return err;
}

int perf_evlist__prepare_workload(struct perf_evlist *evlist,
struct perf_target *target,
int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *target,
const char *argv[], bool pipe_output,
bool want_signal)
{
Expand Down Expand Up @@ -1084,7 +1082,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
exit(-1);
}

if (perf_target__none(target))
if (target__none(target))
evlist->threads->map[0] = evlist->workload.pid;

close(child_ready_pipe[1]);
Expand Down
5 changes: 2 additions & 3 deletions tools/perf/util/evlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void perf_evlist__config(struct perf_evlist *evlist,
int perf_record_opts__config(struct perf_record_opts *opts);

int perf_evlist__prepare_workload(struct perf_evlist *evlist,
struct perf_target *target,
struct target *target,
const char *argv[], bool pipe_output,
bool want_signal);
int perf_evlist__start_workload(struct perf_evlist *evlist);
Expand Down Expand Up @@ -134,8 +134,7 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
evlist->threads = threads;
}

int perf_evlist__create_maps(struct perf_evlist *evlist,
struct perf_target *target);
int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
void perf_evlist__delete_maps(struct perf_evlist *evlist);
int perf_evlist__apply_filters(struct perf_evlist *evlist);

Expand Down
9 changes: 4 additions & 5 deletions tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,15 @@ void perf_evsel__config(struct perf_evsel *evsel,
}
}

if (perf_target__has_cpu(&opts->target))
if (target__has_cpu(&opts->target))
perf_evsel__set_sample_bit(evsel, CPU);

if (opts->period)
perf_evsel__set_sample_bit(evsel, PERIOD);

if (!perf_missing_features.sample_id_all &&
(opts->sample_time || !opts->no_inherit ||
perf_target__has_cpu(&opts->target)))
target__has_cpu(&opts->target)))
perf_evsel__set_sample_bit(evsel, TIME);

if (opts->raw_samples) {
Expand Down Expand Up @@ -696,7 +696,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
* Setting enable_on_exec for independent events and
* group leaders for traced executed by perf.
*/
if (perf_target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
attr->enable_on_exec = 1;
}

Expand Down Expand Up @@ -2006,8 +2006,7 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
return false;
}

int perf_evsel__open_strerror(struct perf_evsel *evsel,
struct perf_target *target,
int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
int err, char *msg, size_t size)
{
switch (err) {
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/util/evsel.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,

bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
char *msg, size_t msgsize);
int perf_evsel__open_strerror(struct perf_evsel *evsel,
struct perf_target *target,
int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
int err, char *msg, size_t size);

static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,12 +1396,12 @@ int machine__for_each_thread(struct machine *machine,
}

int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
struct perf_target *target, struct thread_map *threads,
struct target *target, struct thread_map *threads,
perf_event__handler_t process, bool data_mmap)
{
if (perf_target__has_task(target))
if (target__has_task(target))
return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
else if (perf_target__has_cpu(target))
else if (target__has_cpu(target))
return perf_event__synthesize_threads(tool, process, machine, data_mmap);
/* command specified */
return 0;
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ int machine__for_each_thread(struct machine *machine,
void *priv);

int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
struct perf_target *target, struct thread_map *threads,
struct target *target, struct thread_map *threads,
perf_event__handler_t process, bool data_mmap);
static inline
int machine__synthesize_threads(struct machine *machine, struct perf_target *target,
int machine__synthesize_threads(struct machine *machine, struct target *target,
struct thread_map *threads, bool data_mmap)
{
return __machine__synthesize_threads(machine, NULL, target, threads,
Expand Down
Loading

0 comments on commit 602ad87

Please sign in to comment.