Linux Audio

Check our new training course

Loading...
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * thread-stack.h: Synthesize a thread's stack using call / return events
  4 * Copyright (c) 2014, Intel Corporation.
 
 
 
 
 
 
 
 
 
 
  5 */
  6
  7#ifndef __PERF_THREAD_STACK_H
  8#define __PERF_THREAD_STACK_H
  9
 10#include <sys/types.h>
 11
 12#include <linux/types.h>
 13
 14struct thread;
 15struct comm;
 16struct ip_callchain;
 17struct symbol;
 18struct dso;
 19struct comm;
 20struct perf_sample;
 21struct addr_location;
 22struct call_path;
 23
 24/*
 25 * Call/Return flags.
 26 *
 27 * CALL_RETURN_NO_CALL: 'return' but no matching 'call'
 28 * CALL_RETURN_NO_RETURN: 'call' but no matching 'return'
 29 * CALL_RETURN_NON_CALL: a branch but not a 'call' to the start of a different
 30 *                       symbol
 31 */
 32enum {
 33	CALL_RETURN_NO_CALL	= 1 << 0,
 34	CALL_RETURN_NO_RETURN	= 1 << 1,
 35	CALL_RETURN_NON_CALL	= 1 << 2,
 36};
 37
 38/**
 39 * struct call_return - paired call/return information.
 40 * @thread: thread in which call/return occurred
 41 * @comm: comm in which call/return occurred
 42 * @cp: call path
 43 * @call_time: timestamp of call (if known)
 44 * @return_time: timestamp of return (if known)
 45 * @branch_count: number of branches seen between call and return
 46 * @insn_count: approx. number of instructions between call and return
 47 * @cyc_count: approx. number of cycles between call and return
 48 * @call_ref: external reference to 'call' sample (e.g. db_id)
 49 * @return_ref:  external reference to 'return' sample (e.g. db_id)
 50 * @db_id: id used for db-export
 51 * @parent_db_id: id of parent call used for db-export
 52 * @flags: Call/Return flags
 53 */
 54struct call_return {
 55	struct thread *thread;
 56	struct comm *comm;
 57	struct call_path *cp;
 58	u64 call_time;
 59	u64 return_time;
 60	u64 branch_count;
 61	u64 insn_count;
 62	u64 cyc_count;
 63	u64 call_ref;
 64	u64 return_ref;
 65	u64 db_id;
 66	u64 parent_db_id;
 67	u32 flags;
 68};
 69
 70/**
 71 * struct call_return_processor - provides a call-back to consume call-return
 72 *                                information.
 73 * @cpr: call path root
 74 * @process: call-back that accepts call/return information
 75 * @data: anonymous data for call-back
 76 */
 77struct call_return_processor {
 78	struct call_path_root *cpr;
 79	int (*process)(struct call_return *cr, u64 *parent_db_id, void *data);
 80	void *data;
 81};
 82
 83int thread_stack__event(struct thread *thread, int cpu, u32 flags, u64 from_ip,
 84			u64 to_ip, u16 insn_len, u64 trace_nr);
 85void thread_stack__set_trace_nr(struct thread *thread, int cpu, u64 trace_nr);
 86void thread_stack__sample(struct thread *thread, int cpu, struct ip_callchain *chain,
 87			  size_t sz, u64 ip, u64 kernel_start);
 88int thread_stack__flush(struct thread *thread);
 89void thread_stack__free(struct thread *thread);
 90size_t thread_stack__depth(struct thread *thread, int cpu);
 91
 92struct call_return_processor *
 93call_return_processor__new(int (*process)(struct call_return *cr, u64 *parent_db_id, void *data),
 94			   void *data);
 95void call_return_processor__free(struct call_return_processor *crp);
 96int thread_stack__process(struct thread *thread, struct comm *comm,
 97			  struct perf_sample *sample,
 98			  struct addr_location *from_al,
 99			  struct addr_location *to_al, u64 ref,
100			  struct call_return_processor *crp);
101
102#endif
v4.10.11
 
  1/*
  2 * thread-stack.h: Synthesize a thread's stack using call / return events
  3 * Copyright (c) 2014, Intel Corporation.
  4 *
  5 * This program is free software; you can redistribute it and/or modify it
  6 * under the terms and conditions of the GNU General Public License,
  7 * version 2, as published by the Free Software Foundation.
  8 *
  9 * This program is distributed in the hope it will be useful, but WITHOUT
 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 12 * more details.
 13 *
 14 */
 15
 16#ifndef __PERF_THREAD_STACK_H
 17#define __PERF_THREAD_STACK_H
 18
 19#include <sys/types.h>
 20
 21#include <linux/types.h>
 22
 23struct thread;
 24struct comm;
 25struct ip_callchain;
 26struct symbol;
 27struct dso;
 28struct comm;
 29struct perf_sample;
 30struct addr_location;
 31struct call_path;
 32
 33/*
 34 * Call/Return flags.
 35 *
 36 * CALL_RETURN_NO_CALL: 'return' but no matching 'call'
 37 * CALL_RETURN_NO_RETURN: 'call' but no matching 'return'
 
 
 38 */
 39enum {
 40	CALL_RETURN_NO_CALL	= 1 << 0,
 41	CALL_RETURN_NO_RETURN	= 1 << 1,
 
 42};
 43
 44/**
 45 * struct call_return - paired call/return information.
 46 * @thread: thread in which call/return occurred
 47 * @comm: comm in which call/return occurred
 48 * @cp: call path
 49 * @call_time: timestamp of call (if known)
 50 * @return_time: timestamp of return (if known)
 51 * @branch_count: number of branches seen between call and return
 
 
 52 * @call_ref: external reference to 'call' sample (e.g. db_id)
 53 * @return_ref:  external reference to 'return' sample (e.g. db_id)
 54 * @db_id: id used for db-export
 
 55 * @flags: Call/Return flags
 56 */
 57struct call_return {
 58	struct thread *thread;
 59	struct comm *comm;
 60	struct call_path *cp;
 61	u64 call_time;
 62	u64 return_time;
 63	u64 branch_count;
 
 
 64	u64 call_ref;
 65	u64 return_ref;
 66	u64 db_id;
 
 67	u32 flags;
 68};
 69
 70/**
 71 * struct call_return_processor - provides a call-back to consume call-return
 72 *                                information.
 73 * @cpr: call path root
 74 * @process: call-back that accepts call/return information
 75 * @data: anonymous data for call-back
 76 */
 77struct call_return_processor {
 78	struct call_path_root *cpr;
 79	int (*process)(struct call_return *cr, void *data);
 80	void *data;
 81};
 82
 83int thread_stack__event(struct thread *thread, u32 flags, u64 from_ip,
 84			u64 to_ip, u16 insn_len, u64 trace_nr);
 85void thread_stack__set_trace_nr(struct thread *thread, u64 trace_nr);
 86void thread_stack__sample(struct thread *thread, struct ip_callchain *chain,
 87			  size_t sz, u64 ip);
 88int thread_stack__flush(struct thread *thread);
 89void thread_stack__free(struct thread *thread);
 90size_t thread_stack__depth(struct thread *thread);
 91
 92struct call_return_processor *
 93call_return_processor__new(int (*process)(struct call_return *cr, void *data),
 94			   void *data);
 95void call_return_processor__free(struct call_return_processor *crp);
 96int thread_stack__process(struct thread *thread, struct comm *comm,
 97			  struct perf_sample *sample,
 98			  struct addr_location *from_al,
 99			  struct addr_location *to_al, u64 ref,
100			  struct call_return_processor *crp);
101
102#endif