Lines Matching full:thread
3 * thread-stack.c: Synthesize a thread's stack using call / return events
14 #include "thread.h"
22 #include "thread-stack.h"
40 * struct thread_stack_entry - thread stack entry.
68 * struct thread_stack - thread stack constructed from 'call' and 'return'
113 static inline bool thread_stack__per_cpu(struct thread *thread) in thread_stack__per_cpu() argument
115 return !(thread__tid(thread) || thread__pid(thread)); in thread_stack__per_cpu()
136 static int thread_stack__init(struct thread_stack *ts, struct thread *thread, in thread_stack__init() argument
158 if (thread__maps(thread) && maps__machine(thread__maps(thread))) { in thread_stack__init()
159 struct machine *machine = maps__machine(thread__maps(thread)); in thread_stack__init()
173 static struct thread_stack *thread_stack__new(struct thread *thread, int cpu, in thread_stack__new() argument
178 struct thread_stack *ts = thread__ts(thread), *new_ts; in thread_stack__new()
182 if (thread_stack__per_cpu(thread) && cpu > 0) in thread_stack__new()
192 free(thread__ts(thread)); in thread_stack__new()
193 thread__set_ts(thread, new_ts); in thread_stack__new()
197 if (thread_stack__per_cpu(thread) && cpu > 0 && in thread_stack__new()
202 thread_stack__init(ts, thread, crp, callstack, br_stack_sz)) in thread_stack__new()
208 static struct thread_stack *thread__cpu_stack(struct thread *thread, int cpu) in thread__cpu_stack() argument
210 struct thread_stack *ts = thread__ts(thread); in thread__cpu_stack()
226 static inline struct thread_stack *thread__stack(struct thread *thread, in thread__stack() argument
229 if (!thread) in thread__stack()
232 if (thread_stack__per_cpu(thread)) in thread__stack()
233 return thread__cpu_stack(thread, cpu); in thread__stack()
235 return thread__ts(thread); in thread__stack()
246 pr_warning("Out of memory: discarding thread stack\n"); in thread_stack__push()
298 static int thread_stack__call_return(struct thread *thread, in thread_stack__call_return() argument
305 .thread = thread, in thread_stack__call_return()
338 static int __thread_stack__flush(struct thread *thread, struct thread_stack *ts) in __thread_stack__flush() argument
352 err = thread_stack__call_return(thread, ts, --ts->cnt, in __thread_stack__flush()
355 pr_err("Error flushing thread stack!\n"); in __thread_stack__flush()
364 int thread_stack__flush(struct thread *thread) in thread_stack__flush() argument
366 struct thread_stack *ts = thread__ts(thread); in thread_stack__flush()
372 int ret = __thread_stack__flush(thread, ts + pos); in thread_stack__flush()
406 int thread_stack__event(struct thread *thread, int cpu, u32 flags, u64 from_ip, in thread_stack__event() argument
410 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__event()
412 if (!thread) in thread_stack__event()
416 ts = thread_stack__new(thread, cpu, NULL, callstack, br_stack_sz); in thread_stack__event()
418 pr_warning("Out of memory: no thread stack\n"); in thread_stack__event()
432 __thread_stack__flush(thread, ts); in thread_stack__event()
473 void thread_stack__set_trace_nr(struct thread *thread, int cpu, u64 trace_nr) in thread_stack__set_trace_nr() argument
475 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__set_trace_nr()
482 __thread_stack__flush(thread, ts); in thread_stack__set_trace_nr()
487 static void __thread_stack__free(struct thread *thread, struct thread_stack *ts) in __thread_stack__free() argument
489 __thread_stack__flush(thread, ts); in __thread_stack__free()
494 static void thread_stack__reset(struct thread *thread, struct thread_stack *ts) in thread_stack__reset() argument
498 __thread_stack__free(thread, ts); in thread_stack__reset()
503 void thread_stack__free(struct thread *thread) in thread_stack__free() argument
505 struct thread_stack *ts = thread__ts(thread); in thread_stack__free()
510 __thread_stack__free(thread, ts + pos); in thread_stack__free()
511 free(thread__ts(thread)); in thread_stack__free()
512 thread__set_ts(thread, NULL); in thread_stack__free()
521 void thread_stack__sample(struct thread *thread, int cpu, in thread_stack__sample() argument
525 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__sample()
564 void thread_stack__sample_late(struct thread *thread, int cpu, in thread_stack__sample_late() argument
568 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__sample_late()
617 void thread_stack__br_sample(struct thread *thread, int cpu, in thread_stack__br_sample() argument
620 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__br_sample()
678 void thread_stack__br_sample_late(struct thread *thread, int cpu, in thread_stack__br_sample_late() argument
682 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__br_sample_late()
814 static int thread_stack__pop_cp(struct thread *thread, struct thread_stack *ts, in thread_stack__pop_cp() argument
827 return thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_cp()
833 return thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_cp()
844 err = thread_stack__call_return(thread, ts, in thread_stack__pop_cp()
851 return thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_cp()
886 static int thread_stack__pop_ks(struct thread *thread, struct thread_stack *ts, in thread_stack__pop_ks() argument
894 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_ks()
903 static int thread_stack__no_call_return(struct thread *thread, in thread_stack__no_call_return() argument
922 err = thread_stack__pop_ks(thread, ts, sample, ref); in thread_stack__no_call_return()
934 err = thread_stack__pop_ks(thread, ts, sample, ref); in thread_stack__no_call_return()
951 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__no_call_return()
994 return thread_stack__call_return(thread, ts, --ts->cnt, tm, ref, false); in thread_stack__no_call_return()
997 static int thread_stack__trace_begin(struct thread *thread, in thread_stack__trace_begin() argument
1010 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__trace_begin()
1101 int thread_stack__process(struct thread *thread, struct comm *comm, in thread_stack__process() argument
1107 struct thread_stack *ts = thread__stack(thread, sample->cpu); in thread_stack__process()
1113 thread_stack__reset(thread, ts); in thread_stack__process()
1118 ts = thread_stack__new(thread, sample->cpu, crp, true, 0); in thread_stack__process()
1129 if (ts->comm != comm && thread__pid(thread) == thread__tid(thread)) { in thread_stack__process()
1130 err = __thread_stack__flush(thread, ts); in thread_stack__process()
1185 return thread_stack__pop_ks(thread, ts, sample, ref); in thread_stack__process()
1196 err = thread_stack__pop_cp(thread, ts, sample->addr, in thread_stack__process()
1201 err = thread_stack__no_call_return(thread, ts, sample, in thread_stack__process()
1205 err = thread_stack__trace_begin(thread, ts, sample->time, ref); in thread_stack__process()
1232 size_t thread_stack__depth(struct thread *thread, int cpu) in thread_stack__depth() argument
1234 struct thread_stack *ts = thread__stack(thread, cpu); in thread_stack__depth()