Lines Matching full: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, in machine__init() local
119 if (thread == NULL) in machine__init()
123 thread__set_comm(thread, comm, 0); in machine__init()
124 thread__put(thread); in machine__init()
204 struct thread *t = rb_entry(nd, struct thread, rb_node); in machine__delete_threads()
230 struct thread *thread, *n; in machine__exit() local
239 list_for_each_entry_safe(thread, n, &threads->dead, node) in machine__exit()
240 list_del_init(&thread->node); in machine__exit()
400 struct thread *th, pid_t pid) in machine__update_thread_pid()
402 struct thread *leader; in machine__update_thread_pid()
428 * tid. Consequently there never should be any maps on a thread in machine__update_thread_pid()
432 pr_err("Discarding thread maps for %d:%d\n", in machine__update_thread_pid()
451 static struct thread*
455 struct thread *th; in __threads__get_last_match()
470 static struct thread*
474 struct thread *th = NULL; in threads__get_last_match()
483 __threads__set_last_match(struct threads *threads, struct thread *th) in __threads__set_last_match()
489 threads__set_last_match(struct threads *threads, struct thread *th) in threads__set_last_match()
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, in ____machine__findnew_thread()
506 struct thread *th; in ____machine__findnew_thread()
515 th = rb_entry(parent, struct thread, rb_node); in ____machine__findnew_thread()
543 * within thread__init_maps to find the thread in ____machine__findnew_thread()
563 struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid) in __machine__findnew_thread()
568 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, in machine__findnew_thread()
572 struct thread *th; in machine__findnew_thread()
580 struct thread *machine__find_thread(struct machine *machine, pid_t pid, in machine__find_thread()
584 struct thread *th; in machine__find_thread()
593 struct thread *thread) in machine__thread_exec_comm() argument
596 return thread__exec_comm(thread); in machine__thread_exec_comm()
598 return thread__comm(thread); in machine__thread_exec_comm()
604 struct thread *thread = machine__findnew_thread(machine, in machine__process_comm_event() local
616 if (thread == NULL || in machine__process_comm_event()
617 __thread__set_comm(thread, event->comm.comm, sample->time, exec)) { in machine__process_comm_event()
622 thread__put(thread); in machine__process_comm_event()
631 struct thread *thread = machine__findnew_thread(machine, in machine__process_namespaces_event() local
647 if (thread == NULL || in machine__process_namespaces_event()
648 thread__set_namespaces(thread, sample->time, &event->namespaces)) { in machine__process_namespaces_event()
653 thread__put(thread); in machine__process_namespaces_event()
957 struct thread *pos = rb_entry(nd, struct thread, rb_node); in machine__fprintf()
1723 struct thread *thread; in machine__process_mmap2_event() local
1744 thread = machine__findnew_thread(machine, event->mmap2.pid, in machine__process_mmap2_event()
1746 if (thread == NULL) in machine__process_mmap2_event()
1753 event->mmap2.filename, thread); in machine__process_mmap2_event()
1758 ret = thread__insert_map(thread, map); in machine__process_mmap2_event()
1762 thread__put(thread); in machine__process_mmap2_event()
1769 thread__put(thread); in machine__process_mmap2_event()
1778 struct thread *thread; in machine__process_mmap_event() local
1794 thread = machine__findnew_thread(machine, event->mmap.pid, in machine__process_mmap_event()
1796 if (thread == NULL) in machine__process_mmap_event()
1804 NULL, prot, 0, event->mmap.filename, thread); in machine__process_mmap_event()
1809 ret = thread__insert_map(thread, map); in machine__process_mmap_event()
1813 thread__put(thread); in machine__process_mmap_event()
1820 thread__put(thread); in machine__process_mmap_event()
1826 static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock) in __machine__remove_thread()
1851 * thread. in __machine__remove_thread()
1859 void machine__remove_thread(struct machine *machine, struct thread *th) in machine__remove_thread()
1867 struct thread *thread = machine__find_thread(machine, in machine__process_fork_event() local
1870 struct thread *parent = machine__findnew_thread(machine, in machine__process_fork_event()
1880 * There may be an existing thread that is not actually the parent, in machine__process_fork_event()
1882 * (fork) event that would have removed the thread was lost. Assume the in machine__process_fork_event()
1886 dump_printf("removing erroneous parent thread %d/%d\n", in machine__process_fork_event()
1894 /* if a thread currently exists for the thread id remove it */ in machine__process_fork_event()
1895 if (thread != NULL) { in machine__process_fork_event()
1896 machine__remove_thread(machine, thread); in machine__process_fork_event()
1897 thread__put(thread); in machine__process_fork_event()
1900 thread = machine__findnew_thread(machine, event->fork.pid, in machine__process_fork_event()
1903 * When synthesizing FORK events, we are trying to create thread in machine__process_fork_event()
1919 if (thread == NULL || parent == NULL || in machine__process_fork_event()
1920 thread__fork(thread, parent, sample->time, do_maps_clone) < 0) { in machine__process_fork_event()
1924 thread__put(thread); in machine__process_fork_event()
1933 struct thread *thread = machine__find_thread(machine, in machine__process_exit_event() local
1940 if (thread != NULL) { in machine__process_exit_event()
1941 thread__exited(thread); in machine__process_exit_event()
1942 thread__put(thread); in machine__process_exit_event()
2000 static void ip__resolve_ams(struct thread *thread, in ip__resolve_ams() argument
2014 thread__find_cpumode_addr_location(thread, ip, &al); in ip__resolve_ams()
2024 static void ip__resolve_data(struct thread *thread, in ip__resolve_data() argument
2032 thread__find_symbol(thread, m, addr, &al); in ip__resolve_data()
2050 ip__resolve_ams(al->thread, &mi->iaddr, sample->ip); in sample__resolve_mem()
2051 ip__resolve_data(al->thread, al->cpumode, &mi->daddr, in sample__resolve_mem()
2084 static int add_callchain_ip(struct thread *thread, in add_callchain_ip() argument
2104 thread__find_cpumode_addr_location(thread, ip, &al); in add_callchain_ip()
2129 thread__find_symbol(thread, *cpumode, ip, &al); in add_callchain_ip()
2174 ip__resolve_ams(al->thread, &bi[i].to, entries[i].to); in sample__resolve_bstack()
2175 ip__resolve_ams(al->thread, &bi[i].from, entries[i].from); in sample__resolve_bstack()
2245 static int lbr_callchain_add_kernel_ip(struct thread *thread, in lbr_callchain_add_kernel_ip() argument
2259 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2269 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2279 static void save_lbr_cursor_node(struct thread *thread, in save_lbr_cursor_node() argument
2283 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in save_lbr_cursor_node()
2304 static int lbr_callchain_add_lbr_ip(struct thread *thread, in lbr_callchain_add_lbr_ip() argument
2325 if (thread->lbr_stitch) { in lbr_callchain_add_lbr_ip()
2340 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2353 if (thread->lbr_stitch && (cursor->pos != cursor->nr)) { in lbr_callchain_add_lbr_ip()
2365 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2371 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2380 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2386 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2393 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2403 static int lbr_callchain_add_stitched_lbr_ip(struct thread *thread, in lbr_callchain_add_stitched_lbr_ip() argument
2406 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in lbr_callchain_add_stitched_lbr_ip()
2428 static struct stitch_list *get_stitch_node(struct thread *thread) in get_stitch_node() argument
2430 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in get_stitch_node()
2444 static bool has_stitched_lbr(struct thread *thread, in has_stitched_lbr() argument
2454 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in has_stitched_lbr()
2500 stitch_node = get_stitch_node(thread); in has_stitched_lbr()
2516 static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr) in alloc_lbr_stitch() argument
2518 if (thread->lbr_stitch) in alloc_lbr_stitch()
2521 thread->lbr_stitch = zalloc(sizeof(*thread->lbr_stitch)); in alloc_lbr_stitch()
2522 if (!thread->lbr_stitch) in alloc_lbr_stitch()
2525 thread->lbr_stitch->prev_lbr_cursor = calloc(max_lbr + 1, sizeof(struct callchain_cursor_node)); in alloc_lbr_stitch()
2526 if (!thread->lbr_stitch->prev_lbr_cursor) in alloc_lbr_stitch()
2529 INIT_LIST_HEAD(&thread->lbr_stitch->lists); in alloc_lbr_stitch()
2530 INIT_LIST_HEAD(&thread->lbr_stitch->free_lists); in alloc_lbr_stitch()
2535 zfree(&thread->lbr_stitch); in alloc_lbr_stitch()
2538 thread->lbr_stitch_enable = false; in alloc_lbr_stitch()
2549 static int resolve_lbr_callchain_sample(struct thread *thread, in resolve_lbr_callchain_sample() argument
2574 if (thread->lbr_stitch_enable && !sample->no_hw_idx && in resolve_lbr_callchain_sample()
2575 (max_lbr > 0) && alloc_lbr_stitch(thread, max_lbr)) { in resolve_lbr_callchain_sample()
2576 lbr_stitch = thread->lbr_stitch; in resolve_lbr_callchain_sample()
2578 stitched_lbr = has_stitched_lbr(thread, sample, in resolve_lbr_callchain_sample()
2591 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2597 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2603 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2610 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2614 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2620 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2632 static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, in find_prev_cpumode() argument
2644 err = add_callchain_ip(thread, cursor, parent, in find_prev_cpumode()
2653 static int thread__resolve_callchain_sample(struct thread *thread, in thread__resolve_callchain_sample() argument
2676 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent, in thread__resolve_callchain_sample()
2687 skip_idx = arch_skip_callchain_idx(thread, chain); in thread__resolve_callchain_sample()
2739 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2746 err = add_callchain_ip(thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
2764 err = find_prev_cpumode(chain, thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
2786 err = find_prev_cpumode(chain, thread, cursor, parent, in thread__resolve_callchain_sample()
2793 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2867 static int thread__resolve_callchain_unwind(struct thread *thread, in thread__resolve_callchain_unwind() argument
2884 thread, sample, max_stack); in thread__resolve_callchain_unwind()
2887 int thread__resolve_callchain(struct thread *thread, in thread__resolve_callchain() argument
2900 ret = thread__resolve_callchain_sample(thread, cursor, in thread__resolve_callchain()
2906 ret = thread__resolve_callchain_unwind(thread, cursor, in thread__resolve_callchain()
2910 ret = thread__resolve_callchain_unwind(thread, cursor, in thread__resolve_callchain()
2915 ret = thread__resolve_callchain_sample(thread, cursor, in thread__resolve_callchain()
2925 int (*fn)(struct thread *thread, void *p), in machine__for_each_thread() argument
2930 struct thread *thread; in machine__for_each_thread() local
2938 thread = rb_entry(nd, struct thread, rb_node); in machine__for_each_thread()
2939 rc = fn(thread, priv); in machine__for_each_thread()
2944 list_for_each_entry(thread, &threads->dead, node) { in machine__for_each_thread()
2945 rc = fn(thread, priv); in machine__for_each_thread()
2954 int (*fn)(struct thread *thread, void *p), in machines__for_each_thread() argument
2987 struct thread *thread; in machine__set_current_tid() local
3011 thread = machine__findnew_thread(machine, pid, tid); in machine__set_current_tid()
3012 if (!thread) in machine__set_current_tid()
3015 thread->cpu = cpu; in machine__set_current_tid()
3016 thread__put(thread); in machine__set_current_tid()