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