Lines Matching defs:thread

24 #include "thread.h"
44 static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock);
115 struct thread *thread = machine__findnew_thread(machine, -1,
119 if (thread == NULL)
123 thread__set_comm(thread, comm, 0);
124 thread__put(thread);
204 struct thread *t = rb_entry(nd, struct thread, rb_node);
230 struct thread *thread, *n;
239 list_for_each_entry_safe(thread, n, &threads->dead, node)
240 list_del_init(&thread->node);
400 struct thread *th, pid_t pid)
402 struct thread *leader;
428 * tid. Consequently there never should be any maps on a thread
432 pr_err("Discarding thread maps for %d:%d\n",
451 static struct thread*
455 struct thread *th;
470 static struct thread*
474 struct thread *th = NULL;
483 __threads__set_last_match(struct threads *threads, struct thread *th)
489 threads__set_last_match(struct threads *threads, struct thread *th)
496 * Caller must eventually drop thread->refcnt returned with a successful
497 * lookup/new thread inserted.
499 static struct thread *____machine__findnew_thread(struct machine *machine,
506 struct thread *th;
515 th = rb_entry(parent, struct thread, rb_node);
543 * within thread__init_maps to find the thread
563 struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid)
568 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid,
572 struct thread *th;
580 struct thread *machine__find_thread(struct machine *machine, pid_t pid,
584 struct thread *th;
593 struct thread *thread)
596 return thread__exec_comm(thread);
598 return thread__comm(thread);
604 struct thread *thread = machine__findnew_thread(machine,
616 if (thread == NULL ||
617 __thread__set_comm(thread, event->comm.comm, sample->time, exec)) {
622 thread__put(thread);
631 struct thread *thread = machine__findnew_thread(machine,
647 if (thread == NULL ||
648 thread__set_namespaces(thread, sample->time, &event->namespaces)) {
653 thread__put(thread);
957 struct thread *pos = rb_entry(nd, struct thread, rb_node);
1723 struct thread *thread;
1744 thread = machine__findnew_thread(machine, event->mmap2.pid,
1746 if (thread == NULL)
1753 event->mmap2.filename, thread);
1758 ret = thread__insert_map(thread, map);
1762 thread__put(thread);
1769 thread__put(thread);
1778 struct thread *thread;
1794 thread = machine__findnew_thread(machine, event->mmap.pid,
1796 if (thread == NULL)
1804 NULL, prot, 0, event->mmap.filename, thread);
1809 ret = thread__insert_map(thread, map);
1813 thread__put(thread);
1820 thread__put(thread);
1826 static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock)
1851 * thread.
1859 void machine__remove_thread(struct machine *machine, struct thread *th)
1867 struct thread *thread = machine__find_thread(machine,
1870 struct thread *parent = machine__findnew_thread(machine,
1880 * There may be an existing thread that is not actually the parent,
1882 * (fork) event that would have removed the thread was lost. Assume the
1886 dump_printf("removing erroneous parent thread %d/%d\n",
1894 /* if a thread currently exists for the thread id remove it */
1895 if (thread != NULL) {
1896 machine__remove_thread(machine, thread);
1897 thread__put(thread);
1900 thread = machine__findnew_thread(machine, event->fork.pid,
1903 * When synthesizing FORK events, we are trying to create thread
1919 if (thread == NULL || parent == NULL ||
1920 thread__fork(thread, parent, sample->time, do_maps_clone) < 0) {
1924 thread__put(thread);
1933 struct thread *thread = machine__find_thread(machine,
1940 if (thread != NULL) {
1941 thread__exited(thread);
1942 thread__put(thread);
2000 static void ip__resolve_ams(struct thread *thread,
2014 thread__find_cpumode_addr_location(thread, ip, &al);
2024 static void ip__resolve_data(struct thread *thread,
2032 thread__find_symbol(thread, m, addr, &al);
2050 ip__resolve_ams(al->thread, &mi->iaddr, sample->ip);
2051 ip__resolve_data(al->thread, al->cpumode, &mi->daddr,
2084 static int add_callchain_ip(struct thread *thread,
2105 thread__find_cpumode_addr_location(thread, ip, &al);
2130 thread__find_symbol(thread, *cpumode, ip, &al);
2175 ip__resolve_ams(al->thread, &bi[i].to, entries[i].to);
2176 ip__resolve_ams(al->thread, &bi[i].from, entries[i].from);
2246 static int lbr_callchain_add_kernel_ip(struct thread *thread,
2260 err = add_callchain_ip(thread, cursor, parent,
2270 err = add_callchain_ip(thread, cursor, parent,
2280 static void save_lbr_cursor_node(struct thread *thread,
2284 struct lbr_stitch *lbr_stitch = thread->lbr_stitch;
2305 static int lbr_callchain_add_lbr_ip(struct thread *thread,
2326 if (thread->lbr_stitch) {
2341 err = add_callchain_ip(thread, cursor, parent,
2354 if (thread->lbr_stitch && (cursor->pos != cursor->nr)) {
2366 err = add_callchain_ip(thread, cursor, parent,
2372 save_lbr_cursor_node(thread, cursor, i);
2381 err = add_callchain_ip(thread, cursor, parent,
2387 save_lbr_cursor_node(thread, cursor, i);
2395 err = add_callchain_ip(thread, cursor, parent,
2406 static int lbr_callchain_add_stitched_lbr_ip(struct thread *thread,
2409 struct lbr_stitch *lbr_stitch = thread->lbr_stitch;
2431 static struct stitch_list *get_stitch_node(struct thread *thread)
2433 struct lbr_stitch *lbr_stitch = thread->lbr_stitch;
2447 static bool has_stitched_lbr(struct thread *thread,
2457 struct lbr_stitch *lbr_stitch = thread->lbr_stitch;
2503 stitch_node = get_stitch_node(thread);
2519 static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr)
2521 if (thread->lbr_stitch)
2524 thread->lbr_stitch = zalloc(sizeof(*thread->lbr_stitch));
2525 if (!thread->lbr_stitch)
2528 thread->lbr_stitch->prev_lbr_cursor = calloc(max_lbr + 1, sizeof(struct callchain_cursor_node));
2529 if (!thread->lbr_stitch->prev_lbr_cursor)
2532 INIT_LIST_HEAD(&thread->lbr_stitch->lists);
2533 INIT_LIST_HEAD(&thread->lbr_stitch->free_lists);
2538 zfree(&thread->lbr_stitch);
2541 thread->lbr_stitch_enable = false;
2552 static int resolve_lbr_callchain_sample(struct thread *thread,
2577 if (thread->lbr_stitch_enable && !sample->no_hw_idx &&
2578 (max_lbr > 0) && alloc_lbr_stitch(thread, max_lbr)) {
2579 lbr_stitch = thread->lbr_stitch;
2581 stitched_lbr = has_stitched_lbr(thread, sample,
2594 err = lbr_callchain_add_kernel_ip(thread, cursor, sample,
2600 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent,
2606 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor);
2613 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor);
2617 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent,
2623 err = lbr_callchain_add_kernel_ip(thread, cursor, sample,
2635 static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread,
2647 err = add_callchain_ip(thread, cursor, parent,
2656 static int thread__resolve_callchain_sample(struct thread *thread,
2679 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent,
2690 skip_idx = arch_skip_callchain_idx(thread, chain);
2742 err = add_callchain_ip(thread, cursor, parent,
2749 err = add_callchain_ip(thread, cursor, parent, root_al,
2767 err = find_prev_cpumode(chain, thread, cursor, parent, root_al,
2789 err = find_prev_cpumode(chain, thread, cursor, parent,
2796 err = add_callchain_ip(thread, cursor, parent,
2870 static int thread__resolve_callchain_unwind(struct thread *thread,
2887 thread, sample, max_stack);
2890 int thread__resolve_callchain(struct thread *thread,
2903 ret = thread__resolve_callchain_sample(thread, cursor,
2909 ret = thread__resolve_callchain_unwind(thread, cursor,
2913 ret = thread__resolve_callchain_unwind(thread, cursor,
2918 ret = thread__resolve_callchain_sample(thread, cursor,
2928 int (*fn)(struct thread *thread, void *p),
2933 struct thread *thread;
2941 thread = rb_entry(nd, struct thread, rb_node);
2942 rc = fn(thread, priv);
2947 list_for_each_entry(thread, &threads->dead, node) {
2948 rc = fn(thread, priv);
2957 int (*fn)(struct thread *thread, void *p),
2990 struct thread *thread;
3014 thread = machine__findnew_thread(machine, pid, tid);
3015 if (!thread)
3018 thread->cpu = cpu;
3019 thread__put(thread);