Lines Matching refs:thread
65 static void thread__set_guest_comm(struct thread *thread, pid_t pid) in thread__set_guest_comm() argument
70 thread__set_comm(thread, comm, 0); in thread__set_guest_comm()
106 struct thread *thread = machine__findnew_thread(machine, -1, in machine__init() local
109 if (thread == NULL) in machine__init()
112 thread__set_guest_comm(thread, pid); in machine__init()
113 thread__put(thread); in machine__init()
348 static struct thread *findnew_guest_code(struct machine *machine, in findnew_guest_code()
352 struct thread *host_thread; in findnew_guest_code()
353 struct thread *thread; in findnew_guest_code() local
359 thread = machine__findnew_thread(machine, -1, pid); in findnew_guest_code()
360 if (!thread) in findnew_guest_code()
364 if (!maps__empty(thread__maps(thread))) in findnew_guest_code()
365 return thread; in findnew_guest_code()
371 thread__set_guest_comm(thread, pid); in findnew_guest_code()
377 err = maps__copy_from(thread__maps(thread), thread__maps(host_thread)); in findnew_guest_code()
382 return thread; in findnew_guest_code()
385 thread__zput(thread); in findnew_guest_code()
389 struct thread *machines__findnew_guest_code(struct machines *machines, pid_t pid) in machines__findnew_guest_code()
397 struct thread *machine__findnew_guest_code(struct machine *machine, pid_t pid) in machine__findnew_guest_code()
438 struct thread *th, pid_t pid) in machine__update_thread_pid()
440 struct thread *leader; in machine__update_thread_pid()
488 static struct thread *__machine__findnew_thread(struct machine *machine, in __machine__findnew_thread()
493 struct thread *th = threads__find(&machine->threads, tid); in __machine__findnew_thread()
525 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid) in machine__findnew_thread()
530 struct thread *machine__find_thread(struct machine *machine, pid_t pid, in machine__find_thread()
543 struct thread *machine__idle_thread(struct machine *machine) in machine__idle_thread()
545 struct thread *thread = machine__findnew_thread(machine, 0, 0); in machine__idle_thread() local
547 if (!thread || thread__set_comm(thread, "swapper", 0) || in machine__idle_thread()
548 thread__set_namespaces(thread, 0, NULL)) in machine__idle_thread()
551 return thread; in machine__idle_thread()
555 struct thread *thread) in machine__thread_exec_comm() argument
558 return thread__exec_comm(thread); in machine__thread_exec_comm()
560 return thread__comm(thread); in machine__thread_exec_comm()
566 struct thread *thread = machine__findnew_thread(machine, in machine__process_comm_event() local
578 if (thread == NULL || in machine__process_comm_event()
579 __thread__set_comm(thread, event->comm.comm, sample->time, exec)) { in machine__process_comm_event()
584 thread__put(thread); in machine__process_comm_event()
593 struct thread *thread = machine__findnew_thread(machine, in machine__process_namespaces_event() local
609 if (thread == NULL || in machine__process_namespaces_event()
610 thread__set_namespaces(thread, sample->time, &event->namespaces)) { in machine__process_namespaces_event()
615 thread__put(thread); in machine__process_namespaces_event()
914 static int machine_fprintf_cb(struct thread *thread, void *data) in machine_fprintf_cb() argument
919 args->printed += thread__fprintf(thread, args->fp); in machine_fprintf_cb()
1697 struct thread *thread; in machine__process_mmap2_event() local
1731 thread = machine__findnew_thread(machine, event->mmap2.pid, in machine__process_mmap2_event()
1733 if (thread == NULL) in machine__process_mmap2_event()
1740 event->mmap2.filename, thread); in machine__process_mmap2_event()
1745 ret = thread__insert_map(thread, map); in machine__process_mmap2_event()
1749 thread__put(thread); in machine__process_mmap2_event()
1756 thread__put(thread); in machine__process_mmap2_event()
1765 struct thread *thread; in machine__process_mmap_event() local
1788 thread = machine__findnew_thread(machine, event->mmap.pid, in machine__process_mmap_event()
1790 if (thread == NULL) in machine__process_mmap_event()
1798 NULL, prot, 0, NULL, event->mmap.filename, thread); in machine__process_mmap_event()
1803 ret = thread__insert_map(thread, map); in machine__process_mmap_event()
1807 thread__put(thread); in machine__process_mmap_event()
1814 thread__put(thread); in machine__process_mmap_event()
1820 void machine__remove_thread(struct machine *machine, struct thread *th) in machine__remove_thread()
1828 struct thread *thread = machine__find_thread(machine, in machine__process_fork_event() local
1831 struct thread *parent = machine__findnew_thread(machine, in machine__process_fork_event()
1856 if (thread != NULL) { in machine__process_fork_event()
1857 machine__remove_thread(machine, thread); in machine__process_fork_event()
1858 thread__put(thread); in machine__process_fork_event()
1861 thread = machine__findnew_thread(machine, event->fork.pid, in machine__process_fork_event()
1880 if (thread == NULL || parent == NULL || in machine__process_fork_event()
1881 thread__fork(thread, parent, sample->time, do_maps_clone) < 0) { in machine__process_fork_event()
1885 thread__put(thread); in machine__process_fork_event()
1894 struct thread *thread = machine__find_thread(machine, in machine__process_exit_event() local
1901 if (thread != NULL) { in machine__process_exit_event()
1903 thread__set_exited(thread, /*exited=*/true); in machine__process_exit_event()
1905 machine__remove_thread(machine, thread); in machine__process_exit_event()
1907 thread__put(thread); in machine__process_exit_event()
1963 static void ip__resolve_ams(struct thread *thread, in ip__resolve_ams() argument
1977 thread__find_cpumode_addr_location(thread, ip, /*symbols=*/true, &al); in ip__resolve_ams()
1990 static void ip__resolve_data(struct thread *thread, in ip__resolve_data() argument
1998 thread__find_symbol(thread, m, addr, &al); in ip__resolve_data()
2019 ip__resolve_ams(al->thread, mem_info__iaddr(mi), sample->ip); in sample__resolve_mem()
2020 ip__resolve_data(al->thread, al->cpumode, mem_info__daddr(mi), in sample__resolve_mem()
2056 static int add_callchain_ip(struct thread *thread, in add_callchain_ip() argument
2079 thread__find_cpumode_addr_location(thread, ip, symbols, &al); in add_callchain_ip()
2106 thread__find_symbol(thread, *cpumode, ip, &al); in add_callchain_ip()
2108 thread__find_map(thread, *cpumode, ip, &al); in add_callchain_ip()
2158 ip__resolve_ams(al->thread, &bi[i].to, entries[i].to); in sample__resolve_bstack()
2159 ip__resolve_ams(al->thread, &bi[i].from, entries[i].from); in sample__resolve_bstack()
2231 static int lbr_callchain_add_kernel_ip(struct thread *thread, in lbr_callchain_add_kernel_ip() argument
2246 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2257 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2268 static void save_lbr_cursor_node(struct thread *thread, in save_lbr_cursor_node() argument
2272 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in save_lbr_cursor_node()
2297 static int lbr_callchain_add_lbr_ip(struct thread *thread, in lbr_callchain_add_lbr_ip() argument
2319 if (thread__lbr_stitch(thread)) { in lbr_callchain_add_lbr_ip()
2334 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2347 if (thread__lbr_stitch(thread) && (cursor->pos != cursor->nr)) { in lbr_callchain_add_lbr_ip()
2359 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2365 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2374 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2380 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2388 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2399 static int lbr_callchain_add_stitched_lbr_ip(struct thread *thread, in lbr_callchain_add_stitched_lbr_ip() argument
2402 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in lbr_callchain_add_stitched_lbr_ip()
2424 static struct stitch_list *get_stitch_node(struct thread *thread) in get_stitch_node() argument
2426 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in get_stitch_node()
2440 static bool has_stitched_lbr(struct thread *thread, in has_stitched_lbr() argument
2450 struct lbr_stitch *lbr_stitch = thread__lbr_stitch(thread); in has_stitched_lbr()
2496 stitch_node = get_stitch_node(thread); in has_stitched_lbr()
2515 static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr) in alloc_lbr_stitch() argument
2517 if (thread__lbr_stitch(thread)) in alloc_lbr_stitch()
2520 thread__set_lbr_stitch(thread, zalloc(sizeof(struct lbr_stitch))); in alloc_lbr_stitch()
2521 if (!thread__lbr_stitch(thread)) in alloc_lbr_stitch()
2524 thread__lbr_stitch(thread)->prev_lbr_cursor = in alloc_lbr_stitch()
2526 if (!thread__lbr_stitch(thread)->prev_lbr_cursor) in alloc_lbr_stitch()
2529 thread__lbr_stitch(thread)->prev_lbr_cursor_size = max_lbr + 1; in alloc_lbr_stitch()
2531 INIT_LIST_HEAD(&thread__lbr_stitch(thread)->lists); in alloc_lbr_stitch()
2532 INIT_LIST_HEAD(&thread__lbr_stitch(thread)->free_lists); in alloc_lbr_stitch()
2537 free(thread__lbr_stitch(thread)); in alloc_lbr_stitch()
2538 thread__set_lbr_stitch(thread, NULL); in alloc_lbr_stitch()
2541 thread__set_lbr_stitch_enable(thread, false); in alloc_lbr_stitch()
2552 static int resolve_lbr_callchain_sample(struct thread *thread, in resolve_lbr_callchain_sample() argument
2578 if (thread__lbr_stitch_enable(thread) && !sample->no_hw_idx && in resolve_lbr_callchain_sample()
2579 (max_lbr > 0) && alloc_lbr_stitch(thread, max_lbr)) { in resolve_lbr_callchain_sample()
2580 lbr_stitch = thread__lbr_stitch(thread); in resolve_lbr_callchain_sample()
2582 stitched_lbr = has_stitched_lbr(thread, sample, in resolve_lbr_callchain_sample()
2599 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2605 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2611 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2618 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2622 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2628 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2640 static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, in find_prev_cpumode() argument
2652 err = add_callchain_ip(thread, cursor, parent, in find_prev_cpumode()
2662 struct thread *thread, int usr_idx) in get_leaf_frame_caller() argument
2664 if (machine__normalized_is(maps__machine(thread__maps(thread)), "arm64")) in get_leaf_frame_caller()
2665 return get_leaf_frame_caller_aarch64(sample, thread, usr_idx); in get_leaf_frame_caller()
2670 static int thread__resolve_callchain_sample(struct thread *thread, in thread__resolve_callchain_sample() argument
2695 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent, in thread__resolve_callchain_sample()
2707 skip_idx = arch_skip_callchain_idx(thread, chain); in thread__resolve_callchain_sample()
2759 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2766 err = add_callchain_ip(thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
2785 err = find_prev_cpumode(chain, thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
2807 err = find_prev_cpumode(chain, thread, cursor, parent, in thread__resolve_callchain_sample()
2825 leaf_frame_caller = get_leaf_frame_caller(sample, thread, usr_idx); in thread__resolve_callchain_sample()
2834 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2842 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2920 static int thread__resolve_callchain_unwind(struct thread *thread, in thread__resolve_callchain_unwind() argument
2940 thread, sample, max_stack, false); in thread__resolve_callchain_unwind()
2943 int __thread__resolve_callchain(struct thread *thread, in __thread__resolve_callchain() argument
2960 ret = thread__resolve_callchain_sample(thread, cursor, in __thread__resolve_callchain()
2966 ret = thread__resolve_callchain_unwind(thread, cursor, in __thread__resolve_callchain()
2970 ret = thread__resolve_callchain_unwind(thread, cursor, in __thread__resolve_callchain()
2975 ret = thread__resolve_callchain_sample(thread, cursor, in __thread__resolve_callchain()
2985 int (*fn)(struct thread *thread, void *p), in machine__for_each_thread() argument
2992 int (*fn)(struct thread *thread, void *p), in machines__for_each_thread() argument
3013 static int thread_list_cb(struct thread *thread, void *data) in thread_list_cb() argument
3021 entry->thread = thread__get(thread); in thread_list_cb()
3036 thread__zput(pos->thread); in thread_list__delete()
3053 struct thread *thread; in machine__set_current_tid() local
3067 thread = machine__findnew_thread(machine, pid, tid); in machine__set_current_tid()
3068 if (!thread) in machine__set_current_tid()
3071 thread__set_cpu(thread, cpu); in machine__set_current_tid()
3072 thread__put(thread); in machine__set_current_tid()