Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf annotate: Move the data structures related to register type to header file

Data type profiling uses instruction tracking by checking each
instruction and updating the register type state in some data
structures.

This is useful to find the data type in cases when the register state
gets transferred from one reg to another.

Example, in x86, "mov" instruction and in powerpc, "mr" instruction.

Currently these structures are defined in annotate-data.c and
instruction tracking is implemented only for x86.

Move these data structures to "annotate-data.h" header file so that
other arch implementations can use it in arch specific files as well.

Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Kajol Jain <kjain@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Akanksha J N <akanksha@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Link: https://lore.kernel.org/lkml/20240718084358.72242-2-atrajeev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Athira Rajeev and committed by
Arnaldo Carvalho de Melo
1d303dee e293f4b1

+57 -52
+1 -52
tools/perf/util/annotate-data.c
··· 31 31 32 32 static void delete_var_types(struct die_var_type *var_types); 33 33 34 - enum type_state_kind { 35 - TSR_KIND_INVALID = 0, 36 - TSR_KIND_TYPE, 37 - TSR_KIND_PERCPU_BASE, 38 - TSR_KIND_CONST, 39 - TSR_KIND_POINTER, 40 - TSR_KIND_CANARY, 41 - }; 42 - 43 34 #define pr_debug_dtp(fmt, ...) \ 44 35 do { \ 45 36 if (debug_type_profile) \ ··· 131 140 } 132 141 } 133 142 134 - /* 135 - * Type information in a register, valid when @ok is true. 136 - * The @caller_saved registers are invalidated after a function call. 137 - */ 138 - struct type_state_reg { 139 - Dwarf_Die type; 140 - u32 imm_value; 141 - bool ok; 142 - bool caller_saved; 143 - u8 kind; 144 - }; 145 - 146 - /* Type information in a stack location, dynamically allocated */ 147 - struct type_state_stack { 148 - struct list_head list; 149 - Dwarf_Die type; 150 - int offset; 151 - int size; 152 - bool compound; 153 - u8 kind; 154 - }; 155 - 156 - /* FIXME: This should be arch-dependent */ 157 - #define TYPE_STATE_MAX_REGS 16 158 - 159 - /* 160 - * State table to maintain type info in each register and stack location. 161 - * It'll be updated when new variable is allocated or type info is moved 162 - * to a new location (register or stack). As it'd be used with the 163 - * shortest path of basic blocks, it only maintains a single table. 164 - */ 165 - struct type_state { 166 - /* state of general purpose registers */ 167 - struct type_state_reg regs[TYPE_STATE_MAX_REGS]; 168 - /* state of stack location */ 169 - struct list_head stack_vars; 170 - /* return value register */ 171 - int ret_reg; 172 - /* stack pointer register */ 173 - int stack_reg; 174 - }; 175 - 176 - static bool has_reg_type(struct type_state *state, int reg) 143 + bool has_reg_type(struct type_state *state, int reg) 177 144 { 178 145 return (unsigned)reg < ARRAY_SIZE(state->regs); 179 146 }
+56
tools/perf/util/annotate-data.h
··· 6 6 #include <linux/compiler.h> 7 7 #include <linux/rbtree.h> 8 8 #include <linux/types.h> 9 + #include "annotate.h" 10 + 11 + #ifdef HAVE_DWARF_SUPPORT 12 + #include "debuginfo.h" 13 + #endif 9 14 10 15 struct annotated_op_loc; 11 16 struct debuginfo; ··· 19 14 struct hist_entry; 20 15 struct map_symbol; 21 16 struct thread; 17 + 18 + enum type_state_kind { 19 + TSR_KIND_INVALID = 0, 20 + TSR_KIND_TYPE, 21 + TSR_KIND_PERCPU_BASE, 22 + TSR_KIND_CONST, 23 + TSR_KIND_POINTER, 24 + TSR_KIND_CANARY, 25 + }; 22 26 23 27 /** 24 28 * struct annotated_member - Type of member field ··· 157 143 extern struct annotated_data_stat ann_data_stat; 158 144 159 145 #ifdef HAVE_DWARF_SUPPORT 146 + /* 147 + * Type information in a register, valid when @ok is true. 148 + * The @caller_saved registers are invalidated after a function call. 149 + */ 150 + struct type_state_reg { 151 + Dwarf_Die type; 152 + u32 imm_value; 153 + bool ok; 154 + bool caller_saved; 155 + u8 kind; 156 + }; 157 + 158 + /* Type information in a stack location, dynamically allocated */ 159 + struct type_state_stack { 160 + struct list_head list; 161 + Dwarf_Die type; 162 + int offset; 163 + int size; 164 + bool compound; 165 + u8 kind; 166 + }; 167 + 168 + /* FIXME: This should be arch-dependent */ 169 + #define TYPE_STATE_MAX_REGS 16 170 + 171 + /* 172 + * State table to maintain type info in each register and stack location. 173 + * It'll be updated when new variable is allocated or type info is moved 174 + * to a new location (register or stack). As it'd be used with the 175 + * shortest path of basic blocks, it only maintains a single table. 176 + */ 177 + struct type_state { 178 + /* state of general purpose registers */ 179 + struct type_state_reg regs[TYPE_STATE_MAX_REGS]; 180 + /* state of stack location */ 181 + struct list_head stack_vars; 182 + /* return value register */ 183 + int ret_reg; 184 + /* stack pointer register */ 185 + int stack_reg; 186 + }; 160 187 161 188 /* Returns data type at the location (ip, reg, offset) */ 162 189 struct annotated_data_type *find_data_type(struct data_loc_info *dloc); ··· 215 160 216 161 int hist_entry__annotate_data_tty(struct hist_entry *he, struct evsel *evsel); 217 162 163 + bool has_reg_type(struct type_state *state, int reg); 218 164 #else /* HAVE_DWARF_SUPPORT */ 219 165 220 166 static inline struct annotated_data_type *