Lines Matching full:thread
25 #include "thread.h"
47 struct thread *th, bool lock);
79 return to_find - (int)thread__tid(rb_entry(nd, struct thread_rb_node, rb_node)->thread); in thread_rb_node__cmp_tid()
82 static struct thread_rb_node *thread_rb_node__find(const struct thread *th, in thread_rb_node__find()
104 static void thread__set_guest_comm(struct thread *thread, pid_t pid) in thread__set_guest_comm() argument
109 thread__set_comm(thread, comm, 0); in thread__set_guest_comm()
145 struct thread *thread = machine__findnew_thread(machine, -1, in machine__init() local
148 if (thread == NULL) in machine__init()
151 thread__set_guest_comm(thread, pid); in machine__init()
152 thread__put(thread); in machine__init()
236 __machine__remove_thread(machine, trb, trb->thread, false); in machine__delete_threads()
418 * To support that, copy the host thread's maps to the guest thread's maps.
421 * thread's maps have been set up.
423 * This function returns the guest thread. Apart from keeping the data
424 * structures sane, using a thread belonging to the guest machine, instead
425 * of the host thread, allows it to have its own comm (refer
428 static struct thread *findnew_guest_code(struct machine *machine, in findnew_guest_code()
432 struct thread *host_thread; in findnew_guest_code()
433 struct thread *thread; in findnew_guest_code() local
439 thread = machine__findnew_thread(machine, -1, pid); in findnew_guest_code()
440 if (!thread) in findnew_guest_code()
444 if (maps__nr_maps(thread__maps(thread))) in findnew_guest_code()
445 return thread; in findnew_guest_code()
451 thread__set_guest_comm(thread, pid); in findnew_guest_code()
457 err = maps__clone(thread, thread__maps(host_thread)); in findnew_guest_code()
462 return thread; in findnew_guest_code()
465 thread__zput(thread); in findnew_guest_code()
469 struct thread *machines__findnew_guest_code(struct machines *machines, pid_t pid) in machines__findnew_guest_code()
477 struct thread *machine__findnew_guest_code(struct machine *machine, pid_t pid) in machine__findnew_guest_code()
518 struct thread *th, pid_t pid) in machine__update_thread_pid()
520 struct thread *leader; in machine__update_thread_pid()
546 * tid. Consequently there never should be any maps on a thread in machine__update_thread_pid()
550 pr_err("Discarding thread maps for %d:%d\n", in machine__update_thread_pid()
569 static struct thread*
573 struct thread *th; in __threads__get_last_match()
588 static struct thread*
592 struct thread *th = NULL; in threads__get_last_match()
601 __threads__set_last_match(struct threads *threads, struct thread *th) in __threads__set_last_match()
608 threads__set_last_match(struct threads *threads, struct thread *th) in threads__set_last_match()
615 * Caller must eventually drop thread->refcnt returned with a successful
616 * lookup/new thread inserted.
618 static struct thread *____machine__findnew_thread(struct machine *machine, in ____machine__findnew_thread()
625 struct thread *th; in ____machine__findnew_thread()
635 th = rb_entry(parent, struct thread_rb_node, rb_node)->thread; in ____machine__findnew_thread()
663 nd->thread = th; in ____machine__findnew_thread()
671 * thread__init_maps to find the thread leader and that would screwed in ____machine__findnew_thread()
675 pr_err("Thread init failed thread %d\n", pid); in ____machine__findnew_thread()
691 struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid) in __machine__findnew_thread()
696 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, in machine__findnew_thread()
700 struct thread *th; in machine__findnew_thread()
708 struct thread *machine__find_thread(struct machine *machine, pid_t pid, in machine__find_thread()
712 struct thread *th; in machine__find_thread()
722 * So here a single thread is created for that, but actually there is a separate
723 * idle task per cpu, so there should be one 'struct thread' per cpu, but there
727 struct thread *machine__idle_thread(struct machine *machine) in machine__idle_thread()
729 struct thread *thread = machine__findnew_thread(machine, 0, 0); in machine__idle_thread() local
731 if (!thread || thread__set_comm(thread, "swapper", 0) || in machine__idle_thread()
732 thread__set_namespaces(thread, 0, NULL)) in machine__idle_thread()
735 return thread; in machine__idle_thread()
739 struct thread *thread) in machine__thread_exec_comm() argument
742 return thread__exec_comm(thread); in machine__thread_exec_comm()
744 return thread__comm(thread); in machine__thread_exec_comm()
750 struct thread *thread = machine__findnew_thread(machine, in machine__process_comm_event() local
762 if (thread == NULL || in machine__process_comm_event()
763 __thread__set_comm(thread, event->comm.comm, sample->time, exec)) { in machine__process_comm_event()
768 thread__put(thread); in machine__process_comm_event()
777 struct thread *thread = machine__findnew_thread(machine, in machine__process_namespaces_event() local
793 if (thread == NULL || in machine__process_namespaces_event()
794 thread__set_namespaces(thread, sample->time, &event->namespaces)) { in machine__process_namespaces_event()
799 thread__put(thread); in machine__process_namespaces_event()
1139 struct thread *pos = rb_entry(nd, struct thread_rb_node, rb_node)->thread; in machine__fprintf()
1930 struct thread *thread; in machine__process_mmap2_event() local
1964 thread = machine__findnew_thread(machine, event->mmap2.pid, in machine__process_mmap2_event()
1966 if (thread == NULL) in machine__process_mmap2_event()
1973 event->mmap2.filename, thread); in machine__process_mmap2_event()
1978 ret = thread__insert_map(thread, map); in machine__process_mmap2_event()
1982 thread__put(thread); in machine__process_mmap2_event()
1989 thread__put(thread); in machine__process_mmap2_event()
1998 struct thread *thread; in machine__process_mmap_event() local
2021 thread = machine__findnew_thread(machine, event->mmap.pid, in machine__process_mmap_event()
2023 if (thread == NULL) in machine__process_mmap_event()
2031 NULL, prot, 0, NULL, event->mmap.filename, thread); in machine__process_mmap_event()
2036 ret = thread__insert_map(thread, map); in machine__process_mmap_event()
2040 thread__put(thread); in machine__process_mmap_event()
2047 thread__put(thread); in machine__process_mmap_event()
2054 struct thread *th, bool lock) in __machine__remove_thread()
2069 thread__put(nd->thread); in __machine__remove_thread()
2080 void machine__remove_thread(struct machine *machine, struct thread *th) in machine__remove_thread()
2088 struct thread *thread = machine__find_thread(machine, in machine__process_fork_event() local
2091 struct thread *parent = machine__findnew_thread(machine, in machine__process_fork_event()
2101 * There may be an existing thread that is not actually the parent, in machine__process_fork_event()
2103 * (fork) event that would have removed the thread was lost. Assume the in machine__process_fork_event()
2107 dump_printf("removing erroneous parent thread %d/%d\n", in machine__process_fork_event()
2115 /* if a thread currently exists for the thread id remove it */ in machine__process_fork_event()
2116 if (thread != NULL) { in machine__process_fork_event()
2117 machine__remove_thread(machine, thread); in machine__process_fork_event()
2118 thread__put(thread); in machine__process_fork_event()
2121 thread = machine__findnew_thread(machine, event->fork.pid, in machine__process_fork_event()
2124 * When synthesizing FORK events, we are trying to create thread in machine__process_fork_event()
2140 if (thread == NULL || parent == NULL || in machine__process_fork_event()
2141 thread__fork(thread, parent, sample->time, do_maps_clone) < 0) { in machine__process_fork_event()
2145 thread__put(thread); in machine__process_fork_event()
2154 struct thread *thread = machine__find_thread(machine, in machine__process_exit_event() local
2161 if (thread != NULL) in machine__process_exit_event()
2162 thread__put(thread); in machine__process_exit_event()
2221 static void ip__resolve_ams(struct thread *thread, in ip__resolve_ams() argument
2235 thread__find_cpumode_addr_location(thread, ip, &al); in ip__resolve_ams()
2248 static void ip__resolve_data(struct thread *thread, in ip__resolve_data() argument
2256 thread__find_symbol(thread, m, addr, &al); in ip__resolve_data()
2277 ip__resolve_ams(al->thread, &mi->iaddr, sample->ip); in sample__resolve_mem()
2278 ip__resolve_data(al->thread, al->cpumode, &mi->daddr, in sample__resolve_mem()
2314 static int add_callchain_ip(struct thread *thread, in add_callchain_ip() argument
2336 thread__find_cpumode_addr_location(thread, ip, &al); in add_callchain_ip()
2362 thread__find_symbol(thread, *cpumode, ip, &al); in add_callchain_ip()
2412 ip__resolve_ams(al->thread, &bi[i].to, entries[i].to); in sample__resolve_bstack()
2413 ip__resolve_ams(al->thread, &bi[i].from, entries[i].from); in sample__resolve_bstack()
2483 static int lbr_callchain_add_kernel_ip(struct thread *thread, in lbr_callchain_add_kernel_ip() argument
2497 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2507 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2517 static void save_lbr_cursor_node(struct thread *thread, in save_lbr_cursor_node() argument
2521 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in save_lbr_cursor_node()
2542 static int lbr_callchain_add_lbr_ip(struct thread *thread, in lbr_callchain_add_lbr_ip() argument
2563 if (thread__lbr_stitch(thread)) { in lbr_callchain_add_lbr_ip()
2578 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2591 if (thread__lbr_stitch(thread) && (cursor->pos != cursor->nr)) { in lbr_callchain_add_lbr_ip()
2603 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2609 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2618 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2624 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2631 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2641 static int lbr_callchain_add_stitched_lbr_ip(struct thread *thread, in lbr_callchain_add_stitched_lbr_ip() argument
2644 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in lbr_callchain_add_stitched_lbr_ip()
2666 static struct stitch_list *get_stitch_node(struct thread *thread) in get_stitch_node() argument
2668 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in get_stitch_node()
2682 static bool has_stitched_lbr(struct thread *thread, in has_stitched_lbr() argument
2692 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in has_stitched_lbr()
2738 stitch_node = get_stitch_node(thread); in has_stitched_lbr()
2754 static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr) in alloc_lbr_stitch() argument
2756 if (thread__lbr_stitch(thread)) in alloc_lbr_stitch()
2759 thread__set_lbr_stitch(thread, zalloc(sizeof(struct lbr_stitch))); in alloc_lbr_stitch()
2760 if (!thread__lbr_stitch(thread)) in alloc_lbr_stitch()
2763 thread__lbr_stitch(thread)->prev_lbr_cursor = in alloc_lbr_stitch()
2765 if (!thread__lbr_stitch(thread)->prev_lbr_cursor) in alloc_lbr_stitch()
2768 INIT_LIST_HEAD(&thread__lbr_stitch(thread)->lists); in alloc_lbr_stitch()
2769 INIT_LIST_HEAD(&thread__lbr_stitch(thread)->free_lists); in alloc_lbr_stitch()
2774 free(thread__lbr_stitch(thread)); in alloc_lbr_stitch()
2775 thread__set_lbr_stitch(thread, NULL); in alloc_lbr_stitch()
2778 thread__set_lbr_stitch_enable(thread, false); in alloc_lbr_stitch()
2789 static int resolve_lbr_callchain_sample(struct thread *thread, in resolve_lbr_callchain_sample() argument
2814 if (thread__lbr_stitch_enable(thread) && !sample->no_hw_idx && in resolve_lbr_callchain_sample()
2815 (max_lbr > 0) && alloc_lbr_stitch(thread, max_lbr)) { in resolve_lbr_callchain_sample()
2816 lbr_stitch = thread__lbr_stitch(thread); in resolve_lbr_callchain_sample()
2818 stitched_lbr = has_stitched_lbr(thread, sample, in resolve_lbr_callchain_sample()
2831 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2837 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2843 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2850 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2854 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2860 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2872 static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, in find_prev_cpumode() argument
2884 err = add_callchain_ip(thread, cursor, parent, in find_prev_cpumode()
2894 struct thread *thread, int usr_idx) in get_leaf_frame_caller() argument
2896 if (machine__normalized_is(maps__machine(thread__maps(thread)), "arm64")) in get_leaf_frame_caller()
2897 return get_leaf_frame_caller_aarch64(sample, thread, usr_idx); in get_leaf_frame_caller()
2902 static int thread__resolve_callchain_sample(struct thread *thread, in thread__resolve_callchain_sample() argument
2926 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent, in thread__resolve_callchain_sample()
2937 skip_idx = arch_skip_callchain_idx(thread, chain); in thread__resolve_callchain_sample()
2989 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2996 err = add_callchain_ip(thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
3014 err = find_prev_cpumode(chain, thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
3036 err = find_prev_cpumode(chain, thread, cursor, parent, in thread__resolve_callchain_sample()
3054 leaf_frame_caller = get_leaf_frame_caller(sample, thread, usr_idx); in thread__resolve_callchain_sample()
3063 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
3071 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
3150 static int thread__resolve_callchain_unwind(struct thread *thread, in thread__resolve_callchain_unwind() argument
3167 thread, sample, max_stack, false); in thread__resolve_callchain_unwind()
3170 int thread__resolve_callchain(struct thread *thread, in thread__resolve_callchain() argument
3186 ret = thread__resolve_callchain_sample(thread, cursor, in thread__resolve_callchain()
3192 ret = thread__resolve_callchain_unwind(thread, cursor, in thread__resolve_callchain()
3196 ret = thread__resolve_callchain_unwind(thread, cursor, in thread__resolve_callchain()
3201 ret = thread__resolve_callchain_sample(thread, cursor, in thread__resolve_callchain()
3211 int (*fn)(struct thread *thread, void *p), in machine__for_each_thread() argument
3225 rc = fn(trb->thread, priv); in machine__for_each_thread()
3234 int (*fn)(struct thread *thread, void *p), in machines__for_each_thread() argument
3265 struct thread *thread; in machine__set_current_tid() local
3279 thread = machine__findnew_thread(machine, pid, tid); in machine__set_current_tid()
3280 if (!thread) in machine__set_current_tid()
3283 thread__set_cpu(thread, cpu); in machine__set_current_tid()
3284 thread__put(thread); in machine__set_current_tid()