From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Ian Rogers <irogers@google.com>,
Segher Boessenkool <segher@kernel.crashing.org>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
akanksha@linux.ibm.com, maddy@linux.ibm.com, kjain@linux.ibm.com,
disgoel@linux.vnet.ibm.com
Subject: Re: [V4 01/16] tools/perf: Move the data structures related to register type to header file
Date: Tue, 25 Jun 2024 16:24:58 +0530 [thread overview]
Message-ID: <0AF30B3F-AD13-4398-AC0F-AA6B5425D4AA@linux.vnet.ibm.com> (raw)
In-Reply-To: <ZnpShR7zd9cVdxSj@google.com>
> On 25 Jun 2024, at 10:45 AM, Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> On Fri, Jun 14, 2024 at 10:56:16PM +0530, Athira Rajeev wrote:
>> 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.
>>
>> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
>> ---
>> tools/perf/util/annotate-data.c | 53 +------------------------------
>> tools/perf/util/annotate-data.h | 55 +++++++++++++++++++++++++++++++++
>> 2 files changed, 56 insertions(+), 52 deletions(-)
>>
>> diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
>> index 965da6c0b542..a4c7f98a75e3 100644
>> --- a/tools/perf/util/annotate-data.c
>> +++ b/tools/perf/util/annotate-data.c
>> @@ -31,15 +31,6 @@
>>
>> static void delete_var_types(struct die_var_type *var_types);
>>
>> -enum type_state_kind {
>> - TSR_KIND_INVALID = 0,
>> - TSR_KIND_TYPE,
>> - TSR_KIND_PERCPU_BASE,
>> - TSR_KIND_CONST,
>> - TSR_KIND_POINTER,
>> - TSR_KIND_CANARY,
>> -};
>> -
>> #define pr_debug_dtp(fmt, ...) \
>> do { \
>> if (debug_type_profile) \
>> @@ -140,49 +131,7 @@ static void pr_debug_location(Dwarf_Die *die, u64 pc, int reg)
>> }
>> }
>>
>> -/*
>> - * Type information in a register, valid when @ok is true.
>> - * The @caller_saved registers are invalidated after a function call.
>> - */
>> -struct type_state_reg {
>> - Dwarf_Die type;
>> - u32 imm_value;
>> - bool ok;
>> - bool caller_saved;
>> - u8 kind;
>> -};
>> -
>> -/* Type information in a stack location, dynamically allocated */
>> -struct type_state_stack {
>> - struct list_head list;
>> - Dwarf_Die type;
>> - int offset;
>> - int size;
>> - bool compound;
>> - u8 kind;
>> -};
>> -
>> -/* FIXME: This should be arch-dependent */
>> -#define TYPE_STATE_MAX_REGS 16
>> -
>> -/*
>> - * State table to maintain type info in each register and stack location.
>> - * It'll be updated when new variable is allocated or type info is moved
>> - * to a new location (register or stack). As it'd be used with the
>> - * shortest path of basic blocks, it only maintains a single table.
>> - */
>> -struct type_state {
>> - /* state of general purpose registers */
>> - struct type_state_reg regs[TYPE_STATE_MAX_REGS];
>> - /* state of stack location */
>> - struct list_head stack_vars;
>> - /* return value register */
>> - int ret_reg;
>> - /* stack pointer register */
>> - int stack_reg;
>> -};
>> -
>> -static bool has_reg_type(struct type_state *state, int reg)
>> +bool has_reg_type(struct type_state *state, int reg)
>> {
>> return (unsigned)reg < ARRAY_SIZE(state->regs);
>> }
>> diff --git a/tools/perf/util/annotate-data.h b/tools/perf/util/annotate-data.h
>> index 0a57d9f5ee78..ef235b1b15e1 100644
>> --- a/tools/perf/util/annotate-data.h
>> +++ b/tools/perf/util/annotate-data.h
>> @@ -6,6 +6,9 @@
>> #include <linux/compiler.h>
>> #include <linux/rbtree.h>
>> #include <linux/types.h>
>> +#include "dwarf-aux.h"
>> +#include "annotate.h"
>> +#include "debuginfo.h"
>>
>> struct annotated_op_loc;
>> struct debuginfo;
>> @@ -15,6 +18,15 @@ struct hist_entry;
>> struct map_symbol;
>> struct thread;
>>
>> +enum type_state_kind {
>> + TSR_KIND_INVALID = 0,
>> + TSR_KIND_TYPE,
>> + TSR_KIND_PERCPU_BASE,
>> + TSR_KIND_CONST,
>> + TSR_KIND_POINTER,
>> + TSR_KIND_CANARY,
>> +};
>> +
>> /**
>> * struct annotated_member - Type of member field
>> * @node: List entry in the parent list
>> @@ -142,6 +154,48 @@ struct annotated_data_stat {
>> };
>> extern struct annotated_data_stat ann_data_stat;
>>
>> +/*
>> + * Type information in a register, valid when @ok is true.
>> + * The @caller_saved registers are invalidated after a function call.
>> + */
>> +struct type_state_reg {
>> + Dwarf_Die type;
>> + u32 imm_value;
>> + bool ok;
>> + bool caller_saved;
>> + u8 kind;
>> +};
>> +
>> +/* Type information in a stack location, dynamically allocated */
>> +struct type_state_stack {
>> + struct list_head list;
>> + Dwarf_Die type;
>> + int offset;
>> + int size;
>> + bool compound;
>> + u8 kind;
>> +};
>> +
>> +/* FIXME: This should be arch-dependent */
>> +#define TYPE_STATE_MAX_REGS 32
>
> Can you please define this for powerpc separately? I think x86 should
> remain in 16.
>
> Thanks,
> Namhyung
Sure, I will have this change in V5
>
>> +
>> +/*
>> + * State table to maintain type info in each register and stack location.
>> + * It'll be updated when new variable is allocated or type info is moved
>> + * to a new location (register or stack). As it'd be used with the
>> + * shortest path of basic blocks, it only maintains a single table.
>> + */
>> +struct type_state {
>> + /* state of general purpose registers */
>> + struct type_state_reg regs[TYPE_STATE_MAX_REGS];
>> + /* state of stack location */
>> + struct list_head stack_vars;
>> + /* return value register */
>> + int ret_reg;
>> + /* stack pointer register */
>> + int stack_reg;
>> +};
>> +
>> #ifdef HAVE_DWARF_SUPPORT
>>
>> /* Returns data type at the location (ip, reg, offset) */
>> @@ -160,6 +214,7 @@ void global_var_type__tree_delete(struct rb_root *root);
>>
>> int hist_entry__annotate_data_tty(struct hist_entry *he, struct evsel *evsel);
>>
>> +bool has_reg_type(struct type_state *state, int reg);
>> #else /* HAVE_DWARF_SUPPORT */
>>
>> static inline struct annotated_data_type *
>> --
>> 2.43.0
next prev parent reply other threads:[~2024-06-25 11:48 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 17:26 [V4 00/16] Add data type profiling support for powerpc Athira Rajeev
2024-06-14 17:26 ` [V4 01/16] tools/perf: Move the data structures related to register type to header file Athira Rajeev
2024-06-25 5:15 ` Namhyung Kim
2024-06-25 10:54 ` Athira Rajeev [this message]
2024-06-14 17:26 ` [V4 02/16] tools/perf: Add "update_insn_state" callback function to handle arch specific instruction tracking Athira Rajeev
2024-06-14 17:26 ` [V4 03/16] tools/perf: Add support to capture and parse raw instruction in powerpc using dso__data_read_offset utility Athira Rajeev
2024-06-25 5:29 ` Namhyung Kim
2024-06-25 12:38 ` Athira Rajeev
2024-06-25 18:39 ` Namhyung Kim
2024-06-26 4:09 ` Athira Rajeev
2024-06-14 17:26 ` [V4 04/16] tools/perf: Use sort keys to determine whether to pick objdump to disassemble Athira Rajeev
2024-06-25 5:32 ` Namhyung Kim
2024-06-14 17:26 ` [V4 05/16] tools/perf: Add disasm_line__parse to parse raw instruction for powerpc Athira Rajeev
2024-06-25 5:39 ` Namhyung Kim
2024-06-25 12:42 ` Athira Rajeev
2024-06-25 18:45 ` Namhyung Kim
2024-06-26 4:08 ` Athira Rajeev
2024-06-26 21:17 ` Namhyung Kim
2024-06-27 9:28 ` Athira Rajeev
2024-06-30 11:10 ` Athira Rajeev
2024-06-14 17:26 ` [V4 06/16] tools/perf: Update parameters for reg extract functions to use raw instruction on powerpc Athira Rajeev
2024-06-25 6:00 ` Namhyung Kim
2024-06-25 12:43 ` Athira Rajeev
2024-06-14 17:26 ` [V4 07/16] tools/perf: Add support to identify memory instructions of opcode 31 in powerpc Athira Rajeev
2024-06-14 17:26 ` [V4 08/16] tools/perf: Add some of the arithmetic instructions to support instruction tracking " Athira Rajeev
2024-06-14 17:26 ` [V4 09/16] tools/perf: Add more instructions for instruction tracking Athira Rajeev
2024-06-14 17:26 ` [V4 10/16] tools/perf: Update instruction tracking for powerpc Athira Rajeev
2024-06-14 17:26 ` [V4 11/16] tools/perf: Make capstone_init non-static so that it can be used during symbol disassemble Athira Rajeev
2024-06-14 17:26 ` [V4 12/16] tools/perf: Use capstone_init and remove open_capstone_handle from disasm.c Athira Rajeev
2024-06-14 17:26 ` [V4 13/16] tools/perf: Add support to use libcapstone in powerpc Athira Rajeev
2024-06-25 6:08 ` Namhyung Kim
2024-06-25 12:44 ` Athira Rajeev
2024-06-14 17:26 ` [V4 14/16] tools/perf: Add support to find global register variables using find_data_type_global_reg Athira Rajeev
2024-06-25 6:17 ` Namhyung Kim
2024-06-25 12:45 ` Athira Rajeev
2024-06-14 17:26 ` [V4 15/16] tools/perf: Add support for global_die to capture name of variable in case of register defined variable Athira Rajeev
2024-06-14 17:26 ` [V4 16/16] tools/perf: Set instruction name to be used with insn-stat when using raw instruction Athira Rajeev
2024-06-20 15:31 ` [V4 00/16] Add data type profiling support for powerpc Athira Rajeev
2024-06-22 0:06 ` Namhyung Kim
2024-06-25 11:48 ` Athira Rajeev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0AF30B3F-AD13-4398-AC0F-AA6B5425D4AA@linux.vnet.ibm.com \
--to=atrajeev@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=akanksha@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=disgoel@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=namhyung@kernel.org \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).