public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users <linux-perf-users@vger.kernel.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	akanksha@linux.ibm.com, Madhavan Srinivasan <maddy@linux.ibm.com>,
	Kajol Jain <kjain@linux.ibm.com>,
	disgoel@linux.vnet.ibm.com
Subject: Re: [PATCH V3 11/14] tools/perf: Add support to use libcapstone in powerpc
Date: Tue, 11 Jun 2024 19:29:49 +0300	[thread overview]
Message-ID: <9dedd378-ce85-4329-b770-de47548bf380@intel.com> (raw)
In-Reply-To: <81ED04E0-23B5-44AE-B84D-5766346F1D32@linux.vnet.ibm.com>

On 10/06/24 15:20, Athira Rajeev wrote:
> 
> 
>> On 3 Jun 2024, at 10:28 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 3/06/24 19:30, Ian Rogers wrote:
>>> On Fri, May 31, 2024 at 11:10 PM Athira Rajeev
>>> <atrajeev@linux.vnet.ibm.com> wrote:
>>>>
>>>> Now perf uses the capstone library to disassemble the instructions in
>>>> x86. capstone is used (if available) for perf annotate to speed up.
>>>> Currently it only supports x86 architecture. Patch includes changes to
>>>> enable this in powerpc. For now, only for data type sort keys, this
>>>> method is used and only binary code (raw instruction) is read. This is
>>>> because powerpc approach to understand instructions and reg fields uses
>>>> raw instruction. The "cs_disasm" is currently not enabled. While
>>>> attempting to do cs_disasm, observation is that some of the instructions
>>>> were not identified (ex: extswsli, maddld) and it had to fallback to use
>>>> objdump. Hence enabling "cs_disasm" is added in comment section as a
>>>> TODO for powerpc.
>>>>
>>>> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
>>>> ---
>>>> tools/perf/util/disasm.c | 148 ++++++++++++++++++++++++++++++++++++++-
>>>> 1 file changed, 146 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
>>>> index d8b357055302..915508d2e197 100644
>>>> --- a/tools/perf/util/disasm.c
>>>> +++ b/tools/perf/util/disasm.c
>>>> @@ -1540,12 +1540,18 @@ static int open_capstone_handle(struct annotate_args *args, bool is_64bit,
>>>> {
>>>>        struct annotation_options *opt = args->options;
>>>>        cs_mode mode = is_64bit ? CS_MODE_64 : CS_MODE_32;
>>>> +       int ret;
>>>>
>>>>        /* TODO: support more architectures */
>>>> -       if (!arch__is(args->arch, "x86"))
>>>> +       if ((!arch__is(args->arch, "x86")) && (!arch__is(args->arch, "powerpc")))
>>>>                return -1;
>>>>
>>>> -       if (cs_open(CS_ARCH_X86, mode, handle) != CS_ERR_OK)
>>>> +       if (arch__is(args->arch, "x86"))
>>>> +               ret = cs_open(CS_ARCH_X86, mode, handle);
>>>> +       else
>>>> +               ret = cs_open(CS_ARCH_PPC, mode, handle);
>>>> +
>>>> +       if (ret != CS_ERR_OK)
>>>>                return -1;
>>>
>>> There looks to be a pretty/more robust capstone_init function in
>>> print_insn.c, should we factor this code out and recycle:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/print_insn.c?h=perf-tools-next#n40
>>
>> On a slightly related note, there is a compile error
>> been around for a while in util/disasm.c on Ubuntu 22.04
>>
>> In file included from /usr/include/capstone/capstone.h:279,
>>                 from util/disasm.c:1354:
>> /usr/include/capstone/bpf.h:94:14: error: ‘bpf_insn’ defined as wrong
>> kind of tag
>>   94 | typedef enum bpf_insn {
>>      |              ^~~~~~~~
>>
> 
> Hi Adrian
> 
> I tried compilation on Ubuntu 22.04, but didn’t face this issue.
> The libcapstone version I have is libcapstone4 which doesn’t have the include for “bpf.h”
> What is the version of libcapstone in the setup where you are seeing this issue ?

Yes, sorry. I got confused.  Ubuntu was OK.  The original issue
was with Fedora 40, but even then it requires binutils-devel
and BUILD_NONDISTRO=1


  reply	other threads:[~2024-06-11 16:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-01  6:09 [PATCH V3 00/14] Add data type profiling support for powerpc Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 01/14] tools/perf: Move the data structures related to register type to header file Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 02/14] tools/perf: Add "update_insn_state" callback function to handle arch specific instruction tracking Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 03/14] tools/perf: Add support to capture and parse raw instruction in powerpc using dso__data_read_offset utility Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 04/14] tools/perf: Use sort keys to determine whether to pick objdump to disassemble Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 05/14] tools/perf: Add disasm_line__parse to parse raw instruction for powerpc Athira Rajeev
2024-06-06  6:33   ` Namhyung Kim
2024-06-08  7:08     ` Athira Rajeev
2024-06-08  8:58     ` Christophe Leroy
2024-06-12  8:42       ` Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 06/14] tools/perf: Update parameters for reg extract functions to use raw instruction on powerpc Athira Rajeev
2024-06-06  6:52   ` Namhyung Kim
2024-06-08  7:08     ` Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 07/14] tools/perf: Add support to identify memory instructions of opcode 31 in powerpc Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 08/14] tools/perf: Add some of the arithmetic instructions to support instruction tracking " Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 09/14] tools/perf: Add more instructions for instruction tracking Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 10/14] tools/perf: Update instruction tracking for powerpc Athira Rajeev
2024-06-06  6:53   ` Namhyung Kim
2024-06-08  7:05     ` Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 11/14] tools/perf: Add support to use libcapstone in powerpc Athira Rajeev
2024-06-03 16:30   ` Ian Rogers
2024-06-03 16:58     ` Adrian Hunter
2024-06-10 12:20       ` Athira Rajeev
2024-06-11 16:29         ` Adrian Hunter [this message]
2024-06-08  7:05     ` Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 12/14] tools/perf: Add support to find global register variables using find_data_type_global_reg Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 13/14] tools/perf: Add support for global_die to capture name of variable in case of register defined variable Athira Rajeev
2024-06-01  6:09 ` [PATCH V3 14/14] tools/perf: Set instruction name to be used with insn-stat when using raw instruction 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=9dedd378-ce85-4329-b770-de47548bf380@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=akanksha@linux.ibm.com \
    --cc=atrajeev@linux.vnet.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