Commit 380512345e13c3af64e59627f1b993c4faa94a84

Authored by Adrian Hunter
Committed by Arnaldo Carvalho de Melo
1 parent 27389d7823

perf tools: struct thread has a tid not a pid

As evident from 'machine__process_fork_event()' and
'machine__process_exit_event()' the 'pid' member of struct thread is
actually the tid.

Rename 'pid' to 'tid' in struct thread accordingly.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1372944040-32690-13-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 10 changed files with 35 additions and 35 deletions Side-by-side Diff

tools/perf/builtin-kmem.c
... ... @@ -313,7 +313,7 @@
313 313 return -1;
314 314 }
315 315  
316   - dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
  316 + dump_printf(" ... thread: %s:%d\n", thread->comm, thread->tid);
317 317  
318 318 if (evsel->handler.func != NULL) {
319 319 tracepoint_handler f = evsel->handler.func;
tools/perf/builtin-sched.c
... ... @@ -1075,7 +1075,7 @@
1075 1075 if (!atoms) {
1076 1076 if (thread_atoms_insert(sched, migrant))
1077 1077 return -1;
1078   - register_pid(sched, migrant->pid, migrant->comm);
  1078 + register_pid(sched, migrant->tid, migrant->comm);
1079 1079 atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid);
1080 1080 if (!atoms) {
1081 1081 pr_err("migration-event: Internal tree error");
... ... @@ -1115,7 +1115,7 @@
1115 1115 sched->all_runtime += work_list->total_runtime;
1116 1116 sched->all_count += work_list->nb_atoms;
1117 1117  
1118   - ret = printf(" %s:%d ", work_list->thread->comm, work_list->thread->pid);
  1118 + ret = printf(" %s:%d ", work_list->thread->comm, work_list->thread->tid);
1119 1119  
1120 1120 for (i = 0; i < 24 - ret; i++)
1121 1121 printf(" ");
1122 1122  
... ... @@ -1131,9 +1131,9 @@
1131 1131  
1132 1132 static int pid_cmp(struct work_atoms *l, struct work_atoms *r)
1133 1133 {
1134   - if (l->thread->pid < r->thread->pid)
  1134 + if (l->thread->tid < r->thread->tid)
1135 1135 return -1;
1136   - if (l->thread->pid > r->thread->pid)
  1136 + if (l->thread->tid > r->thread->tid)
1137 1137 return 1;
1138 1138  
1139 1139 return 0;
... ... @@ -1321,7 +1321,7 @@
1321 1321 printf("*");
1322 1322  
1323 1323 if (sched->curr_thread[cpu]) {
1324   - if (sched->curr_thread[cpu]->pid)
  1324 + if (sched->curr_thread[cpu]->tid)
1325 1325 printf("%2s ", sched->curr_thread[cpu]->shortname);
1326 1326 else
1327 1327 printf(". ");
... ... @@ -1332,7 +1332,7 @@
1332 1332 printf(" %12.6f secs ", (double)timestamp/1e9);
1333 1333 if (new_shortname) {
1334 1334 printf("%s => %s:%d\n",
1335   - sched_in->shortname, sched_in->comm, sched_in->pid);
  1335 + sched_in->shortname, sched_in->comm, sched_in->tid);
1336 1336 } else {
1337 1337 printf("\n");
1338 1338 }
tools/perf/builtin-trace.c
... ... @@ -142,7 +142,7 @@
142 142 printed += fprintf_duration(duration, fp);
143 143  
144 144 if (trace->multiple_threads)
145   - printed += fprintf(fp, "%d ", thread->pid);
  145 + printed += fprintf(fp, "%d ", thread->tid);
146 146  
147 147 return printed;
148 148 }
... ... @@ -593,7 +593,7 @@
593 593 color = PERF_COLOR_YELLOW;
594 594  
595 595 printed += color_fprintf(fp, color, "%20s", thread->comm);
596   - printed += fprintf(fp, " - %-5d :%11lu [", thread->pid, ttrace->nr_events);
  596 + printed += fprintf(fp, " - %-5d :%11lu [", thread->tid, ttrace->nr_events);
597 597 printed += color_fprintf(fp, color, "%5.1f%%", ratio);
598 598 printed += fprintf(fp, " ] %10.3f ms\n", ttrace->runtime_ms);
599 599 }
tools/perf/ui/browsers/hists.c
... ... @@ -1256,7 +1256,7 @@
1256 1256 printed += scnprintf(bf + printed, size - printed,
1257 1257 ", Thread: %s(%d)",
1258 1258 (thread->comm_set ? thread->comm : ""),
1259   - thread->pid);
  1259 + thread->tid);
