Lines Matching defs:thread
11 #include "util/thread.h"
68 pthread_t thread;
130 struct thread *thread;
196 struct thread *curr_thread[MAX_CPUS];
250 /* per thread run time data */
284 struct thread *last_thread;
291 static struct thread **idle_threads;
689 err = pthread_create(&task->thread, &attr, thread_func, parms);
882 struct thread *child, *parent;
890 pr_debug("thread does not exist on fork event: child %p, parent %p\n",
916 * handle runtime stats saved per thread
918 static struct thread_runtime *thread__init_runtime(struct thread *thread)
927 thread__set_priv(thread, r);
932 static struct thread_runtime *thread__get_runtime(struct thread *thread)
936 tr = thread__priv(thread);
938 tr = thread__init_runtime(thread);
964 thread_atoms_search(struct rb_root_cached *root, struct thread *thread,
968 struct work_atoms key = { .thread = thread };
982 BUG_ON(thread != atoms->thread);
1017 static int thread_atoms_insert(struct perf_sched *sched, struct thread *thread)
1025 atoms->thread = thread__get(thread);
1115 struct thread *sched_out, *sched_in;
1183 struct thread *thread = machine__findnew_thread(machine, -1, pid);
1184 struct work_atoms *atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid);
1188 if (thread == NULL)
1193 if (thread_atoms_insert(sched, thread))
1195 atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid);
1207 thread__put(thread);
1219 struct thread *wakee;
1281 struct thread *migrant;
1334 if (!strcmp(thread__comm_str(work_list->thread), "swapper"))
1341 ret = printf(" %s:(%d) ", thread__comm_str(work_list->thread), work_list->num_merged);
1343 ret = printf(" %s:%d ", thread__comm_str(work_list->thread), work_list->thread->tid);
1361 if (l->thread == r->thread)
1363 if (l->thread->tid < r->thread->tid)
1365 if (l->thread->tid > r->thread->tid)
1367 return (int)(l->thread - r->thread);
1502 static bool thread__has_color(struct thread *thread)
1505 .ptr = thread__priv(thread),
1511 static struct thread*
1514 struct thread *thread = machine__findnew_thread(machine, pid, tid);
1519 if (!sched->map.color_pids || !thread || thread__priv(thread))
1520 return thread;
1525 thread__set_priv(thread, priv.ptr);
1526 return thread;
1533 struct thread *sched_in;
1612 struct thread *curr_thread = sched->curr_thread[cpu];
1764 struct thread *thread;
1772 thread = machine__find_thread(machine, sample->pid, sample->tid);
1773 if (!thread) {
1774 pr_err("Internal error: can't find thread\n");
1778 tr = thread__get_runtime(thread);
1780 thread__put(thread);
1785 thread__put(thread);
1907 static char *timehist_get_commstr(struct thread *thread)
1910 const char *comm = thread__comm_str(thread);
1911 pid_t tid = thread->tid;
1912 pid_t pid = thread->pid_;
1989 static char task_state_char(struct thread *thread, int state)
1995 if (thread->tid == 0)
2005 struct thread *thread,
2008 struct thread_runtime *tr = thread__priv(thread);
2030 c = (thread->tid == 0) ? 'i' : 's';
2038 printf(" %-*s ", comm_width, timehist_get_commstr(thread));
2047 printf(" %5c ", task_state_char(thread, state));
2057 if (thread->tid == 0)
2153 struct thread *thread;
2155 /* want main thread for process - has maps */
2156 thread = machine__findnew_thread(machine, sample->pid, sample->pid);
2157 if (thread == NULL) {
2158 pr_debug("Failed to get thread for pid %d.\n", sample->pid);
2165 if (thread__resolve_callchain(thread, cursor, evsel, sample,
2195 static int init_idle_thread(struct thread *thread)
2199 thread__set_comm(thread, idle_comm, 0);
2208 thread__set_priv(thread, itr);
2214 * Track idle stats per cpu by maintaining a local thread
2221 idle_threads = zalloc(ncpu * sizeof(struct thread *));
2227 /* allocate the actual thread struct if needed */
2256 static struct thread *get_idle_thread(int cpu)
2259 * expand/allocate array of pointers to local thread
2266 p = realloc(idle_threads, j * sizeof(struct thread *));
2270 idle_threads = (struct thread **) p;
2277 /* allocate a new thread struct if needed */
2300 static struct thread *timehist_get_thread(struct perf_sched *sched,
2305 struct thread *thread;
2308 thread = get_idle_thread(sample->cpu);
2309 if (thread == NULL)
2310 pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
2314 thread = machine__findnew_thread(machine, sample->pid,
2316 if (thread == NULL) {
2317 pr_debug("Failed to get thread for tid %d. skipping sample.\n",
2323 struct thread *idle;
2328 pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
2336 itr->last_thread = thread;
2344 return thread;
2348 struct thread *thread,
2354 if (thread__is_filtered(thread)) {
2374 struct thread *awakened)
2376 struct thread *thread;
2379 thread = machine__findnew_thread(machine, sample->pid, sample->tid);
2380 if (thread == NULL)
2384 if (timehist_skip_sample(sched, thread, evsel, sample) &&
2394 printf(" %-*s ", comm_width, timehist_get_commstr(thread));
2420 struct thread *thread;
2425 thread = machine__findnew_thread(machine, 0, pid);
2426 if (thread == NULL)
2429 tr = thread__get_runtime(thread);
2439 timehist_print_wakeup_event(sched, evsel, sample, machine, thread);
2448 struct thread *migrated)
2450 struct thread *thread;
2462 thread = machine__findnew_thread(machine, sample->pid, sample->tid);
2463 if (thread == NULL)
2466 if (timehist_skip_sample(sched, thread, evsel, sample) &&
2486 printf(" %-*s ", comm_width, timehist_get_commstr(thread));
2504 struct thread *thread;
2509 thread = machine__findnew_thread(machine, 0, pid);
2510 if (thread == NULL)
2513 tr = thread__get_runtime(thread);
2520 timehist_print_migration_event(sched, evsel, sample, machine, thread);
2534 struct thread *thread;
2547 thread = timehist_get_thread(sched, sample, machine, evsel);
2548 if (thread == NULL) {
2553 if (timehist_skip_sample(sched, thread, evsel, sample))
2556 tr = thread__get_runtime(thread);
2589 if (!sched->idle_hist || thread->tid == 0) {
2597 BUG_ON(thread->tid != 0);
2602 /* add current idle time as last thread's runtime */
2609 * remove delta time of last thread as it's not updated
2627 timehist_print_sample(sched, evsel, sample, &al, thread, t, state);
2675 static void print_thread_runtime(struct thread *t,
2698 static void print_thread_waittime(struct thread *t,
2723 static int __show_thread_runtime(struct thread *t, void *priv)
2746 static int show_thread_runtime(struct thread *t, void *priv)
2754 static int show_deadthread_runtime(struct thread *t, void *priv)
2822 struct thread *t;
3119 const char *comm = thread__comm_str(data->thread), *this_comm;
3128 this_comm = thread__comm_str(this->thread);
3195 thread__zput(work_list->thread);
3244 pr_err("failed to get thread map from %s\n", sched->map.color_pids_str);
3261 pr_err("failed to get thread map from %s\n", sched->map.color_cpus_str);
3500 "analyze events only for given thread id(s)"),