Skip to content

Commit 475eeab

Browse files
Andi Kleeningomolnar
authored andcommitted
tools/perf: Add support for record transaction flags
Add support for recording and displaying the transaction flags. They are essentially a new sort key. Also display them in a nice way to the user. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1379688044-14173-6-git-send-email-andi@firstfloor.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 0126d49 commit 475eeab

17 files changed

Lines changed: 122 additions & 15 deletions

‎tools/perf/Documentation/perf-record.txt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,14 @@ is enabled for all the sampling events. The sampled branch type is the same for
179179
The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
180180
Note that this feature may not be available on all processors.
181181

182-
-W::
183182
--weight::
184183
Enable weightened sampling. An additional weight is recorded per sample and can be
185184
displayed with the weight and local_weight sort keys. This currently works for TSX
186185
abort events and some memory events in precise mode on modern Intel CPUs.
187186

187+
--transaction::
188+
Record transaction flags for transaction related events.
189+
188190
SEE ALSO
189191
--------
190192
linkperf:perf-stat[1], linkperf:perf-list[1]

‎tools/perf/Documentation/perf-report.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ OPTIONS
7272
- cpu: cpu number the task ran at the time of sample
7373
- srcline: filename and line number executed at the time of sample. The
7474
DWARF debugging info must be provided.
75+
- weight: Event specific weight, e.g. memory latency or transaction
76+
abort cost. This is the global weight.
77+
- local_weight: Local weight version of the weight above.
78+
- transaction: Transaction abort flags.
7579

7680
By default, comm, dso and symbol keys are used.
7781
(i.e. --sort comm,dso,symbol)

‎tools/perf/Documentation/perf-top.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Default is to monitor all CPUS.
113113
-s::
114114
--sort::
115115
Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight,
116-
local_weight, abort, in_tx
116+
local_weight, abort, in_tx, transaction
117117

118118
-n::
119119
--show-nr-samples::

‎tools/perf/builtin-annotate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
6363
return 0;
6464
}
6565

66-
he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1);
66+
he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1, 0);
6767
if (he == NULL)
6868
return -ENOMEM;
6969

‎tools/perf/builtin-diff.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,10 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair,
304304

305305
static int hists__add_entry(struct hists *self,
306306
struct addr_location *al, u64 period,
307-
u64 weight)
307+
u64 weight, u64 transaction)
308308
{
309-
if (__hists__add_entry(self, al, NULL, period, weight) != NULL)
309+
if (__hists__add_entry(self, al, NULL, period, weight, transaction)
310+
!= NULL)
310311
return 0;
311312
return -ENOMEM;
312313
}
@@ -328,7 +329,8 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
328329
if (al.filtered)
329330
return 0;
330331

331-
if (hists__add_entry(&evsel->hists, &al, sample->period, sample->weight)) {
332+
if (hists__add_entry(&evsel->hists, &al, sample->period,
333+
sample->weight, sample->transaction)) {
332334
pr_warning("problem incrementing symbol period, skipping event\n");
333335
return -1;
334336
}

‎tools/perf/builtin-record.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,8 @@ const struct option record_options[] = {
894894
parse_branch_stack),
895895
OPT_BOOLEAN('W', "weight", &record.opts.sample_weight,
896896
"sample by weight (on special events only)"),
897+
OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
898+
"sample transaction flags (special events only)"),
897899
OPT_END()
898900
};
899901

‎tools/perf/builtin-report.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
259259
}
260260

261261
he = __hists__add_entry(&evsel->hists, al, parent, sample->period,
262-
sample->weight);
262+
sample->weight, sample->transaction);
263263
if (he == NULL)
264264
return -ENOMEM;
265265

@@ -787,7 +787,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
787787
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline,"
788788
" dso_to, dso_from, symbol_to, symbol_from, mispredict,"
789789
" weight, local_weight, mem, symbol_daddr, dso_daddr, tlb, "
790-
"snoop, locked, abort, in_tx"),
790+
"snoop, locked, abort, in_tx, transaction"),
791791
OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
792792
"Show sample percentage for different cpu modes"),
793793
OPT_STRING('p', "parent", &parent_pattern, "regex",

‎tools/perf/builtin-top.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
247247

248248
pthread_mutex_lock(&evsel->hists.lock);
249249
he = __hists__add_entry(&evsel->hists, al, NULL, sample->period,
250-
sample->weight);
250+
sample->weight, sample->transaction);
251251
pthread_mutex_unlock(&evsel->hists.lock);
252-
253252
if (he == NULL)
254253
return NULL;
255254

@@ -1104,7 +1103,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
11041103
"be more verbose (show counter open errors, etc)"),
11051104
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
11061105
"sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight,"
1107-
" abort, in_tx"),
1106+
" abort, in_tx, transaction"),
11081107
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
11091108
"Show a column with the number of samples"),
11101109
OPT_CALLBACK_DEFAULT('G', "call-graph", &top.record_opts,

‎tools/perf/perf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ struct perf_record_opts {
233233
u64 default_interval;
234234
u64 user_interval;
235235
u16 stack_dump_size;
236+
bool sample_transaction;
236237
};
237238

238239
#endif

‎tools/perf/tests/hists_link.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
222222
&sample) < 0)
223223
goto out;
224224

225-
he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1);
225+
he = __hists__add_entry(&evsel->hists, &al, NULL,
226+
1, 1, 0);
226227
if (he == NULL)
227228
goto out;
228229

@@ -244,7 +245,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
244245
&sample) < 0)
245246
goto out;
246247

247-
he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1);
248+
he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1,
249+
0);
248250
if (he == NULL)
249251
goto out;
250252

0 commit comments

Comments
 (0)