1260 1260 if (dso)
1261 1261 printed += scnprintf(bf + printed, size - printed,
1262 1262 ", DSO: %s", dso->short_name);
... ... @@ -1579,7 +1579,7 @@
1579 1579 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
1580 1580 (browser->hists->thread_filter ? "out of" : "into"),
1581 1581 (thread->comm_set ? thread->comm : ""),
1582   - thread->pid) > 0)
  1582 + thread->tid) > 0)
1583 1583 zoom_thread = nr_options++;
1584 1584  
1585 1585 if (dso != NULL &&
... ... @@ -1702,7 +1702,7 @@
1702 1702 } else {
1703 1703 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
1704 1704 thread->comm_set ? thread->comm : "",
1705   - thread->pid);
  1705 + thread->tid);
1706 1706 browser->hists->thread_filter = thread;
1707 1707 sort_thread.elide = true;
1708 1708 pstack__push(fstack, &browser->hists->thread_filter);
tools/perf/util/event.c
... ... @@ -686,7 +686,7 @@
686 686 !strlist__has_entry(symbol_conf.comm_list, thread->comm))
687 687 goto out_filtered;
688 688  
689   - dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
  689 + dump_printf(" ... thread: %s:%d\n", thread->comm, thread->tid);
690 690 /*
691 691 * Have we already created the kernel maps for this machine?
692 692 *
tools/perf/util/machine.c
... ... @@ -233,7 +233,7 @@
233 233 return;
234 234 }
235 235  
236   -static struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid,
  236 +static struct thread *__machine__findnew_thread(struct machine *machine, pid_t tid,
237 237 bool create)
238 238 {
239 239 struct rb_node **p = &machine->threads.rb_node;
240 240  
241 241  
242 242  
... ... @@ -241,23 +241,23 @@
241 241 struct thread *th;
242 242  
243 243 /*
244   - * Font-end cache - PID lookups come in blocks,
  244 + * Front-end cache - TID lookups come in blocks,
245 245 * so most of the time we dont have to look up
246 246 * the full rbtree:
247 247 */
248   - if (machine->last_match && machine->last_match->pid == pid)
  248 + if (machine->last_match && machine->last_match->tid == tid)
249 249 return machine->last_match;
250 250  
251 251 while (*p != NULL) {
252 252 parent = *p;
253 253 th = rb_entry(parent, struct thread, rb_node);
254 254  
255   - if (th->pid == pid) {
  255 + if (th->tid == tid) {
256 256 machine->last_match = th;
257 257 return th;
258 258 }
259 259  
260   - if (pid < th->pid)
  260 + if (tid < th->tid)
261 261 p = &(*p)->rb_left;
262 262 else
263 263 p = &(*p)->rb_right;
... ... @@ -266,7 +266,7 @@
266 266 if (!create)
267 267 return NULL;
268 268  
269   - th = thread__new(pid);
  269 + th = thread__new(tid);
270 270 if (th != NULL) {
271 271 rb_link_node(&th->rb_node, parent, p);
272 272 rb_insert_color(&th->rb_node, &machine->threads);
273 273  
274 274  
275 275  
... ... @@ -276,14 +276,14 @@
276 276 return th;
277 277 }
278 278  
279   -struct thread *machine__findnew_thread(struct machine *machine, pid_t pid)
  279 +struct thread *machine__findnew_thread(struct machine *machine, pid_t tid)
280 280 {
281   - return __machine__findnew_thread(machine, pid, true);
  281 + return __machine__findnew_thread(machine, tid, true);
282 282 }
283 283  
284   -struct thread *machine__find_thread(struct machine *machine, pid_t pid)
  284 +struct thread *machine__find_thread(struct machine *machine, pid_t tid)
285 285 {
286   - return __machine__findnew_thread(machine, pid, false);
  286 + return __machine__findnew_thread(machine, tid, false);
287 287 }
288 288  
289 289 int machine__process_comm_event(struct machine *machine, union perf_event *event)
tools/perf/util/machine.h
... ... @@ -36,7 +36,7 @@
36 36 return machine->vmlinux_maps[type];
37 37 }
38 38  
39   -struct thread *machine__find_thread(struct machine *machine, pid_t pid);
  39 +struct thread *machine__find_thread(struct machine *machine, pid_t tid);
40 40  
41 41 int machine__process_comm_event(struct machine *machine, union perf_event *event);
42 42 int machine__process_exit_event(struct machine *machine, union perf_event *event);
... ... @@ -99,7 +99,7 @@
99 99 return machine ? machine->pid == HOST_KERNEL_ID : false;
100 100 }
101 101  
102   -struct thread *machine__findnew_thread(struct machine *machine, pid_t pid);
  102 +struct thread *machine__findnew_thread(struct machine *machine, pid_t tid);
