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()
409 struct thread *th, pid_t pid) in machine__update_thread_pid()
411 struct thread *leader; in machine__update_thread_pid()
437 * tid. Consequently there never should be any maps on a thread in machine__update_thread_pid()
441 pr_err("Discarding thread maps for %d:%d\n", in machine__update_thread_pid()
460 static struct thread*
464 struct thread *th; in __threads__get_last_match()
479 static struct thread*
483 struct thread *th = NULL; in threads__get_last_match()
492 __threads__set_last_match(struct threads *threads, struct thread *th) in __threads__set_last_match()
498 threads__set_last_match(struct threads *threads, struct thread *th) in threads__set_last_match()
505 * Caller must eventually drop thread->refcnt returned with a successful
506 * lookup/new thread inserted.
508 static struct thread *____machine__findnew_thread(struct machine *machine, in ____machine__findnew_thread()
515 struct thread *th; in ____machine__findnew_thread()
524 th = rb_entry(parent, struct thread, rb_node); in ____machine__findnew_thread()
552 * within thread__init_maps to find the thread in ____machine__findnew_thread()
572 struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid) in __machine__findnew_thread()
577 struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, in machine__findnew_thread()
581 struct thread *th; in machine__findnew_thread()
589 struct thread *machine__find_thread(struct machine *machine, pid_t pid, in machine__find_thread()
593 struct thread *th; in machine__find_thread()
603 * So here a single thread is created for that, but actually there is a separate
604 * idle task per cpu, so there should be one 'struct thread' per cpu, but there
608 struct thread *machine__idle_thread(struct machine *machine) in machine__idle_thread()
610 struct thread *thread = machine__findnew_thread(machine, 0, 0); in machine__idle_thread() local
612 if (!thread || thread__set_comm(thread, "swapper", 0) || in machine__idle_thread()
613 thread__set_namespaces(thread, 0, NULL)) in machine__idle_thread()
616 return thread; in machine__idle_thread()
620 struct thread *thread) in machine__thread_exec_comm() argument
623 return thread__exec_comm(thread); in machine__thread_exec_comm()
625 return thread__comm(thread); in machine__thread_exec_comm()
631 struct thread *thread = machine__findnew_thread(machine, in machine__process_comm_event() local
643 if (thread == NULL || in machine__process_comm_event()
644 __thread__set_comm(thread, event->comm.comm, sample->time, exec)) { in machine__process_comm_event()
649 thread__put(thread); in machine__process_comm_event()
658 struct thread *thread = machine__findnew_thread(machine, in machine__process_namespaces_event() local
674 if (thread == NULL || in machine__process_namespaces_event()
675 thread__set_namespaces(thread, sample->time, &event->namespaces)) { in machine__process_namespaces_event()
680 thread__put(thread); in machine__process_namespaces_event()
985 struct thread *pos = rb_entry(nd, struct thread, rb_node); in machine__fprintf()
1749 struct thread *thread; in machine__process_mmap2_event() local
1783 thread = machine__findnew_thread(machine, event->mmap2.pid, in machine__process_mmap2_event()
1785 if (thread == NULL) in machine__process_mmap2_event()
1792 event->mmap2.filename, thread); in machine__process_mmap2_event()
1797 ret = thread__insert_map(thread, map); in machine__process_mmap2_event()
1801 thread__put(thread); in machine__process_mmap2_event()
1808 thread__put(thread); in machine__process_mmap2_event()
1817 struct thread *thread; in machine__process_mmap_event() local
1840 thread = machine__findnew_thread(machine, event->mmap.pid, in machine__process_mmap_event()
1842 if (thread == NULL) in machine__process_mmap_event()
1850 NULL, prot, 0, NULL, event->mmap.filename, thread); in machine__process_mmap_event()
1855 ret = thread__insert_map(thread, map); in machine__process_mmap_event()
1859 thread__put(thread); in machine__process_mmap_event()
1866 thread__put(thread); in machine__process_mmap_event()
1872 static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock) in __machine__remove_thread()
1897 * thread. in __machine__remove_thread()
1905 void machine__remove_thread(struct machine *machine, struct thread *th) in machine__remove_thread()
1913 struct thread *thread = machine__find_thread(machine, in machine__process_fork_event() local
1916 struct thread *parent = machine__findnew_thread(machine, in machine__process_fork_event()
1926 * There may be an existing thread that is not actually the parent, in machine__process_fork_event()
1928 * (fork) event that would have removed the thread was lost. Assume the in machine__process_fork_event()
1932 dump_printf("removing erroneous parent thread %d/%d\n", in machine__process_fork_event()
1940 /* if a thread currently exists for the thread id remove it */ in machine__process_fork_event()
1941 if (thread != NULL) { in machine__process_fork_event()
1942 machine__remove_thread(machine, thread); in machine__process_fork_event()
1943 thread__put(thread); in machine__process_fork_event()
1946 thread = machine__findnew_thread(machine, event->fork.pid, in machine__process_fork_event()
1949 * When synthesizing FORK events, we are trying to create thread in machine__process_fork_event()
1965 if (thread == NULL || parent == NULL || in machine__process_fork_event()
1966 thread__fork(thread, parent, sample->time, do_maps_clone) < 0) { in machine__process_fork_event()
1970 thread__put(thread); in machine__process_fork_event()
1979 struct thread *thread = machine__find_thread(machine, in machine__process_exit_event() local
1986 if (thread != NULL) { in machine__process_exit_event()
1987 thread__exited(thread); in machine__process_exit_event()
1988 thread__put(thread); in machine__process_exit_event()
2046 static void ip__resolve_ams(struct thread *thread, in ip__resolve_ams() argument
2060 thread__find_cpumode_addr_location(thread, ip, &al); in ip__resolve_ams()
2071 static void ip__resolve_data(struct thread *thread, in ip__resolve_data() argument
2079 thread__find_symbol(thread, m, addr, &al); in ip__resolve_data()
2098 ip__resolve_ams(al->thread, &mi->iaddr, sample->ip); in sample__resolve_mem()
2099 ip__resolve_data(al->thread, al->cpumode, &mi->daddr, in sample__resolve_mem()
2133 static int add_callchain_ip(struct thread *thread, in add_callchain_ip() argument
2154 thread__find_cpumode_addr_location(thread, ip, &al); in add_callchain_ip()
2179 thread__find_symbol(thread, *cpumode, ip, &al); in add_callchain_ip()
2224 ip__resolve_ams(al->thread, &bi[i].to, entries[i].to); in sample__resolve_bstack()
2225 ip__resolve_ams(al->thread, &bi[i].from, entries[i].from); in sample__resolve_bstack()
2295 static int lbr_callchain_add_kernel_ip(struct thread *thread, in lbr_callchain_add_kernel_ip() argument
2309 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2319 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_kernel_ip()
2329 static void save_lbr_cursor_node(struct thread *thread, in save_lbr_cursor_node() argument
2333 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in save_lbr_cursor_node()
2354 static int lbr_callchain_add_lbr_ip(struct thread *thread, in lbr_callchain_add_lbr_ip() argument
2375 if (thread->lbr_stitch) { in lbr_callchain_add_lbr_ip()
2390 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2403 if (thread->lbr_stitch && (cursor->pos != cursor->nr)) { in lbr_callchain_add_lbr_ip()
2415 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2421 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2430 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2436 save_lbr_cursor_node(thread, cursor, i); in lbr_callchain_add_lbr_ip()
2443 err = add_callchain_ip(thread, cursor, parent, in lbr_callchain_add_lbr_ip()
2453 static int lbr_callchain_add_stitched_lbr_ip(struct thread *thread, in lbr_callchain_add_stitched_lbr_ip() argument
2456 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in lbr_callchain_add_stitched_lbr_ip()
2478 static struct stitch_list *get_stitch_node(struct thread *thread) in get_stitch_node() argument
2480 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in get_stitch_node()
2494 static bool has_stitched_lbr(struct thread *thread, in has_stitched_lbr() argument
2504 struct lbr_stitch *lbr_stitch = thread->lbr_stitch; in has_stitched_lbr()
2550 stitch_node = get_stitch_node(thread); in has_stitched_lbr()
2566 static bool alloc_lbr_stitch(struct thread *thread, unsigned int max_lbr) in alloc_lbr_stitch() argument
2568 if (thread->lbr_stitch) in alloc_lbr_stitch()
2571 thread->lbr_stitch = zalloc(sizeof(*thread->lbr_stitch)); in alloc_lbr_stitch()
2572 if (!thread->lbr_stitch) in alloc_lbr_stitch()
2575 thread->lbr_stitch->prev_lbr_cursor = calloc(max_lbr + 1, sizeof(struct callchain_cursor_node)); in alloc_lbr_stitch()
2576 if (!thread->lbr_stitch->prev_lbr_cursor) in alloc_lbr_stitch()
2579 INIT_LIST_HEAD(&thread->lbr_stitch->lists); in alloc_lbr_stitch()
2580 INIT_LIST_HEAD(&thread->lbr_stitch->free_lists); in alloc_lbr_stitch()
2585 zfree(&thread->lbr_stitch); in alloc_lbr_stitch()
2588 thread->lbr_stitch_enable = false; in alloc_lbr_stitch()
2599 static int resolve_lbr_callchain_sample(struct thread *thread, in resolve_lbr_callchain_sample() argument
2624 if (thread->lbr_stitch_enable && !sample->no_hw_idx && in resolve_lbr_callchain_sample()
2625 (max_lbr > 0) && alloc_lbr_stitch(thread, max_lbr)) { in resolve_lbr_callchain_sample()
2626 lbr_stitch = thread->lbr_stitch; in resolve_lbr_callchain_sample()
2628 stitched_lbr = has_stitched_lbr(thread, sample, in resolve_lbr_callchain_sample()
2641 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2647 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2653 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2660 err = lbr_callchain_add_stitched_lbr_ip(thread, cursor); in resolve_lbr_callchain_sample()
2664 err = lbr_callchain_add_lbr_ip(thread, cursor, sample, parent, in resolve_lbr_callchain_sample()
2670 err = lbr_callchain_add_kernel_ip(thread, cursor, sample, in resolve_lbr_callchain_sample()
2682 static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread, in find_prev_cpumode() argument
2694 err = add_callchain_ip(thread, cursor, parent, in find_prev_cpumode()
2703 static int thread__resolve_callchain_sample(struct thread *thread, in thread__resolve_callchain_sample() argument
2726 err = resolve_lbr_callchain_sample(thread, cursor, sample, parent, in thread__resolve_callchain_sample()
2737 skip_idx = arch_skip_callchain_idx(thread, chain); in thread__resolve_callchain_sample()
2789 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2796 err = add_callchain_ip(thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
2814 err = find_prev_cpumode(chain, thread, cursor, parent, root_al, in thread__resolve_callchain_sample()
2836 err = find_prev_cpumode(chain, thread, cursor, parent, in thread__resolve_callchain_sample()
2843 err = add_callchain_ip(thread, cursor, parent, in thread__resolve_callchain_sample()
2917 static int thread__resolve_callchain_unwind(struct thread *thread, in thread__resolve_callchain_unwind() argument
2934 thread, sample, max_stack); in thread__resolve_callchain_unwind()
2937 int thread__resolve_callchain(struct thread *thread, in thread__resolve_callchain() argument
2950 ret = thread__resolve_callchain_sample(thread, cursor, in thread__resolve_callchain()
2956 ret = thread__resolve_callchain_unwind(thread, cursor, in thread__resolve_callchain()
2960 ret = thread__resolve_callchain_unwind(thread, cursor, in thread__resolve_callchain()
2965 ret = thread__resolve_callchain_sample(thread, cursor, in thread__resolve_callchain()
2975 int (*fn)(struct thread *thread, void *p), in machine__for_each_thread() argument
2980 struct thread *thread; in machine__for_each_thread() local
2988 thread = rb_entry(nd, struct thread, rb_node); in machine__for_each_thread()
2989 rc = fn(thread, priv); in machine__for_each_thread()
2994 list_for_each_entry(thread, &threads->dead, node) { in machine__for_each_thread()
2995 rc = fn(thread, priv); in machine__for_each_thread()
3004 int (*fn)(struct thread *thread, void *p), in machines__for_each_thread() argument
3037 struct thread *thread; in machine__set_current_tid() local
3061 thread = machine__findnew_thread(machine, pid, tid); in machine__set_current_tid()
3062 if (!thread) in machine__set_current_tid()
3065 thread->cpu = cpu; in machine__set_current_tid()
3066 thread__put(thread); in machine__set_current_tid()