From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
"Steinar H. Gunderson" <sesse@google.com>,
Charlie Jenkins <charlie@rivosinc.com>,
Changbin Du <changbin.du@huawei.com>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
James Clark <james.clark@linaro.org>,
Kajol Jain <kjain@linux.ibm.com>,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Li Huafei <lihuafei1@huawei.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH v1 4/5] perf capstone: Support for dlopen-ing libcapstone.so
Date: Fri, 24 Jan 2025 13:31:52 -0800 [thread overview]
Message-ID: <Z5QGyGQ9SfXiE3WH@google.com> (raw)
In-Reply-To: <CAP-5=fUhNuybCU-2_5EgcCwgwXnxvyFMvyhzKe=ZP1bssQwXHw@mail.gmail.com>
On Thu, Jan 23, 2025 at 01:37:16PM -0800, Ian Rogers wrote:
> > > On Wed, Jan 22, 2025 at 2:27 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > > > I think reverse engineering the types is fragile. Can we simply change
> > > > to dlopen if libcapstone is available?
>
> To understand the scope of the problem, here is the LLVM code:
> https://github.com/googleprodkernel/linux-perf/blob/google_tools_master/tools/perf/util/llvm.c#L22
> 3 typedefs and 5 #defines on 13 lines of code.
It doesn't look that bad than I thought. :)
>
> The capstone code is larger primarily due to needing to define cs_x86
> (and its dependencies) which are used for extra detail in printing:
> https://github.com/googleprodkernel/linux-perf/blob/google_tools_master/tools/perf/util/capstone.c#L23-L132
> We could opt out of providing the extra detail if capstone.h isn't
> present. I believe this can remove lines 49 to 123. This would mean
> there would be 37 lines of reverse engineered types - 2 structs and 5
> enums.
Probably, we don't need to carry the full details of instructions when
the library support was not built.
>
> My feeling is that this isn't significant and better than returning
> errors for capstone/llvm, having #ifdefs/__maybe_unused for the cases
> we lack the types throughout the code and relying on people building
> noticing a warning to realize they need to install a dependency - the
> alternative of failing the build if the capstone/LLVM header files
> aren't present, and unless some NO_... build option isn't passed,
> likely won't fly with perf developers.
I don't think failing the build due to the optional dependencies is an
option. I'm not against the idea of dlopen but my concern is to carry
those external definitions in the perf code base. Maybe it'd be ok if
we could keep it minimally.
Thanks,
Namhyung
next prev parent reply other threads:[~2025-01-24 21:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 17:32 [PATCH v1 0/5] Support dynamic opening of capstone and libLLVM Ian Rogers
2025-01-20 17:32 ` [PATCH v1 1/5] perf capstone: Move capstone functionality into its own file Ian Rogers
2025-01-20 17:32 ` [PATCH v1 2/5] perf llvm: Move llvm " Ian Rogers
2025-01-20 17:32 ` [PATCH v1 3/5] perf capstone: Remove open_capstone_handle Ian Rogers
2025-01-20 17:32 ` [PATCH v1 4/5] perf capstone: Support for dlopen-ing libcapstone.so Ian Rogers
2025-01-22 22:27 ` Namhyung Kim
2025-01-22 22:42 ` Ian Rogers
2025-01-23 16:07 ` Ian Rogers
2025-01-23 21:37 ` Ian Rogers
2025-01-24 21:31 ` Namhyung Kim [this message]
2025-01-20 17:32 ` [PATCH v1 5/5] perf llvm: Support for dlopen-ing libLLVM.so Ian Rogers
2025-01-20 18:01 ` [PATCH v1 0/5] Support dynamic opening of capstone and libLLVM Ian Rogers
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=Z5QGyGQ9SfXiE3WH@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=changbin.du@huawei.com \
--cc=charlie@rivosinc.com \
--cc=dvyukov@google.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=lihuafei1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=sesse@google.com \
/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).