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>
This commit is contained in:
@@ -907,6 +907,78 @@ struct sort_entry sort_in_tx = {
|
||||
.se_width_idx = HISTC_IN_TX,
|
||||
};
|
||||
|
||||
static int64_t
|
||||
sort__transaction_cmp(struct hist_entry *left, struct hist_entry *right)
|
||||
{
|
||||
return left->transaction - right->transaction;
|
||||
}
|
||||
|
||||
static inline char *add_str(char *p, const char *str)
|
||||
{
|
||||
strcpy(p, str);
|
||||
return p + strlen(str);
|
||||
}
|
||||
|
||||
static struct txbit {
|
||||
unsigned flag;
|
||||
const char *name;
|
||||
int skip_for_len;
|
||||
} txbits[] = {
|
||||
{ PERF_TXN_ELISION, "EL ", 0 },
|
||||
{ PERF_TXN_TRANSACTION, "TX ", 1 },
|
||||
{ PERF_TXN_SYNC, "SYNC ", 1 },
|
||||
{ PERF_TXN_ASYNC, "ASYNC ", 0 },
|
||||
{ PERF_TXN_RETRY, "RETRY ", 0 },
|
||||
{ PERF_TXN_CONFLICT, "CON ", 0 },
|
||||
{ PERF_TXN_CAPACITY_WRITE, "CAP-WRITE ", 1 },
|
||||
{ PERF_TXN_CAPACITY_READ, "CAP-READ ", 0 },
|
||||
{ 0, NULL, 0 }
|
||||
};
|
||||
|
||||
int hist_entry__transaction_len(void)
|
||||
{
|
||||
int i;
|
||||
int len = 0;
|
||||
|
||||
for (i = 0; txbits[i].name; i++) {
|
||||
if (!txbits[i].skip_for_len)
|
||||
len += strlen(txbits[i].name);
|
||||
}
|
||||
len += 4; /* :XX<space> */
|
||||
return len;
|
||||
}
|
||||
|
||||
static int hist_entry__transaction_snprintf(struct hist_entry *self, char *bf,
|
||||
size_t size, unsigned int width)
|
||||
{
|
||||
u64 t = self->transaction;
|
||||
char buf[128];
|
||||
char *p = buf;
|
||||
int i;
|
||||
|
||||
buf[0] = 0;
|
||||
for (i = 0; txbits[i].name; i++)
|
||||
if (txbits[i].flag & t)
|
||||
p = add_str(p, txbits[i].name);
|
||||
if (t && !(t & (PERF_TXN_SYNC|PERF_TXN_ASYNC)))
|
||||
p = add_str(p, "NEITHER ");
|
||||
if (t & PERF_TXN_ABORT_MASK) {
|
||||
sprintf(p, ":%" PRIx64,
|
||||
(t & PERF_TXN_ABORT_MASK) >>
|
||||
PERF_TXN_ABORT_SHIFT);
|
||||
p += strlen(p);
|
||||
}
|
||||
|
||||
return repsep_snprintf(bf, size, "%-*s", width, buf);
|
||||
}
|
||||
|
||||
struct sort_entry sort_transaction = {
|
||||
.se_header = "Transaction ",
|
||||
.se_cmp = sort__transaction_cmp,
|
||||
.se_snprintf = hist_entry__transaction_snprintf,
|
||||
.se_width_idx = HISTC_TRANSACTION,
|
||||
};
|
||||
|
||||
struct sort_dimension {
|
||||
const char *name;
|
||||
struct sort_entry *entry;
|
||||
@@ -925,6 +997,7 @@ static struct sort_dimension common_sort_dimensions[] = {
|
||||
DIM(SORT_SRCLINE, "srcline", sort_srcline),
|
||||
DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
|
||||
DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
|
||||
DIM(SORT_TRANSACTION, "transaction", sort_transaction),
|
||||
};
|
||||
|
||||
#undef DIM
|
||||
|
||||
Reference in New Issue
Block a user