aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/thread.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-03-15 14:27:27 -0400
committerIngo Molnar <mingo@kernel.org>2017-03-15 14:27:27 -0400
commitffa86c2f1a8862cf58c873f6f14d4b2c3250fb48 (patch)
tree9e15f9494d9a70bd0d2295311f0c56a04113070c /tools/perf/util/thread.c
parent84e5b549214f2160c12318aac549de85f600c79a (diff)
parent5f6bee34707973ea7879a7857fd63ddccc92fff3 (diff)
Merge tag 'perf-core-for-mingo-4.12-20170314' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: New features: - Add PERF_RECORD_NAMESPACES so that the kernel can record information required to associate samples to namespaces, helping in container problem characterization. Now the 'perf record has a --namespace' option to ask for such info, and when present, it can be used, initially, via a new sort order, 'cgroup_id', allowing histogram entry bucketization by a (device, inode) based cgroup identifier (Hari Bathini) - Add --next option to 'perf sched timehist', showing what is the next thread to run (Brendan Gregg) Fixes: - Fix segfault with basic block 'cycles' sort dimension (Changbin Du) - Add c2c to command-list.txt, making it appear in the 'perf help' output (Changbin Du) - Fix zeroing of 'abs_path' variable in the perf hists browser switch file code (Changbin Du) - Hide tips messages when -q/--quiet is given to 'perf report' (Namhyung Kim) Infrastructure changes: - Use ref_reloc_sym + offset to setup kretprobes (Naveen Rao) - Ignore generated files pmu-events/{jevents,pmu-events.c} for git (Changbin Du) Documentation changes: - Document +field style argument support for --field option (Changbin Du) - Clarify 'perf c2c --stats' help message (Namhyung Kim) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/thread.c')
-rw-r--r--tools/perf/util/thread.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 74e79d26b421..dcdb87a5d0a1 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -7,6 +7,7 @@
7#include "thread-stack.h" 7#include "thread-stack.h"
8#include "util.h" 8#include "util.h"
9#include "debug.h" 9#include "debug.h"
10#include "namespaces.h"
10#include "comm.h" 11#include "comm.h"
11#include "unwind.h" 12#include "unwind.h"
12 13
@@ -40,6 +41,7 @@ struct thread *thread__new(pid_t pid, pid_t tid)
40 thread->tid = tid; 41 thread->tid = tid;
41 thread->ppid = -1; 42 thread->ppid = -1;
42 thread->cpu = -1; 43 thread->cpu = -1;
44 INIT_LIST_HEAD(&thread->namespaces_list);
43 INIT_LIST_HEAD(&thread->comm_list); 45 INIT_LIST_HEAD(&thread->comm_list);
44 46
45 comm_str = malloc(32); 47 comm_str = malloc(32);
@@ -66,7 +68,8 @@ err_thread:
66 68
67void thread__delete(struct thread *thread) 69void thread__delete(struct thread *thread)
68{ 70{
69 struct comm *comm, *tmp; 71 struct namespaces *namespaces, *tmp_namespaces;
72 struct comm *comm, *tmp_comm;
70 73
71 BUG_ON(!RB_EMPTY_NODE(&thread->rb_node)); 74 BUG_ON(!RB_EMPTY_NODE(&thread->rb_node));
72 75
@@ -76,7 +79,12 @@ void thread__delete(struct thread *thread)
76 map_groups__put(thread->mg); 79 map_groups__put(thread->mg);
77 thread->mg = NULL; 80 thread->mg = NULL;
78 } 81 }
79 list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) { 82 list_for_each_entry_safe(namespaces, tmp_namespaces,
83 &thread->namespaces_list, list) {
84 list_del(&namespaces->list);
85 namespaces__free(namespaces);
86 }
87 list_for_each_entry_safe(comm, tmp_comm, &thread->comm_list, list) {
80 list_del(&comm->list); 88 list_del(&comm->list);
81 comm__free(comm); 89 comm__free(comm);
82 } 90 }
@@ -104,6 +112,38 @@ void thread__put(struct thread *thread)
104 } 112 }
105} 113}
106 114
115struct namespaces *thread__namespaces(const struct thread *thread)
116{
117 if (list_empty(&thread->namespaces_list))
118 return NULL;
119
120 return list_first_entry(&thread->namespaces_list, struct namespaces, list);
121}
122
123int thread__set_namespaces(struct thread *thread, u64 timestamp,
124 struct namespaces_event *event)
125{
126 struct namespaces *new, *curr = thread__namespaces(thread);
127
128 new = namespaces__new(event);
129 if (!new)
130 return -ENOMEM;
131
132 list_add(&new->list, &thread->namespaces_list);
133
134 if (timestamp && curr) {
135 /*
136 * setns syscall must have changed few or all the namespaces
137 * of this thread. Update end time for the namespaces
138 * previously used.
139 */
140 curr = list_next_entry(new, list);
141 curr->end_time = timestamp;
142 }
143
144 return 0;
145}
146
107struct comm *thread__comm(const struct thread *thread) 147struct comm *thread__comm(const struct thread *thread)
108{ 148{
109 if (list_empty(&thread->comm_list)) 149 if (list_empty(&thread->comm_list))