Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1697172 > unrolled thread
| Started by | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| First post | 2017-07-26 16:20 +0200 |
| Last post | 2017-07-26 19:20 +0200 |
| Articles | 8 on this page of 28 — 2 participants |
Back to article view | Back to linux.kernel
[GIT PULL 00/40] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:20 +0200
[PATCH 15/40] tools include: Adopt strstarts() from the kernel Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:20 +0200
[PATCH 30/40] perf script: Remove some bogus error handling Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 39/40] perf annotate stdio: Fix column header when using --show-total-period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 33/40] perf script python: Add sample_read to dict Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 22/40] perf annotate stdio: Fix --show-total-period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 40/40] perf tools: Add tools/include/uapi/asm-generic/fcntl.h to the MANIFEST Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 38/40] perf jevents: Make build fail on JSON parse error Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 36/40] perf report: Make --branch-history work without callgraphs(-g) option in perf record Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 26/40] perf annotate: Process tracing data in pipe mode Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 29/40] perf top: Support lookup of symbols in other mount namespaces. Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 32/40] perf script python: Refactor creation of perf sample dict Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 23/40] perf report: Fix kernel symbol adjustment for s390x Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 28/40] perf evsel: Add verbose output for sys_perf_event_open fallback Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 35/40] perf script python: Generate hooks with additional argument Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 21/40] perf annotate: Do not overwrite sample->period Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 27/40] perf jvmti: Fix linker error when libelf config is disabled Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 31/40] perf script python: Allocate memory only if handler exists Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 34/40] perf script python: Add perf_sample dict to tracepoint handlers Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 25/40] perf tools: Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 24/40] perf cgroup: Fix refcount usage Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 37/40] perf report: Tag branch type/flag on "to" and tag cycles on "from" Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:30 +0200
[PATCH 03/40] perf trace: Add missing ' = ' in the default formatting of syscall returns Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
[PATCH 05/40] perf trace: Allow allocating sc->arg_fmt even without the syscall tracepoint Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
[PATCH 01/40] perf intel-pt: Set no_aux_samples for the tracking event Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
[PATCH 04/40] perf trace beauty mmap: Ignore 'fd' and 'offset' args for MAP_ANONYMOUS Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
[PATCH 17/40] perf annotate: Introduce struct sym_hist_entry Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-26 16:40 +0200
Re: [GIT PULL 00/40] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2017-07-26 19:20 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:30 +0200 |
| Subject | [PATCH 24/40] perf cgroup: Fix refcount usage |
| Message-ID | <u7vu4-1s1-81@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
When converting from atomic_t to refcount_t we didn't follow the usual
step of initializing it to one before taking any new reference, which
trips over checking if taking a reference for a freed refcount_t, fix
it.
Brendan's report:
---
It's 4.12-rc7, with node v4.4.1. I'm building 4.13-rc1 now, as I hit
what I think is another unrelated perf bug and I'm starting to wonder
what else is broken on that version:
(root) /mnt/src/linux-4.12-rc7/tools/perf # ./perf record -F 99 -a -e
cpu-clock --cgroup=docker/f9e9d5df065b14646e8a11edc837a13877fd90c171137b2ba3feb67a0201cb65
-g
perf: /mnt/src/linux-4.12-rc7/tools/include/linux/refcount.h:108:
refcount_inc: Assertion `!(!refcount_inc_not_zero(r))' failed.
Aborted
that used to work...
---
Testing it:
Before:
# perf stat -e cycles -C 0 --cgroup /
perf: /home/acme/git/linux/tools/include/linux/refcount.h:108: refcount_inc: Assertion `!(!refcount_inc_not_zero(r))' failed.
Aborted (core dumped)
#
After:
# perf stat -e cycles -C 0 --cgroup /
^C
Performance counter stats for 'CPU(s) 0':
132,081,393 cycles /
2.492942763 seconds time elapsed
#
Reported-by: Brendan Gregg <brendan.d.gregg@gmail.com>
Acked-by: Elena Reshetova <elena.reshetova@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: David Carrillo-Cisneros <davidcc@google.com>
Cc: Kees Kook <keescook@chromium.org>
Cc: Krister Johansen <kjlx@templeofstupid.com>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sudeep Holla <Sudeep.Holla@arm.com>
Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 79c5fe6db8c7 ("perf cgroup: Convert cgroup_sel.refcnt from atomic_t to refcount_t")
Link: http://lkml.kernel.org/n/tip-l7ovfblq14ip2i08m1g0fkhv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/cgroup.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index 03347748f3fa..0e77bc9e5f3c 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -98,8 +98,10 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
cgrp = counter->cgrp;
if (!cgrp)
continue;
- if (!strcmp(cgrp->name, str))
+ if (!strcmp(cgrp->name, str)) {
+ refcount_inc(&cgrp->refcnt);
break;
+ }
cgrp = NULL;
}
@@ -110,6 +112,7 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
return -1;
cgrp->name = str;
+ refcount_set(&cgrp->refcnt, 1);
cgrp->fd = open_cgroup(str);
if (cgrp->fd == -1) {
@@ -128,12 +131,11 @@ static int add_cgroup(struct perf_evlist *evlist, char *str)
goto found;
n++;
}
- if (refcount_read(&cgrp->refcnt) == 0)
+ if (refcount_dec_and_test(&cgrp->refcnt))
free(cgrp);
return -1;
found:
- refcount_inc(&cgrp->refcnt);
counter->cgrp = cgrp;
return 0;
}
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:30 +0200 |
| Subject | [PATCH 37/40] perf report: Tag branch type/flag on "to" and tag cycles on "from" |
| Message-ID | <u7vu5-1s1-107@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Jin Yao <yao.jin@linux.intel.com>
Current --branch-history LBR annotation displays confused data. For
example, each cycles report is duplicated on both "from" and "to"
entries.
For example:
perf report --branch-history --no-children --stdio
--2.32%--main div.c:39 (COND_BWD CROSS_2M predicted:49.7% cycles:1)
main div.c:44 (predicted:49.7% cycles:1)
main div.c:42 (RET CROSS_2M cycles:2)
compute_flag div.c:28 (cycles:2)
compute_flag div.c:27 (RET CROSS_2M cycles:1)
rand rand.c:28 (cycles:1)
rand rand.c:28 (RET CROSS_2M cycles:1)
__random random.c:298 (cycles:1)
__random random.c:297 (COND_BWD CROSS_2M cycles:1)
__random random.c:295 (cycles:1)
__random random.c:295 (COND_BWD CROSS_2M cycles:1)
__random random.c:295 (cycles:1)
__random random.c:295 (RET CROSS_2M cycles:9)
The cycles should be tagged only on the "from". It's for the code block
that ends with "from", not for "to".
Another issue is the "predicted:49.7%" is duplicated too (tag on both
"from" and "to").
This patch tags the branch type/flag on "to" and tag the cycles on
"from".
For example:
--2.32%--main div.c:39 (COND_BWD CROSS_2M predicted:49.7%)
main div.c:44 (cycles:1)
main div.c:42 (RET CROSS_2M)
compute_flag div.c:28 (cycles:2)
compute_flag div.c:27 (RET CROSS_2M)
rand rand.c:28 (cycles:1)
rand rand.c:28 (RET CROSS_2M)
__random random.c:298 (cycles:1)
__random random.c:297 (COND_BWD CROSS_2M)
__random random.c:295 (cycles:1)
__random random.c:295 (COND_BWD CROSS_2M)
__random random.c:295 (cycles:1)
__random random.c:295 (RET CROSS_2M)
|
--2.23%--__random_r random_r.c:392 (cycles:9)
In this example, The "main div.c:39 (COND_BWD CROSS_2M predicted:49.7%)"
is "to" of branch and "main div.c:44 (cycles:1)" is "from" of branch.
It should be easier for understanding than before.
Signed-off-by: Yao Jin <yao.jin@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1500894547-18411-1-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/branch.h | 11 ++--
tools/perf/util/callchain.c | 148 +++++++++++++++++++++++++++++++-------------
2 files changed, 111 insertions(+), 48 deletions(-)
diff --git a/tools/perf/util/branch.h b/tools/perf/util/branch.h
index 686f2b65ba84..1e3c7c5cdc63 100644
--- a/tools/perf/util/branch.h
+++ b/tools/perf/util/branch.h
@@ -5,11 +5,12 @@
#include "../perf.h"
struct branch_type_stat {
- u64 counts[PERF_BR_MAX];
- u64 cond_fwd;
- u64 cond_bwd;
- u64 cross_4k;
- u64 cross_2m;
+ bool branch_to;
+ u64 counts[PERF_BR_MAX];
+ u64 cond_fwd;
+ u64 cond_bwd;
+ u64 cross_4k;
+ u64 cross_2m;
};
struct branch_flags;
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 1f536418dfb5..f320b0777e0d 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -563,20 +563,33 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
if (cursor_node->branch) {
call->branch_count = 1;
- if (cursor_node->branch_flags.predicted)
- call->predicted_count = 1;
-
- if (cursor_node->branch_flags.abort)
- call->abort_count = 1;
-
- call->cycles_count = cursor_node->branch_flags.cycles;
- call->iter_count = cursor_node->nr_loop_iter;
- call->samples_count = cursor_node->samples;
-
- branch_type_count(&call->brtype_stat,
- &cursor_node->branch_flags,
- cursor_node->branch_from,
- cursor_node->ip);
+ if (cursor_node->branch_from) {
+ /*
+ * branch_from is set with value somewhere else
+ * to imply it's "to" of a branch.
+ */
+ call->brtype_stat.branch_to = true;
+
+ if (cursor_node->branch_flags.predicted)
+ call->predicted_count = 1;
+
+ if (cursor_node->branch_flags.abort)
+ call->abort_count = 1;
+
+ branch_type_count(&call->brtype_stat,
+ &cursor_node->branch_flags,
+ cursor_node->branch_from,
+ cursor_node->ip);
+ } else {
+ /*
+ * It's "from" of a branch
+ */
+ call->brtype_stat.branch_to = false;
+ call->cycles_count =
+ cursor_node->branch_flags.cycles;
+ call->iter_count = cursor_node->nr_loop_iter;
+ call->samples_count = cursor_node->samples;
+ }
}
list_add_tail(&call->list, &node->val);
@@ -685,20 +698,32 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
if (node->branch) {
cnode->branch_count++;
- if (node->branch_flags.predicted)
- cnode->predicted_count++;
-
- if (node->branch_flags.abort)
- cnode->abort_count++;
-
- cnode->cycles_count += node->branch_flags.cycles;
- cnode->iter_count += node->nr_loop_iter;
- cnode->samples_count += node->samples;
-
- branch_type_count(&cnode->brtype_stat,
- &node->branch_flags,
- node->branch_from,
- node->ip);
+ if (node->branch_from) {
+ /*
+ * It's "to" of a branch
+ */
+ cnode->brtype_stat.branch_to = true;
+
+ if (node->branch_flags.predicted)
+ cnode->predicted_count++;
+
+ if (node->branch_flags.abort)
+ cnode->abort_count++;
+
+ branch_type_count(&cnode->brtype_stat,
+ &node->branch_flags,
+ node->branch_from,
+ node->ip);
+ } else {
+ /*
+ * It's "from" of a branch
+ */
+ cnode->brtype_stat.branch_to = false;
+ cnode->cycles_count +=
+ node->branch_flags.cycles;
+ cnode->iter_count += node->nr_loop_iter;
+ cnode->samples_count += node->samples;
+ }
}
return MATCH_EQ;
@@ -1236,27 +1261,26 @@ static int count_pri64_printf(int idx, const char *str, u64 value, char *bf, int
return printed;
}
-static int count_float_printf(int idx, const char *str, float value, char *bf, int bfsize)
+static int count_float_printf(int idx, const char *str, float value,
+ char *bf, int bfsize, float threshold)
{
int printed;
+ if (threshold != 0.0 && value < threshold)
+ return 0;
+
printed = scnprintf(bf, bfsize, "%s%s:%.1f%%", (idx) ? " " : " (", str, value);
return printed;
}
-static int counts_str_build(char *bf, int bfsize,
- u64 branch_count, u64 predicted_count,
- u64 abort_count, u64 cycles_count,
- u64 iter_count, u64 samples_count,
- struct branch_type_stat *brtype_stat)
+static int branch_to_str(char *bf, int bfsize,
+ u64 branch_count, u64 predicted_count,
+ u64 abort_count,
+ struct branch_type_stat *brtype_stat)
{
- u64 cycles;
int printed, i = 0;
- if (branch_count == 0)
- return scnprintf(bf, bfsize, " (calltrace)");
-
printed = branch_type_str(brtype_stat, bf, bfsize);
if (printed)
i++;
@@ -1264,15 +1288,29 @@ static int counts_str_build(char *bf, int bfsize,
if (predicted_count < branch_count) {
printed += count_float_printf(i++, "predicted",
predicted_count * 100.0 / branch_count,
- bf + printed, bfsize - printed);
+ bf + printed, bfsize - printed, 0.0);
}
if (abort_count) {
printed += count_float_printf(i++, "abort",
abort_count * 100.0 / branch_count,
- bf + printed, bfsize - printed);
+ bf + printed, bfsize - printed, 0.1);
}
+ if (i)
+ printed += scnprintf(bf + printed, bfsize - printed, ")");
+
+ return printed;
+}
+
+static int branch_from_str(char *bf, int bfsize,
+ u64 branch_count,
+ u64 cycles_count, u64 iter_count,
+ u64 samples_count)
+{
+ int printed = 0, i = 0;
+ u64 cycles;
+
cycles = cycles_count / branch_count;
if (cycles) {
printed += count_pri64_printf(i++, "cycles",
@@ -1287,10 +1325,34 @@ static int counts_str_build(char *bf, int bfsize,
}
if (i)
- return scnprintf(bf + printed, bfsize - printed, ")");
+ printed += scnprintf(bf + printed, bfsize - printed, ")");
- bf[0] = 0;
- return 0;
+ return printed;
+}
+
+static int counts_str_build(char *bf, int bfsize,
+ u64 branch_count, u64 predicted_count,
+ u64 abort_count, u64 cycles_count,
+ u64 iter_count, u64 samples_count,
+ struct branch_type_stat *brtype_stat)
+{
+ int printed;
+
+ if (branch_count == 0)
+ return scnprintf(bf, bfsize, " (calltrace)");
+
+ if (brtype_stat->branch_to) {
+ printed = branch_to_str(bf, bfsize, branch_count,
+ predicted_count, abort_count, brtype_stat);
+ } else {
+ printed = branch_from_str(bf, bfsize, branch_count,
+ cycles_count, iter_count, samples_count);
+ }
+
+ if (!printed)
+ bf[0] = 0;
+
+ return printed;
}
static int callchain_counts_printf(FILE *fp, char *bf, int bfsize,
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:40 +0200 |
| Subject | [PATCH 03/40] perf trace: Add missing ' = ' in the default formatting of syscall returns |
| Message-ID | <u7vDH-1vq-9@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Arnaldo Carvalho de Melo <acme@redhat.com>
We lost it recently, put it back.
Before:
789.499 ( 0.001 ms): libvirtd/1175 lseek(fd: 22, whence: CUR) 4328
After:
789.499 ( 0.001 ms): libvirtd/1175 lseek(fd: 22, whence: CUR) = 4328
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 1f63139c3f8a ("perf trace beauty: Simplify syscall return formatting")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 1e4c0657b712..4370ce4f28c7 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1660,7 +1660,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
if (ret < 0)
goto errno_print;
signed_print:
- fprintf(trace->output, ") %ld", ret);
+ fprintf(trace->output, ") = %ld", ret);
} else if (ret < 0) {
errno_print: {
char bf[STRERR_BUFSIZE];
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:40 +0200 |
| Subject | [PATCH 05/40] perf trace: Allow allocating sc->arg_fmt even without the syscall tracepoint |
| Message-ID | <u7vDI-1vq-17@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Arnaldo Carvalho de Melo <acme@redhat.com>
At least "clone" doesn't have (enter, exit) entries tracefs/events/syscalls/,
but we can provide a syscall_fmt and use it instead, as will be done for
"clone" in the next cset.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-o12kejgcxddyovn2hlg4gbim@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-trace.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4370ce4f28c7..1c5238af6d14 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1165,22 +1165,31 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
return err;
}
-static int syscall__set_arg_fmts(struct syscall *sc)
+static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args)
{
- struct format_field *field;
- int idx = 0, len;
+ int idx;
- sc->arg_fmt = calloc(sc->nr_args, sizeof(*sc->arg_fmt));
+ sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt));
if (sc->arg_fmt == NULL)
return -1;
- for (field = sc->args; field; field = field->next, ++idx) {
- if (sc->fmt) {
+ for (idx = 0; idx < nr_args; ++idx) {
+ if (sc->fmt)
sc->arg_fmt[idx] = sc->fmt->arg[idx];
+ }
- if (sc->fmt->arg[idx].scnprintf)
- continue;
- }
+ sc->nr_args = nr_args;
+ return 0;
+}
+
+static int syscall__set_arg_fmts(struct syscall *sc)
+{
+ struct format_field *field;
+ int idx = 0, len;
+
+ for (field = sc->args; field; field = field->next, ++idx) {
+ if (sc->fmt && sc->fmt->arg[idx].scnprintf)
+ continue;
if (strcmp(field->type, "const char *") == 0 &&
(strcmp(field->name, "filename") == 0 ||
@@ -1251,11 +1260,13 @@ static int trace__read_syscall_info(struct trace *trace, int id)
sc->tp_format = trace_event__tp_format("syscalls", tp_name);
}
+ if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? 6 : sc->tp_format->format.nr_fields))
+ return -1;
+
if (IS_ERR(sc->tp_format))
return -1;
sc->args = sc->tp_format->format.fields;
- sc->nr_args = sc->tp_format->format.nr_fields;
/*
* We need to check and discard the first variable '__syscall_nr'
* or 'nr' that mean the syscall number. It is needless here.
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:40 +0200 |
| Subject | [PATCH 01/40] perf intel-pt: Set no_aux_samples for the tracking event |
| Message-ID | <u7vDI-1vq-23@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Kan Liang <kan.liang@intel.com> The reason of introducing the tracking event (a dummy software event) is to collect side-band information. Additional sampling is wasteful. no_aux_samples should be set for tracking event. Signed-off-by: Kan Liang <kan.liang@intel.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20170630141656.1626-1-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/arch/x86/util/intel-pt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index 9535be57033f..4a461e8ae326 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c @@ -752,6 +752,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, tracking_evsel->attr.freq = 0; tracking_evsel->attr.sample_period = 1; + tracking_evsel->no_aux_samples = true; if (need_immediate) tracking_evsel->immediate = true; -- 2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:40 +0200 |
| Subject | [PATCH 04/40] perf trace beauty mmap: Ignore 'fd' and 'offset' args for MAP_ANONYMOUS |
| Message-ID | <u7vDI-1vq-25@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Just suppress them, not used by the kernel.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-atpt07y2x9a8ttlwja94ow3j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/trace/beauty/mmap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace/beauty/mmap.c
index af1cfde6b97b..754558f9009d 100644
--- a/tools/perf/trace/beauty/mmap.c
+++ b/tools/perf/trace/beauty/mmap.c
@@ -34,6 +34,9 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
{
int printed = 0, flags = arg->val;
+ if (flags & MAP_ANONYMOUS)
+ arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */
+
#define P_MMAP_FLAG(n) \
if (flags & MAP_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2017-07-26 16:40 +0200 |
| Subject | [PATCH 17/40] perf annotate: Introduce struct sym_hist_entry |
| Message-ID | <u7vDJ-1vq-63@gated-at.bofh.it> |
| In reply to | #1697172 |
From: Taeung Song <treeze.taeung@gmail.com>
struct sym_hist has addr[] but it should have not only number of samples
but also the sample period. So use new struct symhist_entry to pave the
way to have that.
Committer notes:
This initial patch will only introduce the struct sym_hist_entry and use
only the nr_samples member, which makes the code clearer and paves the
way to save the period as well.
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1500500205-16553-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/ui/browsers/annotate.c | 6 +++---
tools/perf/ui/gtk/annotate.c | 4 ++--
tools/perf/util/annotate.c | 45 ++++++++++++++++++++-------------------
tools/perf/util/annotate.h | 9 ++++++--
4 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6794a8bec404..dbe4e630b90f 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -450,14 +450,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
next = disasm__get_next_ip_line(¬es->src->source, pos);
for (i = 0; i < browser->nr_events; i++) {
- u64 nr_samples;
+ struct sym_hist_entry sample;
bpos->samples[i].percent = disasm__calc_percent(notes,
evsel->idx + i,
pos->offset,
next ? next->offset : len,
- &path, &nr_samples);
- bpos->samples[i].nr = nr_samples;
+ &path, &sample);
+ bpos->samples[i].nr = sample.nr_samples;
if (max_percent < bpos->samples[i].percent)
max_percent = bpos->samples[i].percent;
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index 87e3760624f2..d736fd57ab9b 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -34,10 +34,10 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,
return 0;
symhist = annotation__histogram(symbol__annotation(sym), evidx);
- if (!symbol_conf.event_group && !symhist->addr[dl->offset])
+ if (!symbol_conf.event_group && !symhist->addr[dl->offset].nr_samples)
return 0;
- percent = 100.0 * symhist->addr[dl->offset] / symhist->sum;
+ percent = 100.0 * symhist->addr[dl->offset].nr_samples / symhist->sum;
markup = perf_gtk__get_percent_color(percent);
if (markup)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 1742510f0120..c3829555ce1c 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -610,10 +610,10 @@ int symbol__alloc_hist(struct symbol *sym)
size_t sizeof_sym_hist;
/* Check for overflow when calculating sizeof_sym_hist */
- if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(u64))
+ if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
return -1;
- sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(u64));
+ sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(struct sym_hist_entry));
/* Check for overflow in zalloc argument */
if (sizeof_sym_hist > (SIZE_MAX - sizeof(*notes->src))
@@ -714,11 +714,11 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
offset = addr - sym->start;
h = annotation__histogram(notes, evidx);
h->sum++;
- h->addr[offset]++;
+ h->addr[offset].nr_samples++;
pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
", evidx=%d] => %" PRIu64 "\n", sym->start, sym->name,
- addr, addr - sym->start, evidx, h->addr[offset]);
+ addr, addr - sym->start, evidx, h->addr[offset].nr_samples);
return 0;
}
@@ -928,11 +928,12 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa
}
double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
- s64 end, const char **path, u64 *nr_samples)
+ s64 end, const char **path, struct sym_hist_entry *sample)
{
struct source_line *src_line = notes->src->lines;
double percent = 0.0;
- *nr_samples = 0;
+
+ sample->nr_samples = 0;
if (src_line) {
size_t sizeof_src_line = sizeof(*src_line) +
@@ -946,7 +947,7 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
*path = src_line->path;
percent += src_line->samples[evidx].percent;
- *nr_samples += src_line->samples[evidx].nr;
+ sample->nr_samples += src_line->samples[evidx].nr;
offset++;
}
} else {
@@ -954,10 +955,10 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
unsigned int hits = 0;
while (offset < end)
- hits += h->addr[offset++];
+ hits += h->addr[offset++].nr_samples;
if (h->sum) {
- *nr_samples = hits;
+ sample->nr_samples = hits;
percent = 100.0 * hits / h->sum;
}
}
@@ -1057,10 +1058,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
if (dl->offset != -1) {
const char *path = NULL;
- u64 nr_samples;
double percent, max_percent = 0.0;
double *ppercents = &percent;
- u64 *psamples = &nr_samples;
+ struct sym_hist_entry sample;
+ struct sym_hist_entry *psamples = &sample;
int i, nr_percent = 1;
const char *color;
struct annotation *notes = symbol__annotation(sym);
@@ -1074,7 +1075,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
if (perf_evsel__is_group_event(evsel)) {
nr_percent = evsel->nr_members;
ppercents = calloc(nr_percent, sizeof(double));
- psamples = calloc(nr_percent, sizeof(u64));
+ psamples = calloc(nr_percent, sizeof(struct sym_hist_entry));
if (ppercents == NULL || psamples == NULL) {
return -1;
}
@@ -1085,10 +1086,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
notes->src->lines ? i : evsel->idx + i,
offset,
next ? next->offset : (s64) len,
- &path, &nr_samples);
+ &path, &sample);
ppercents[i] = percent;
- psamples[i] = nr_samples;
+ psamples[i] = sample;
if (percent > max_percent)
max_percent = percent;
}
@@ -1126,12 +1127,12 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
for (i = 0; i < nr_percent; i++) {
percent = ppercents[i];
- nr_samples = psamples[i];
+ sample = psamples[i];
color = get_percent_color(percent);
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %7" PRIu64,
- nr_samples);
+ sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
@@ -1147,7 +1148,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
if (ppercents != &percent)
free(ppercents);
- if (psamples != &nr_samples)
+ if (psamples != &sample)
free(psamples);
} else if (max_lines && printed >= max_lines)
@@ -1702,7 +1703,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
double percent = 0.0;
h = annotation__histogram(notes, evidx + k);
- nr_samples = h->addr[i];
+ nr_samples = h->addr[i].nr_samples;
if (h->sum)
percent = 100.0 * nr_samples / h->sum;
@@ -1773,9 +1774,9 @@ static void symbol__annotate_hits(struct symbol *sym, struct perf_evsel *evsel)
u64 len = symbol__size(sym), offset;
for (offset = 0; offset < len; ++offset)
- if (h->addr[offset] != 0)
+ if (h->addr[offset].nr_samples != 0)
printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
- sym->start + offset, h->addr[offset]);
+ sym->start + offset, h->addr[offset].nr_samples);
printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
}
@@ -1878,8 +1879,8 @@ void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
h->sum = 0;
for (offset = 0; offset < len; ++offset) {
- h->addr[offset] = h->addr[offset] * 7 / 8;
- h->sum += h->addr[offset];
+ h->addr[offset].nr_samples = h->addr[offset].nr_samples * 7 / 8;
+ h->sum += h->addr[offset].nr_samples;
}
}
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index bac698d7cc6a..3a176633b324 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -74,16 +74,21 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl)
return dl->ops.target.offset_avail;
}
+struct sym_hist_entry {
+ u64 nr_samples;
+ u64 period;
+};
+
void disasm_line__free(struct disasm_line *dl);
struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos);
int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
size_t disasm__fprintf(struct list_head *head, FILE *fp);
double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
- s64 end, const char **path, u64 *nr_samples);
+ s64 end, const char **path, struct sym_hist_entry *sample);
struct sym_hist {
u64 sum;
- u64 addr[0];
+ struct sym_hist_entry addr[0];
};
struct cyc_hist {
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2017-07-26 19:20 +0200 |
| Message-ID | <u7y8z-3b6-47@gated-at.bofh.it> |
| In reply to | #1697172 |
* Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > Hi Ingo, > > Please consider pulling, > > - Arnaldo > > Test results at the end of this message, as usual. > > The following changes since commit 510457ec9dc259b002879bcfe475f89d4514a0fc: > > Merge tag 'perf-core-for-mingo-4.13-20170718' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2017-07-20 10:31:52 +0200) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-4.14-20170725 > > for you to fetch changes up to 62e6039f02888efdd824e8c596c4927616a97ce3: > > perf tools: Add tools/include/uapi/asm-generic/fcntl.h to the MANIFEST (2017-07-25 22:46:37 -0300) > > ---------------------------------------------------------------- > perf/core improvemends and fixes for v4.14: > > New features: > > - Filter out 'sshd' in the tracer ancestry in 'perf trace' syswide tracing, > to elliminate tracing loops (Arnaldo Carvalho de Melo) > > - Support lookup of symbols in other mount namespaces in 'perf top' (Krister Johansen) > > - Initial 'clone' syscall args beautifier in 'perf trace' (Arnaldo Carvalho de Melo) > > User visible: > > - Ignore 'fd' and 'offset' args for MAP_ANONYMOUS in 'perf trace' > (Arnaldo Carvalho de Melo) > > - Process tracing data in 'perf annotate' pipe mode (David Carrillo-Cisneros) > > - Make 'perf report --branch-history' work without callgraphs(-g) option > in perf record (Jin Yao) > > - Tag branch type/flag on "to" and tag cycles on "from" in 'perf report' (Jin Yao) > > Fixes: > > - Fix jvmti linker error when libelf config is disabled (Sudeep Holla) > > - Fix cgroups refcount usage (Arnaldo Carvalho de Melo) > > - Fix kernel symbol adjustment for s390x (Thomas Richter) > > - Fix 'perf report --stdio --show-total-period', it was showing the > number of samples, not the total period (Taeung Song) > > Infrastructure: > > - Add perf_sample dictionary to tracepoint handlers in 'perf script' > python, which were already present for other types of events > (hardware, etc) (Arun Kalyanasundaram) > > - Make build fail on vendor events JSON parse error (Andi Kleen) > > - Adopt strstarts() from the kernel (Arnaldo Carvalho de Melo) > > Arch specific: > > - Set no_aux_samples for the tracking event in Intel PT (Kan Liang) > > - Always set no branch for Intel PT dummy event (Kan Liang) > > Trivial: > > - Simplify some error handlers in 'perf script' (Dan Carpenter) > > - Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile (David Carrillo-Cisneros) > > ---------------------------------------------------------------- > Andi Kleen (1): > perf jevents: Make build fail on JSON parse error > > Arnaldo Carvalho de Melo (16): > perf trace: Add missing ' = ' in the default formatting of syscall returns > perf trace beauty mmap: Ignore 'fd' and 'offset' args for MAP_ANONYMOUS > perf trace: Allow allocating sc->arg_fmt even without the syscall tracepoint > perf trace: Use the syscall_fmt formatters without a tracepoint > perf trace: Ditch __syscall__arg_val() variant, not needed anymore > perf trace: Allow specifying number of syscall args for tracepointless syscalls > perf trace: Allow specifying names to syscall arguments formatters > tools include uapi: Grab a copy of linux/sched.h > perf trace beauty clone: Beautify syscall arguments > perf trace beauty clone: Suppress unused args according to 'flags' arg > perf trace: Introduce filter_loop_pids() > perf trace: Filter out 'sshd' in the tracer ancestry in syswide tracing > tools include: Adopt strstarts() from the kernel > tools lib: Update copy of strtobool from the kernel sources > perf cgroup: Fix refcount usage > perf tools: Add tools/include/uapi/asm-generic/fcntl.h to the MANIFEST > > Arun Kalyanasundaram (5): > perf script python: Allocate memory only if handler exists > perf script python: Refactor creation of perf sample dict > perf script python: Add sample_read to dict > perf script python: Add perf_sample dict to tracepoint handlers > perf script python: Generate hooks with additional argument > > Dan Carpenter (1): > perf script: Remove some bogus error handling > > David Carrillo-Cisneros (2): > perf tools: Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile > perf annotate: Process tracing data in pipe mode > > Jin Yao (2): > perf report: Make --branch-history work without callgraphs(-g) option in perf record > perf report: Tag branch type/flag on "to" and tag cycles on "from" > > Jiri Olsa (1): > perf evsel: Add verbose output for sys_perf_event_open fallback > > Kan Liang (2): > perf intel-pt: Set no_aux_samples for the tracking event > perf intel-pt: Always set no branch for dummy event > > Krister Johansen (1): > perf top: Support lookup of symbols in other mount namespaces. > > Sudeep Holla (1): > perf jvmti: Fix linker error when libelf config is disabled > > Taeung Song (7): > perf annotate: Introduce struct sym_hist_entry > perf annotate: Rename 'sum' to 'nr_samples' in struct sym_hist > perf hists: Pass perf_sample to __symbol__inc_addr_samples() > perf annotate: Store the sample period in each histogram bucket > perf annotate: Do not overwrite sample->period > perf annotate stdio: Fix --show-total-period > perf annotate stdio: Fix column header when using --show-total-period > > Thomas Richter (1): > perf report: Fix kernel symbol adjustment for s390x > > tools/include/linux/string.h | 12 +- > tools/include/uapi/linux/sched.h | 52 +++++ > tools/lib/string.c | 41 ++-- > tools/lib/subcmd/help.c | 2 +- > tools/lib/subcmd/parse-options.c | 18 +- > tools/perf/Documentation/perf-top.txt | 4 + > tools/perf/MANIFEST | 2 + > tools/perf/Makefile.perf | 10 +- > tools/perf/arch/s390/util/Build | 1 + > tools/perf/arch/s390/util/sym-handling.c | 22 ++ > tools/perf/arch/x86/util/intel-pt.c | 3 + > tools/perf/builtin-annotate.c | 4 +- > tools/perf/builtin-config.c | 3 +- > tools/perf/builtin-ftrace.c | 2 +- > tools/perf/builtin-help.c | 6 +- > tools/perf/builtin-report.c | 27 ++- > tools/perf/builtin-script.c | 7 +- > tools/perf/builtin-top.c | 20 +- > tools/perf/builtin-trace.c | 140 ++++++++---- > tools/perf/check-headers.sh | 1 + > tools/perf/perf.c | 16 +- > tools/perf/pmu-events/README | 4 - > tools/perf/pmu-events/jevents.c | 21 +- > tools/perf/trace/beauty/Build | 1 + > tools/perf/trace/beauty/beauty.h | 3 + > tools/perf/trace/beauty/clone.c | 75 +++++++ > tools/perf/trace/beauty/mmap.c | 3 + > tools/perf/ui/browser.c | 3 +- > tools/perf/ui/browsers/annotate.c | 9 +- > tools/perf/ui/gtk/annotate.c | 4 +- > tools/perf/ui/stdio/hist.c | 3 +- > tools/perf/util/annotate.c | 99 +++++---- > tools/perf/util/annotate.h | 18 +- > tools/perf/util/bpf-loader.c | 2 +- > tools/perf/util/branch.h | 11 +- > tools/perf/util/callchain.c | 157 +++++++++---- > tools/perf/util/cgroup.c | 8 +- > tools/perf/util/config.c | 13 +- > tools/perf/util/evsel.c | 8 + > tools/perf/util/hist.c | 2 + > tools/perf/util/llvm-utils.c | 2 +- > tools/perf/util/machine.c | 13 +- > .../util/scripting-engines/trace-event-python.c | 246 +++++++++++++++------ > 43 files changed, 798 insertions(+), 300 deletions(-) > create mode 100644 tools/include/uapi/linux/sched.h > create mode 100644 tools/perf/arch/s390/util/sym-handling.c > create mode 100644 tools/perf/trace/beauty/clone.c Pulled, thanks a lot Arnaldo! Ingo
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web