Lines Matching defs:thread

11 #include "util/thread.h"
69 pthread_t thread;
131 struct thread *thread;
197 struct thread **curr_thread;
252 /* per thread run time data */
286 struct thread *last_thread;
293 static struct thread **idle_threads;
688 err = pthread_create(&task->thread, &attr, thread_func, parms);
706 err = pthread_join(task->thread, NULL);
904 struct thread *child, *parent;
912 pr_debug("thread does not exist on fork event: child %p, parent %p\n",
938 * handle runtime stats saved per thread
940 static struct thread_runtime *thread__init_runtime(struct thread *thread)
949 thread__set_priv(thread, r);
954 static struct thread_runtime *thread__get_runtime(struct thread *thread)
958 tr = thread__priv(thread);
960 tr = thread__init_runtime(thread);
986 thread_atoms_search(struct rb_root_cached *root, struct thread *thread,
990 struct work_atoms key = { .thread = thread };
1004 BUG_ON(thread != atoms->thread);
1039 static int thread_atoms_insert(struct perf_sched *sched, struct thread *thread)
1047 atoms->thread = thread__get(thread);
1137 struct thread *sched_out, *sched_in;
1205 struct thread *thread = machine__findnew_thread(machine, -1, pid);
1206 struct work_atoms *atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid);
1210 if (thread == NULL)
1215 if (thread_atoms_insert(sched, thread))
1217 atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid);
1229 thread__put(thread);
1241 struct thread *wakee;
1303 struct thread *migrant;
1356 if (!strcmp(thread__comm_str(work_list->thread), "swapper"))
1363 ret = printf(" %s:(%d) ", thread__comm_str(work_list->thread),
1366 ret = printf(" %s:%d ", thread__comm_str(work_list->thread),
1367 thread__tid(work_list->thread));
1388 if (RC_CHK_ACCESS(l->thread) == RC_CHK_ACCESS(r->thread))
1390 l_tid = thread__tid(l->thread);
1391 r_tid = thread__tid(r->thread);
1396 return (int)(RC_CHK_ACCESS(l->thread) - RC_CHK_ACCESS(r->thread));
1539 static bool thread__has_color(struct thread *thread)
1542 .ptr = thread__priv(thread),
1548 static struct thread*
1551 struct thread *thread = machine__findnew_thread(machine, pid, tid);
1556 if (!sched->map.color_pids || !thread || thread__priv(thread))
1557 return thread;
1562 thread__set_priv(thread, priv.ptr);
1563 return thread;
1570 struct thread *sched_in;
1654 struct thread *curr_thread = sched->curr_thread[cpu.cpu];
1806 struct thread *thread;
1814 thread = machine__find_thread(machine, sample->pid, sample->tid);
1815 if (!thread) {
1816 pr_err("Internal error: can't find thread\n");
1820 tr = thread__get_runtime(thread);
1822 thread__put(thread);
1827 thread__put(thread);
1954 static char *timehist_get_commstr(struct thread *thread)
1957 const char *comm = thread__comm_str(thread);
1958 pid_t tid = thread__tid(thread);
1959 pid_t pid = thread__pid(thread);
2036 static char task_state_char(struct thread *thread, int state)
2042 if (thread__tid(thread) == 0)
2052 struct thread *thread,
2055 struct thread_runtime *tr = thread__priv(thread);
2077 c = (thread__tid(thread) == 0) ? 'i' : 's';
2085 printf(" %-*s ", comm_width, timehist_get_commstr(thread));
2094 printf(" %5c ", task_state_char(thread, state));
2104 if (thread__tid(thread) == 0)
2200 struct thread *thread;
2202 /* want main thread for process - has maps */
2203 thread = machine__findnew_thread(machine, sample->pid, sample->pid);
2204 if (thread == NULL) {
2205 pr_debug("Failed to get thread for pid %d.\n", sample->pid);
2214 if (thread__resolve_callchain(thread, cursor, evsel, sample,
2244 static int init_idle_thread(struct thread *thread)
2248 thread__set_comm(thread, idle_comm, 0);
2257 thread__set_priv(thread, itr);
2263 * Track idle stats per cpu by maintaining a local thread
2270 idle_threads = zalloc(ncpu * sizeof(struct thread *));
2276 /* allocate the actual thread struct if needed */
2305 static struct thread *get_idle_thread(int cpu)
2308 * expand/allocate array of pointers to local thread
2315 p = realloc(idle_threads, j * sizeof(struct thread *));
2319 idle_threads = (struct thread **) p;
2326 /* allocate a new thread struct if needed */
2355 static struct thread *timehist_get_thread(struct perf_sched *sched,
2360 struct thread *thread;
2363 thread = get_idle_thread(sample->cpu);
2364 if (thread == NULL)
2365 pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
2369 thread = machine__findnew_thread(machine, sample->pid,
2371 if (thread == NULL) {
2372 pr_debug("Failed to get thread for tid %d. skipping sample.\n",
2378 struct thread *idle;
2383 pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu);
2391 itr->last_thread = thread;
2399 return thread;
2403 struct thread *thread,
2409 if (thread__is_filtered(thread)) {
2429 struct thread *awakened)
2431 struct thread *thread;
2434 thread = machine__findnew_thread(machine, sample->pid, sample->tid);
2435 if (thread == NULL)
2439 if (timehist_skip_sample(sched, thread, evsel, sample) &&
2449 printf(" %-*s ", comm_width, timehist_get_commstr(thread));
2475 struct thread *thread;
2480 thread = machine__findnew_thread(machine, 0, pid);
2481 if (thread == NULL)
2484 tr = thread__get_runtime(thread);
2494 timehist_print_wakeup_event(sched, evsel, sample, machine, thread);
2503 struct thread *migrated)
2505 struct thread *thread;
2517 thread = machine__findnew_thread(machine, sample->pid, sample->tid);
2518 if (thread == NULL)
2521 if (timehist_skip_sample(sched, thread, evsel, sample) &&
2541 printf(" %-*s ", comm_width, timehist_get_commstr(thread));
2559 struct thread *thread;
2564 thread = machine__findnew_thread(machine, 0, pid);
2565 if (thread == NULL)
2568 tr = thread__get_runtime(thread);
2575 timehist_print_migration_event(sched, evsel, sample, machine, thread);
2589 struct thread *thread;
2603 thread = timehist_get_thread(sched, sample, machine, evsel);
2604 if (thread == NULL) {
2609 if (timehist_skip_sample(sched, thread, evsel, sample))
2612 tr = thread__get_runtime(thread);
2645 if (!sched->idle_hist || thread__tid(thread) == 0) {
2653 BUG_ON(thread__tid(thread) != 0);
2658 /* add current idle time as last thread's runtime */
2665 * remove delta time of last thread as it's not updated
2683 timehist_print_sample(sched, evsel, sample, &al, thread, t, state);
2732 static void print_thread_runtime(struct thread *t,
2755 static void print_thread_waittime(struct thread *t,
2780 static int show_thread_runtime(struct thread *t, void *priv)
2863 struct thread *t;
3155 const char *comm = thread__comm_str(data->thread), *this_comm;
3164 this_comm = thread__comm_str(this->thread);
3231 thread__zput(work_list->thread);
3280 pr_err("failed to get thread map from %s\n", sched->map.color_pids_str);
3297 pr_err("failed to get thread map from %s\n", sched->map.color_cpus_str);
3551 "analyze events only for given thread id(s)"),