From: Leo Yan <leo.yan@linaro.org>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
John Garry <john.g.garry@oracle.com>,
Will Deacon <will@kernel.org>, James Clark <james.clark@arm.com>,
Mike Leach <mike.leach@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Guo Ren <guoren@kernel.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>, Eric Lin <eric.lin@sifive.com>,
Kan Liang <kan.liang@linux.intel.com>,
Qi Liu <liuqi115@huawei.com>, Sandipan Das <sandipan.das@amd.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-csky@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH v1 2/5] perf parse-regs: Introduce functions arch__reg_{ip|sp}()
Date: Tue, 23 May 2023 14:49:04 +0800 [thread overview]
Message-ID: <20230523064904.GA1969788@leoy-yangtze.lan> (raw)
In-Reply-To: <CAP-5=fU-+8Sdw0tfQNYN40tXanrzUgqv0=6jsHqGR9cgjkQa2A@mail.gmail.com>
On Mon, May 22, 2023 at 11:08:12AM -0700, Ian Rogers wrote:
[...]
> > diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c
> > index 8720ec6cf147..334c9a2b785d 100644
> > --- a/tools/perf/util/perf_regs.c
> > +++ b/tools/perf/util/perf_regs.c
> > @@ -20,6 +20,16 @@ uint64_t __weak arch__user_reg_mask(void)
> > return PERF_REGS_MASK;
> > }
> >
> > +uint64_t __weak arch__reg_ip(void)
> > +{
> > + return 0;
> > +}
> > +
> > +uint64_t __weak arch__reg_sp(void)
> > +{
> > + return 0;
> > +}
> > +
>
> Is there a need for the weak function if there is a definition for
> every architecture?
In current code, some archs don't support register parsing (e.g.
arch/alpha, arch/parisc, arch/riscv64, etc), this is why I added weak
functions to avoid building breakage for these archs.
> A problem with weak definitions is that they are
> not part of the C standard, so strange things can happen such as
> inlining - although I think this code is safe.
Good to know this info, thanks for sharing.
> Not having the weak
> functions means that if someone tries to bring up a new architecture
> they will get linker failures until they add the definitions. Failing
> to link seems better than silently succeeding but then having to track
> down runtime failures because these functions are returning 0.
I agreed that removing weak functions is better way to move forward.
If removing the weak functions, we need to handle cases for below
archs which don't support register parsing:
arch/alpha/
arch/arc/
arch/parisc/
arch/riscv64/
arch/sh/
arch/sparc/
arch/xtensa/
As James pointed out perf fails to support cross unwinding, I will update
this patch, the new version's arch__reg_ip() / arch__reg_sp() will return
IP and SP registers based on the passed 'arch' parameter; for above
unsupported archs, arch__reg_ip() / arch__reg_sp() will return error and
architecture developers can extend register parsing in the future.
In this way, we also can remove weak definitions, this can give us an
extra benefit :)
Thanks,
Leo
next prev parent reply other threads:[~2023-05-23 6:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-20 2:55 [PATCH v1 0/5] perf parse-regs: Refactor arch related functions Leo Yan
2023-05-20 2:55 ` [PATCH v1 1/5] perf parse-regs: Refactor arch register parsing functions Leo Yan
2023-05-20 2:55 ` [PATCH v1 2/5] perf parse-regs: Introduce functions arch__reg_{ip|sp}() Leo Yan
2023-05-22 8:57 ` James Clark
2023-05-22 12:07 ` Leo Yan
2023-05-22 16:34 ` James Clark
2023-05-22 18:08 ` Ian Rogers
2023-05-23 6:49 ` Leo Yan [this message]
2023-05-20 2:55 ` [PATCH v1 3/5] perf parse-regs: Remove unused macros PERF_REG_{IP|SP} Leo Yan
2023-05-20 2:55 ` [PATCH v1 4/5] perf parse-regs: Remove PERF_REGS_{MAX|MASK} from common code Leo Yan
2023-05-20 2:55 ` [PATCH v1 5/5] perf parse-regs: Move out arch specific header from util/perf_regs.h Leo Yan
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=20230523064904.GA1969788@leoy-yangtze.lan \
--to=leo.yan@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=eric.lin@sifive.com \
--cc=guoren@kernel.org \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=liuqi115@huawei.com \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=sandipan.das@amd.com \
--cc=will@kernel.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).