diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-03-24 14:03:19 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-03-24 15:05:31 -0400 |
commit | ef65e96e0762cb98d9abeb6737c721ca840f8092 (patch) | |
tree | 308c81e8496062feaea5af9641d5fef6f8023bce /tools/perf/builtin-trace.c | |
parent | c04dfafa6033ca2eddc56fe188017d9ae50414c9 (diff) |
perf trace: Fixup thread refcounting
In trace__vfs_getname() and when checking if a thread is filtered in
trace__process_sample() we were not dropping the reference obtained via
machine__findnew_thread(), fix it.
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-9gc470phavxwxv5d9w7ck8ev@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r-- | tools/perf/builtin-trace.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 2425605461fe..60053d49539b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1653,17 +1653,17 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel, | |||
1653 | 1653 | ||
1654 | ttrace = thread__priv(thread); | 1654 | ttrace = thread__priv(thread); |
1655 | if (!ttrace) | 1655 | if (!ttrace) |
1656 | goto out; | 1656 | goto out_put; |
1657 | 1657 | ||
1658 | filename_len = strlen(filename); | 1658 | filename_len = strlen(filename); |
1659 | if (filename_len == 0) | 1659 | if (filename_len == 0) |
1660 | goto out; | 1660 | goto out_put; |
1661 | 1661 | ||
1662 | if (ttrace->filename.namelen < filename_len) { | 1662 | if (ttrace->filename.namelen < filename_len) { |
1663 | char *f = realloc(ttrace->filename.name, filename_len + 1); | 1663 | char *f = realloc(ttrace->filename.name, filename_len + 1); |
1664 | 1664 | ||
1665 | if (f == NULL) | 1665 | if (f == NULL) |
1666 | goto out; | 1666 | goto out_put; |
1667 | 1667 | ||
1668 | ttrace->filename.namelen = filename_len; | 1668 | ttrace->filename.namelen = filename_len; |
1669 | ttrace->filename.name = f; | 1669 | ttrace->filename.name = f; |
@@ -1673,12 +1673,12 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel, | |||
1673 | ttrace->filename.pending_open = true; | 1673 | ttrace->filename.pending_open = true; |
1674 | 1674 | ||
1675 | if (!ttrace->filename.ptr) | 1675 | if (!ttrace->filename.ptr) |
1676 | goto out; | 1676 | goto out_put; |
1677 | 1677 | ||
1678 | entry_str_len = strlen(ttrace->entry_str); | 1678 | entry_str_len = strlen(ttrace->entry_str); |
1679 | remaining_space = trace__entry_str_size - entry_str_len - 1; /* \0 */ | 1679 | remaining_space = trace__entry_str_size - entry_str_len - 1; /* \0 */ |
1680 | if (remaining_space <= 0) | 1680 | if (remaining_space <= 0) |
1681 | goto out; | 1681 | goto out_put; |
1682 | 1682 | ||
1683 | if (filename_len > (size_t)remaining_space) { | 1683 | if (filename_len > (size_t)remaining_space) { |
1684 | filename += filename_len - remaining_space; | 1684 | filename += filename_len - remaining_space; |
@@ -1692,6 +1692,8 @@ static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel, | |||
1692 | 1692 | ||
1693 | ttrace->filename.ptr = 0; | 1693 | ttrace->filename.ptr = 0; |
1694 | ttrace->filename.entry_str_pos = 0; | 1694 | ttrace->filename.entry_str_pos = 0; |
1695 | out_put: | ||
1696 | thread__put(thread); | ||
1695 | out: | 1697 | out: |
1696 | return 0; | 1698 | return 0; |
1697 | } | 1699 | } |
@@ -1712,6 +1714,7 @@ static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evs | |||
1712 | 1714 | ||
1713 | ttrace->runtime_ms += runtime_ms; | 1715 | ttrace->runtime_ms += runtime_ms; |
1714 | trace->runtime_ms += runtime_ms; | 1716 | trace->runtime_ms += runtime_ms; |
1717 | out_put: | ||
1715 | thread__put(thread); | 1718 | thread__put(thread); |
1716 | return 0; | 1719 | return 0; |
1717 | 1720 | ||
@@ -1722,8 +1725,7 @@ out_dump: | |||
1722 | (pid_t)perf_evsel__intval(evsel, sample, "pid"), | 1725 | (pid_t)perf_evsel__intval(evsel, sample, "pid"), |
1723 | runtime, | 1726 | runtime, |
1724 | perf_evsel__intval(evsel, sample, "vruntime")); | 1727 | perf_evsel__intval(evsel, sample, "vruntime")); |
1725 | thread__put(thread); | 1728 | goto out_put; |
1726 | return 0; | ||
1727 | } | 1729 | } |
1728 | 1730 | ||
1729 | static void bpf_output__printer(enum binary_printer_ops op, | 1731 | static void bpf_output__printer(enum binary_printer_ops op, |
@@ -1922,7 +1924,7 @@ static int trace__process_sample(struct perf_tool *tool, | |||
1922 | 1924 | ||
1923 | thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); | 1925 | thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); |
1924 | if (thread && thread__is_filtered(thread)) | 1926 | if (thread && thread__is_filtered(thread)) |
1925 | return 0; | 1927 | goto out; |
1926 | 1928 | ||
1927 | trace__set_base_time(trace, evsel, sample); | 1929 | trace__set_base_time(trace, evsel, sample); |
1928 | 1930 | ||
@@ -1930,7 +1932,8 @@ static int trace__process_sample(struct perf_tool *tool, | |||
1930 | ++trace->nr_events; | 1932 | ++trace->nr_events; |
1931 | handler(trace, evsel, event, sample); | 1933 | handler(trace, evsel, event, sample); |
1932 | } | 1934 | } |
1933 | 1935 | out: | |
1936 | thread__put(thread); | ||
1934 | return err; | 1937 | return err; |
1935 | } | 1938 | } |
1936 | 1939 | ||