Lines Matching refs:thread
126 static struct thread_stack *thread_stack__new(struct thread *thread, in thread_stack__new() argument
140 if (thread->mg && thread->mg->machine) in thread_stack__new()
141 ts->kernel_start = machine__kernel_start(thread->mg->machine); in thread_stack__new()
195 static int thread_stack__call_return(struct thread *thread, in thread_stack__call_return() argument
202 .thread = thread, in thread_stack__call_return()
222 static int thread_stack__flush(struct thread *thread, struct thread_stack *ts) in thread_stack__flush() argument
233 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__flush()
245 int thread_stack__event(struct thread *thread, u32 flags, u64 from_ip, in thread_stack__event() argument
248 if (!thread) in thread_stack__event()
251 if (!thread->ts) { in thread_stack__event()
252 thread->ts = thread_stack__new(thread, NULL); in thread_stack__event()
253 if (!thread->ts) { in thread_stack__event()
257 thread->ts->trace_nr = trace_nr; in thread_stack__event()
265 if (trace_nr != thread->ts->trace_nr) { in thread_stack__event()
266 if (thread->ts->trace_nr) in thread_stack__event()
267 thread_stack__flush(thread, thread->ts); in thread_stack__event()
268 thread->ts->trace_nr = trace_nr; in thread_stack__event()
272 if (thread->ts->crp) in thread_stack__event()
283 return thread_stack__push(thread->ts, ret_addr); in thread_stack__event()
287 thread_stack__pop(thread->ts, to_ip); in thread_stack__event()
293 void thread_stack__set_trace_nr(struct thread *thread, u64 trace_nr) in thread_stack__set_trace_nr() argument
295 if (!thread || !thread->ts) in thread_stack__set_trace_nr()
298 if (trace_nr != thread->ts->trace_nr) { in thread_stack__set_trace_nr()
299 if (thread->ts->trace_nr) in thread_stack__set_trace_nr()
300 thread_stack__flush(thread, thread->ts); in thread_stack__set_trace_nr()
301 thread->ts->trace_nr = trace_nr; in thread_stack__set_trace_nr()
305 void thread_stack__free(struct thread *thread) in thread_stack__free() argument
307 if (thread->ts) { in thread_stack__free()
308 thread_stack__flush(thread, thread->ts); in thread_stack__free()
309 zfree(&thread->ts->stack); in thread_stack__free()
310 zfree(&thread->ts); in thread_stack__free()
314 void thread_stack__sample(struct thread *thread, struct ip_callchain *chain, in thread_stack__sample() argument
319 if (!thread || !thread->ts) in thread_stack__sample()
322 chain->nr = min(sz, thread->ts->cnt + 1); in thread_stack__sample()
327 chain->ips[i] = thread->ts->stack[thread->ts->cnt - i].ret_addr; in thread_stack__sample()
485 static int thread_stack__pop_cp(struct thread *thread, struct thread_stack *ts, in thread_stack__pop_cp() argument
498 return thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_cp()
503 return thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_cp()
513 err = thread_stack__call_return(thread, ts, in thread_stack__pop_cp()
520 return thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__pop_cp()
528 static int thread_stack__bottom(struct thread *thread, struct thread_stack *ts, in thread_stack__bottom() argument
553 return thread_stack__push_cp(thread->ts, ip, sample->time, ref, cp, in thread_stack__bottom()
557 static int thread_stack__no_call_return(struct thread *thread, in thread_stack__no_call_return() argument
571 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__no_call_return()
591 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__no_call_return()
615 return thread_stack__pop_cp(thread, ts, sample->addr, sample->time, ref, in thread_stack__no_call_return()
619 static int thread_stack__trace_begin(struct thread *thread, in thread_stack__trace_begin() argument
632 err = thread_stack__call_return(thread, ts, --ts->cnt, in thread_stack__trace_begin()
663 int thread_stack__process(struct thread *thread, struct comm *comm, in thread_stack__process() argument
669 struct thread_stack *ts = thread->ts; in thread_stack__process()
675 thread_stack__free(thread); in thread_stack__process()
676 thread->ts = thread_stack__new(thread, crp); in thread_stack__process()
677 if (!thread->ts) in thread_stack__process()
679 ts = thread->ts; in thread_stack__process()
683 thread->ts = thread_stack__new(thread, crp); in thread_stack__process()
684 if (!thread->ts) in thread_stack__process()
686 ts = thread->ts; in thread_stack__process()
691 if (ts->comm != comm && thread->pid_ == thread->tid) { in thread_stack__process()
692 err = thread_stack__flush(thread, ts); in thread_stack__process()
700 err = thread_stack__bottom(thread, ts, sample, from_al, to_al, in thread_stack__process()
732 err = thread_stack__pop_cp(thread, ts, sample->addr, in thread_stack__process()
737 err = thread_stack__no_call_return(thread, ts, sample, in thread_stack__process()
741 err = thread_stack__trace_begin(thread, ts, sample->time, ref); in thread_stack__process()