103 103  
104 104 size_t machine__fprintf(struct machine *machine, FILE *fp);
105 105  
tools/perf/util/sort.c
... ... @@ -55,14 +55,14 @@
55 55 static int64_t
56 56 sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
57 57 {
58   - return right->thread->pid - left->thread->pid;
  58 + return right->thread->tid - left->thread->tid;
59 59 }
60 60  
61 61 static int hist_entry__thread_snprintf(struct hist_entry *self, char *bf,
62 62 size_t size, unsigned int width)
63 63 {
64 64 return repsep_snprintf(bf, size, "%*s:%5d", width - 6,
65   - self->thread->comm ?: "", self->thread->pid);
  65 + self->thread->comm ?: "", self->thread->tid);
66 66 }
67 67  
68 68 struct sort_entry sort_thread = {
... ... @@ -77,7 +77,7 @@
77 77 static int64_t
78 78 sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
79 79 {
80   - return right->thread->pid - left->thread->pid;
  80 + return right->thread->tid - left->thread->tid;
81 81 }
82 82  
83 83 static int64_t
tools/perf/util/thread.c
... ... @@ -7,17 +7,17 @@
7 7 #include "util.h"
8 8 #include "debug.h"
9 9  
10   -struct thread *thread__new(pid_t pid)
  10 +struct thread *thread__new(pid_t tid)
11 11 {
12 12 struct thread *self = zalloc(sizeof(*self));
13 13  
14 14 if (self != NULL) {
15 15 map_groups__init(&self->mg);
16   - self->pid = pid;
  16 + self->tid = tid;
17 17 self->ppid = -1;
18 18 self->comm = malloc(32);
19 19 if (self->comm)
20   - snprintf(self->comm, 32, ":%d", self->pid);
  20 + snprintf(self->comm, 32, ":%d", self->tid);
21 21 }
22 22  
23 23 return self;
... ... @@ -57,7 +57,7 @@
57 57  
58 58 size_t thread__fprintf(struct thread *thread, FILE *fp)
59 59 {
60   - return fprintf(fp, "Thread %d %s\n", thread->pid, thread->comm) +
  60 + return fprintf(fp, "Thread %d %s\n", thread->tid, thread->comm) +
61 61 map_groups__fprintf(&thread->mg, verbose, fp);
62 62 }
63 63  
... ... @@ -84,7 +84,7 @@
84 84 if (map_groups__clone(&self->mg, &parent->mg, i) < 0)
85 85 return -ENOMEM;
86 86  
87   - self->ppid = parent->pid;
  87 + self->ppid = parent->tid;
88 88  
89 89 return 0;
90 90 }
tools/perf/util/thread.h
... ... @@ -12,7 +12,7 @@
12 12 struct list_head node;
13 13 };
14 14 struct map_groups mg;
15   - pid_t pid;
  15 + pid_t tid;
16 16 pid_t ppid;
17 17 char shortname[3];
18 18 bool comm_set;
... ... @@ -24,7 +24,7 @@
24 24  
25 25 struct machine;
26 26  
27   -struct thread *thread__new(pid_t pid);
  27 +struct thread *thread__new(pid_t tid);
28 28 void thread__delete(struct thread *self);
29 29  
30 30 int thread__set_comm(struct thread *self, const char *comm);