hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/tools/perf/util/thread-stack.h
....@@ -1,16 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * thread-stack.h: Synthesize a thread's stack using call / return events
34 * 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
- *
145 */
156
167 #ifndef __PERF_THREAD_STACK_H
....@@ -35,10 +26,13 @@
3526 *
3627 * CALL_RETURN_NO_CALL: 'return' but no matching 'call'
3728 * 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
3831 */
3932 enum {
4033 CALL_RETURN_NO_CALL = 1 << 0,
4134 CALL_RETURN_NO_RETURN = 1 << 1,
35
+ CALL_RETURN_NON_CALL = 1 << 2,
4236 };
4337
4438 /**
....@@ -49,9 +43,12 @@
4943 * @call_time: timestamp of call (if known)
5044 * @return_time: timestamp of return (if known)
5145 * @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
5248 * @call_ref: external reference to 'call' sample (e.g. db_id)
5349 * @return_ref: external reference to 'return' sample (e.g. db_id)
5450 * @db_id: id used for db-export
51
+ * @parent_db_id: id of parent call used for db-export
5552 * @flags: Call/Return flags
5653 */
5754 struct call_return {
....@@ -61,9 +58,12 @@
6158 u64 call_time;
6259 u64 return_time;
6360 u64 branch_count;
61
+ u64 insn_count;
62
+ u64 cyc_count;
6463 u64 call_ref;
6564 u64 return_ref;
6665 u64 db_id;
66
+ u64 parent_db_id;
6767 u32 flags;
6868 };
6969
....@@ -76,21 +76,30 @@
7676 */
7777 struct call_return_processor {
7878 struct call_path_root *cpr;
79
- int (*process)(struct call_return *cr, void *data);
79
+ int (*process)(struct call_return *cr, u64 *parent_db_id, void *data);
8080 void *data;
8181 };
8282
83
-int thread_stack__event(struct thread *thread, u32 flags, u64 from_ip,
84
- u64 to_ip, u16 insn_len, u64 trace_nr);
85
-void thread_stack__set_trace_nr(struct thread *thread, u64 trace_nr);
86
-void thread_stack__sample(struct thread *thread, struct ip_callchain *chain,
83
+int thread_stack__event(struct thread *thread, int cpu, u32 flags, u64 from_ip,
84
+ u64 to_ip, u16 insn_len, u64 trace_nr, bool callstack,
85
+ unsigned int br_stack_sz, bool mispred_all);
86
+void thread_stack__set_trace_nr(struct thread *thread, int cpu, u64 trace_nr);
87
+void thread_stack__sample(struct thread *thread, int cpu, struct ip_callchain *chain,
8788 size_t sz, u64 ip, u64 kernel_start);
89
+void thread_stack__sample_late(struct thread *thread, int cpu,
90
+ struct ip_callchain *chain, size_t sz, u64 ip,
91
+ u64 kernel_start);
92
+void thread_stack__br_sample(struct thread *thread, int cpu,
93
+ struct branch_stack *dst, unsigned int sz);
94
+void thread_stack__br_sample_late(struct thread *thread, int cpu,
95
+ struct branch_stack *dst, unsigned int sz,
96
+ u64 sample_ip, u64 kernel_start);
8897 int thread_stack__flush(struct thread *thread);
8998 void thread_stack__free(struct thread *thread);
90
-size_t thread_stack__depth(struct thread *thread);
99
+size_t thread_stack__depth(struct thread *thread, int cpu);
91100
92101 struct call_return_processor *
93
-call_return_processor__new(int (*process)(struct call_return *cr, void *data),
102
+call_return_processor__new(int (*process)(struct call_return *cr, u64 *parent_db_id, void *data),
94103 void *data);
95104 void call_return_processor__free(struct call_return_processor *crp);
96105 int thread_stack__process(struct thread *thread, struct comm *comm,