From: Leo Yan <leo.yan@linaro.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, David Miller <davem@davemloft.net>,
Milian Wolff <milian.wolff@kdab.com>,
Donald Yandt <donald.yandt@gmail.com>,
Davidlohr Bueso <dave@stgolabs.net>, Wei Li <liwei391@huawei.com>,
Mark Drayton <mbd@fb.com>,
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, clang-built-linux@googlegroups.com,
Mathieu Poirier <mathieu.poirier@linaro.org>
Subject: Re: [PATCH v4 1/2] perf machine: Support arch's specific kernel start address
Date: Mon, 12 Aug 2019 15:39:31 +0800 [thread overview]
Message-ID: <20190812073931.GB8062@leoy-ThinkPad-X240s> (raw)
In-Reply-To: <250165c6-908a-c57e-8d83-03da4272f568@intel.com>
On Mon, Aug 12, 2019 at 10:23:21AM +0300, Adrian Hunter wrote:
> On 12/08/19 10:02 AM, Leo Yan wrote:
> > On Mon, Aug 12, 2019 at 09:37:33AM +0300, Adrian Hunter wrote:
> >> On 10/08/19 10:21 AM, Leo Yan wrote:
> >>> machine__get_kernel_start() gives out the kernel start address; some
> >>> architectures need to tweak the start address so that can reflect the
> >>> kernel start address correctly. This is not only for x86_64 arch, but
> >>> it is also required by other architectures, e.g. arm/arm64 needs to
> >>> tweak the kernel start address so can include the kernel memory regions
> >>> which are used before the '_stext' symbol.
> >>>
> >>> This patch refactors machine__get_kernel_start() by adding a weak
> >>> arch__fix_kernel_text_start(), any architecture can implement it to
> >>> tweak its specific start address; this also allows the arch specific
> >>> code to be placed into 'arch' folder.
> >>>
> >>> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> >>> ---
> >>> tools/perf/arch/x86/util/machine.c | 10 ++++++++++
> >>> tools/perf/util/machine.c | 13 +++++++------
> >>> tools/perf/util/machine.h | 2 ++
> >>> 3 files changed, 19 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/tools/perf/arch/x86/util/machine.c b/tools/perf/arch/x86/util/machine.c
> >>> index 1e9ec783b9a1..9f012131534a 100644
> >>> --- a/tools/perf/arch/x86/util/machine.c
> >>> +++ b/tools/perf/arch/x86/util/machine.c
> >>> @@ -101,4 +101,14 @@ int machine__create_extra_kernel_maps(struct machine *machine,
> >>> return ret;
> >>> }
> >>>
> >>> +void arch__fix_kernel_text_start(u64 *start)
> >>> +{
> >>> + /*
> >>> + * On x86_64, PTI entry trampolines are less than the
> >>> + * start of kernel text, but still above 2^63. So leave
> >>> + * kernel_start = 1ULL << 63 for x86_64.
> >>> + */
> >>> + *start = 1ULL << 63;
> >>> +}
> >>
> >> That is needed for reporting x86 data on any arch i.e. it is not specific to
> >> the compile-time architecture, it is specific to the perf.data file
> >> architecture, which is what machine__is() compares. So, this looks wrong.
> >
> > Thanks for reviewing, Adrian.
> >
> > If so, I think we should extend the function machine__get_kernel_start()
> > as below; for building successfully, will always define the macro
> > ARM_PRE_START_SIZE in Makefile.config.
> >
> > @Arnaldo, @Adrian, Please let me know if this works for you?
>
> I don't know how you intend to calculate ARM_PRE_START_SIZE, but below is OK
> for x86.
>
> >
> > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> > index f6ee7fbad3e4..30a0ff627263 100644
> > --- a/tools/perf/util/machine.c
> > +++ b/tools/perf/util/machine.c
> > @@ -2687,13 +2687,26 @@ int machine__get_kernel_start(struct machine *machine)
> > machine->kernel_start = 1ULL << 63;
> > if (map) {
> > err = map__load(map);
> > + if (err)
> > + return err;
> > +
> > /*
> > * On x86_64, PTI entry trampolines are less than the
> > * start of kernel text, but still above 2^63. So leave
> > * kernel_start = 1ULL << 63 for x86_64.
> > */
> > - if (!err && !machine__is(machine, "x86_64"))
> > + if (!machine__is(machine, "x86_64"))
> > machine->kernel_start = map->start;
> > +
> > + /*
> > + * On arm/arm64, some memory regions are prior to '_stext'
> > + * symbol; to reflect the complete kernel address space,
> > + * compensate these pre-defined regions for kernel start
> > + * address.
> > + */
> > + if (machine__is(machine, "arm64") ||
> > + machine__is(machine, "arm"))
>
> machine__is() does not normalize the architecture, so you may want to use
> perf_env__arch() instead.
You are right, thanks for suggestion. Will use perf_env__arch() in
next spin.
Thanks,
Leo Yan
>
> > + machine->kernel_start -= ARM_PRE_START_SIZE;
> > }
> > return err;
> > }
[...]
next prev parent reply other threads:[~2019-08-12 7:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-10 7:21 [PATCH v4 0/2] perf: arm/arm64: Improve completeness for kernel address space Leo Yan
2019-08-10 7:21 ` [PATCH v4 1/2] perf machine: Support arch's specific kernel start address Leo Yan
2019-08-12 6:37 ` Adrian Hunter
2019-08-12 7:02 ` Leo Yan
2019-08-12 7:23 ` Adrian Hunter
2019-08-12 7:39 ` Leo Yan [this message]
2019-08-10 7:21 ` [PATCH v4 2/2] perf machine: arm/arm64: Improve completeness for kernel address space 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=20190812073931.GB8062@leoy-ThinkPad-X240s \
--to=leo.yan@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clang-built-linux@googlegroups.com \
--cc=daniel@iogearbox.net \
--cc=dave@stgolabs.net \
--cc=davem@davemloft.net \
--cc=donald.yandt@gmail.com \
--cc=jolsa@redhat.com \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liwei391@huawei.com \
--cc=mathieu.poirier@linaro.org \
--cc=mbd@fb.com \
--cc=milian.wolff@kdab.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=tz.stoyanov@gmail.com \
--cc=yhs@fb.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