Skip to content

Commit 2d4f279

Browse files
olsajiriacmel
authored andcommitted
perf data: Add global path holder
Add a 'path' member to 'struct perf_data'. It will keep the configured path for the data (const char *). The path in struct perf_data_file is now dynamically allocated (duped) from it. This scheme is useful/used in following patches where struct perf_data::path holds the 'configure' directory path and struct perf_data_file::path holds the allocated path for specific files. Also it actually makes the code little simpler. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/20190221094145.9151-3-jolsa@kernel.org [ Fixup data-convert-bt.c missing conversion ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 45112e8 commit 2d4f279

21 files changed

Lines changed: 87 additions & 93 deletions

‎tools/perf/builtin-annotate.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
441441
}
442442

443443
if (total_nr_samples == 0) {
444-
ui__error("The %s file has no samples!\n", session->data->file.path);
444+
ui__error("The %s data has no samples!\n", session->data->path);
445445
goto out;
446446
}
447447

@@ -578,7 +578,7 @@ int cmd_annotate(int argc, const char **argv)
578578
if (quiet)
579579
perf_quiet_option();
580580

581-
data.file.path = input_name;
581+
data.path = input_name;
582582

583583
annotate.session = perf_session__new(&data, false, &annotate.tool);
584584
if (annotate.session == NULL)

‎tools/perf/builtin-buildid-cache.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ int cmd_buildid_cache(int argc, const char **argv)
416416
nsi = nsinfo__new(ns_id);
417417

418418
if (missing_filename) {
419-
data.file.path = missing_filename;
420-
data.force = force;
419+
data.path = missing_filename;
420+
data.force = force;
421421

422422
session = perf_session__new(&data, false, NULL);
423423
if (session == NULL)

‎tools/perf/builtin-buildid-list.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
5252
{
5353
struct perf_session *session;
5454
struct perf_data data = {
55-
.file = {
56-
.path = input_name,
57-
},
58-
.mode = PERF_DATA_MODE_READ,
59-
.force = force,
55+
.path = input_name,
56+
.mode = PERF_DATA_MODE_READ,
57+
.force = force,
6058
};
6159

6260
symbol__elf_init();

‎tools/perf/builtin-c2c.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,8 +2750,8 @@ static int perf_c2c__report(int argc, const char **argv)
27502750
if (!input_name || !strlen(input_name))
27512751
input_name = "perf.data";
27522752

2753-
data.file.path = input_name;
2754-
data.force = symbol_conf.force;
2753+
data.path = input_name;
2754+
data.force = symbol_conf.force;
27552755

27562756
err = setup_display(display);
27572757
if (err)

‎tools/perf/builtin-diff.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ static void data__fprintf(void)
708708

709709
data__for_each_file(i, d)
710710
fprintf(stdout, "# [%d] %s %s\n",
711-
d->idx, d->data.file.path,
711+
d->idx, d->data.path,
712712
!d->idx ? "(Baseline)" : "");
713713

714714
fprintf(stdout, "#\n");
@@ -779,14 +779,14 @@ static int __cmd_diff(void)
779779
data__for_each_file(i, d) {
780780
d->session = perf_session__new(&d->data, false, &tool);
781781
if (!d->session) {
782-
pr_err("Failed to open %s\n", d->data.file.path);
782+
pr_err("Failed to open %s\n", d->data.path);
783783
ret = -1;
784784
goto out_delete;
785785
}
786786

787787
ret = perf_session__process_events(d->session);
788788
if (ret) {
789-
pr_err("Failed to process %s\n", d->data.file.path);
789+
pr_err("Failed to process %s\n", d->data.path);
790790
goto out_delete;
791791
}
792792

@@ -1289,9 +1289,9 @@ static int data_init(int argc, const char **argv)
12891289
data__for_each_file(i, d) {
12901290
struct perf_data *data = &d->data;
12911291

1292-
data->file.path = use_default ? defaults[i] : argv[i];
1293-
data->mode = PERF_DATA_MODE_READ,
1294-
data->force = force,
1292+
data->path = use_default ? defaults[i] : argv[i];
1293+
data->mode = PERF_DATA_MODE_READ,
1294+
data->force = force,
12951295

12961296
d->idx = i;
12971297
}

‎tools/perf/builtin-evlist.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
2323
struct perf_session *session;
2424
struct perf_evsel *pos;
2525
struct perf_data data = {
26-
.file = {
27-
.path = file_name,
28-
},
26+
.path = file_name,
2927
.mode = PERF_DATA_MODE_READ,
3028
.force = details->force,
3129
};

‎tools/perf/builtin-inject.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,8 @@ int cmd_inject(int argc, const char **argv)
770770
.input_name = "-",
771771
.samples = LIST_HEAD_INIT(inject.samples),
772772
.output = {
773-
.file = {
774-
.path = "-",
775-
},
776-
.mode = PERF_DATA_MODE_WRITE,
773+
.path = "-",
774+
.mode = PERF_DATA_MODE_WRITE,
777775
},
778776
};
779777
struct perf_data data = {
@@ -786,7 +784,7 @@ int cmd_inject(int argc, const char **argv)
786784
"Inject build-ids into the output stream"),
787785
OPT_STRING('i', "input", &inject.input_name, "file",
788786
"input file name"),
789-
OPT_STRING('o', "output", &inject.output.file.path, "file",
787+
OPT_STRING('o', "output", &inject.output.path, "file",
790788
"output file name"),
791789
OPT_BOOLEAN('s', "sched-stat", &inject.sched_stat,
792790
"Merge sched-stat and sched-switch for getting events "
@@ -834,7 +832,7 @@ int cmd_inject(int argc, const char **argv)
834832

835833
inject.tool.ordered_events = inject.sched_stat;
836834

837-
data.file.path = inject.input_name;
835+
data.path = inject.input_name;
838836
inject.session = perf_session__new(&data, true, &inject.tool);
839837
if (inject.session == NULL)
840838
return -1;

‎tools/perf/builtin-kmem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,7 @@ int cmd_kmem(int argc, const char **argv)
19491949
return __cmd_record(argc, argv);
19501950
}
19511951

1952-
data.file.path = input_name;
1952+
data.path = input_name;
19531953

19541954
kmem_session = session = perf_session__new(&data, false, &perf_kmem);
19551955
if (session == NULL)

‎tools/perf/builtin-kvm.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,11 +1080,9 @@ static int read_events(struct perf_kvm_stat *kvm)
10801080
.ordered_events = true,
10811081
};
10821082
struct perf_data file = {
1083-
.file = {
1084-
.path = kvm->file_name,
1085-
},
1086-
.mode = PERF_DATA_MODE_READ,
1087-
.force = kvm->force,
1083+
.path = kvm->file_name,
1084+
.mode = PERF_DATA_MODE_READ,
1085+
.force = kvm->force,
10881086
};
10891087

10901088
kvm->tool = eops;

‎tools/perf/builtin-lock.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -866,11 +866,9 @@ static int __cmd_report(bool display_info)
866866
.ordered_events = true,
867867
};
868868
struct perf_data data = {
869-
.file = {
870-
.path = input_name,
871-
},
872-
.mode = PERF_DATA_MODE_READ,
873-
.force = force,
869+
.path = input_name,
870+
.mode = PERF_DATA_MODE_READ,
871+
.force = force,
874872
};
875873

876874
session = perf_session__new(&data, false, &eops);

0 commit comments

Comments
 (0)