From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Leo Yan <leo.yan@linaro.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Suzuki Poulouse <suzuki.poulose@arm.com>,
Coresight ML <coresight@lists.linaro.org>
Subject: Re: [PATCH] perf cs-etm: Improve completeness for kernel address space
Date: Mon, 24 Jun 2019 16:00:09 -0300 [thread overview]
Message-ID: <20190624190009.GE4181@kernel.org> (raw)
In-Reply-To: <20190620005829.GH24549@leoy-ThinkPad-X240s>
Em Thu, Jun 20, 2019 at 08:58:29AM +0800, Leo Yan escreveu:
> Hi Mathieu,
>
> On Wed, Jun 19, 2019 at 11:49:44AM -0600, Mathieu Poirier wrote:
>
> [...]
>
> > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > > index 51dd00f65709..4776c2c1fb6d 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -418,6 +418,30 @@ ifdef CORESIGHT
> > > endif
> > > LDFLAGS += $(LIBOPENCSD_LDFLAGS)
> > > EXTLIBS += $(OPENCSDLIBS)
> > > + ifneq ($(wildcard $(srctree)/arch/arm64/kernel/vmlinux.lds),)
> > > + # Extract info from lds:
> > > + # . = ((((((((0xffffffffffffffff)) - (((1)) << (48)) + 1) + (0)) + (0x08000000))) + (0x08000000))) + 0x00080000;
> > > + # ARM64_PRE_START_SIZE := (0x08000000 + 0x08000000 + 0x00080000)
> > > + ARM64_PRE_START_SIZE := $(shell egrep ' \. \= \({8}0x[0-9a-fA-F]+\){2}' \
> > > + $(srctree)/arch/arm64/kernel/vmlinux.lds | \
> > > + sed -e 's/[(|)|.|=|+|<|;|-]//g' -e 's/ \+/ /g' -e 's/^[ \t]*//' | \
> > > + awk -F' ' '{print "("$$6 "+" $$7 "+" $$8")"}' 2>/dev/null)
> > > + else
> > > + ARM64_PRE_START_SIZE := 0
> > > + endif
> > > + CFLAGS += -DARM64_PRE_START_SIZE="$(ARM64_PRE_START_SIZE)"
> > > + ifneq ($(wildcard $(srctree)/arch/arm/kernel/vmlinux.lds),)
> > > + # Extract info from lds:
> > > + # . = ((0xC0000000)) + 0x00208000;
> > > + # ARM_PRE_START_SIZE := 0x00208000
> > > + ARM_PRE_START_SIZE := $(shell egrep ' \. \= \({2}0x[0-9a-fA-F]+\){2}' \
> > > + $(srctree)/arch/arm/kernel/vmlinux.lds | \
> > > + sed -e 's/[(|)|.|=|+|<|;|-]//g' -e 's/ \+/ /g' -e 's/^[ \t]*//' | \
> > > + awk -F' ' '{print "("$$2")"}' 2>/dev/null)
> > > + else
> > > + ARM_PRE_START_SIZE := 0
> > > + endif
> > > + CFLAGS += -DARM_PRE_START_SIZE="$(ARM_PRE_START_SIZE)"
> > > $(call detected,CONFIG_LIBOPENCSD)
> > > ifdef CSTRACE_RAW
> > > CFLAGS += -DCS_DEBUG_RAW
> > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> > > index 0c7776b51045..ae831f836c70 100644
> > > --- a/tools/perf/util/cs-etm.c
> > > +++ b/tools/perf/util/cs-etm.c
> > > @@ -613,10 +613,34 @@ static void cs_etm__free(struct perf_session *session)
> > > static u8 cs_etm__cpu_mode(struct cs_etm_queue *etmq, u64 address)
> > > {
> > > struct machine *machine;
> > > + u64 fixup_kernel_start = 0;
> > > + const char *arch;
> > >
> > > machine = etmq->etm->machine;
> > > + arch = perf_env__arch(machine->env);
> > >
> > > - if (address >= etmq->etm->kernel_start) {
> > > + /*
> > > + * Since arm and arm64 specify some memory regions prior to
> > > + * 'kernel_start', kernel addresses can be less than 'kernel_start'.
> > > + *
> > > + * For arm architecture, the 16MB virtual memory space prior to
> > > + * 'kernel_start' is allocated to device modules, a PMD table if
> > > + * CONFIG_HIGHMEM is enabled and a PGD table.
> > > + *
> > > + * For arm64 architecture, the root PGD table, device module memory
> > > + * region and BPF jit region are prior to 'kernel_start'.
> > > + *
> > > + * To reflect the complete kernel address space, compensate these
> > > + * pre-defined regions for kernel start address.
> > > + */
> > > + if (!strcmp(arch, "arm64"))
> > > + fixup_kernel_start = etmq->etm->kernel_start -
> > > + ARM64_PRE_START_SIZE;
> > > + else if (!strcmp(arch, "arm"))
> > > + fixup_kernel_start = etmq->etm->kernel_start -
> > > + ARM_PRE_START_SIZE;
> >
> > I will test your work but from a quick look wouldn't it be better to
> > have a single define name here? From looking at the modifications you
> > did to Makefile.config there doesn't seem to be a reason to have two.
>
> Thanks for suggestion. I changed to use single define
> ARM_PRE_START_SIZE and sent patch v2 [1].
>
> If possible, please test patch v2.
>
> Thanks,
> Leo Yan
So just for the record, I'm waiting for Mathieu on this one, i.e. for
him to test/ack v3.
- Arnaldo
> [1] https://lore.kernel.org/linux-arm-kernel/20190620005428.20883-1-leo.yan@linaro.org/T/#u
>
> > > +
> > > + if (address >= fixup_kernel_start) {
> > > if (machine__is_host(machine))
> > > return PERF_RECORD_MISC_KERNEL;
> > > else
> > > --
> > > 2.17.1
> > >
--
- Arnaldo
WARNING: multiple messages have this Message-ID (diff)
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Leo Yan <leo.yan@linaro.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>,
Suzuki Poulouse <suzuki.poulose@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
netdev@vger.kernel.org, Coresight ML <coresight@lists.linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Namhyung Kim <namhyung@kernel.org>,
bpf@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] perf cs-etm: Improve completeness for kernel address space
Date: Mon, 24 Jun 2019 16:00:09 -0300 [thread overview]
Message-ID: <20190624190009.GE4181@kernel.org> (raw)
In-Reply-To: <20190620005829.GH24549@leoy-ThinkPad-X240s>
Em Thu, Jun 20, 2019 at 08:58:29AM +0800, Leo Yan escreveu:
> Hi Mathieu,
>
> On Wed, Jun 19, 2019 at 11:49:44AM -0600, Mathieu Poirier wrote:
>
> [...]
>
> > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > > index 51dd00f65709..4776c2c1fb6d 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -418,6 +418,30 @@ ifdef CORESIGHT
> > > endif
> > > LDFLAGS += $(LIBOPENCSD_LDFLAGS)
> > > EXTLIBS += $(OPENCSDLIBS)
> > > + ifneq ($(wildcard $(srctree)/arch/arm64/kernel/vmlinux.lds),)
> > > + # Extract info from lds:
> > > + # . = ((((((((0xffffffffffffffff)) - (((1)) << (48)) + 1) + (0)) + (0x08000000))) + (0x08000000))) + 0x00080000;
> > > + # ARM64_PRE_START_SIZE := (0x08000000 + 0x08000000 + 0x00080000)
> > > + ARM64_PRE_START_SIZE := $(shell egrep ' \. \= \({8}0x[0-9a-fA-F]+\){2}' \
> > > + $(srctree)/arch/arm64/kernel/vmlinux.lds | \
> > > + sed -e 's/[(|)|.|=|+|<|;|-]//g' -e 's/ \+/ /g' -e 's/^[ \t]*//' | \
> > > + awk -F' ' '{print "("$$6 "+" $$7 "+" $$8")"}' 2>/dev/null)
> > > + else
> > > + ARM64_PRE_START_SIZE := 0
> > > + endif
> > > + CFLAGS += -DARM64_PRE_START_SIZE="$(ARM64_PRE_START_SIZE)"
> > > + ifneq ($(wildcard $(srctree)/arch/arm/kernel/vmlinux.lds),)
> > > + # Extract info from lds:
> > > + # . = ((0xC0000000)) + 0x00208000;
> > > + # ARM_PRE_START_SIZE := 0x00208000
> > > + ARM_PRE_START_SIZE := $(shell egrep ' \. \= \({2}0x[0-9a-fA-F]+\){2}' \
> > > + $(srctree)/arch/arm/kernel/vmlinux.lds | \
> > > + sed -e 's/[(|)|.|=|+|<|;|-]//g' -e 's/ \+/ /g' -e 's/^[ \t]*//' | \
> > > + awk -F' ' '{print "("$$2")"}' 2>/dev/null)
> > > + else
> > > + ARM_PRE_START_SIZE := 0
> > > + endif
> > > + CFLAGS += -DARM_PRE_START_SIZE="$(ARM_PRE_START_SIZE)"
> > > $(call detected,CONFIG_LIBOPENCSD)
> > > ifdef CSTRACE_RAW
> > > CFLAGS += -DCS_DEBUG_RAW
> > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> > > index 0c7776b51045..ae831f836c70 100644
> > > --- a/tools/perf/util/cs-etm.c
> > > +++ b/tools/perf/util/cs-etm.c
> > > @@ -613,10 +613,34 @@ static void cs_etm__free(struct perf_session *session)
> > > static u8 cs_etm__cpu_mode(struct cs_etm_queue *etmq, u64 address)
> > > {
> > > struct machine *machine;
> > > + u64 fixup_kernel_start = 0;
> > > + const char *arch;
> > >
> > > machine = etmq->etm->machine;
> > > + arch = perf_env__arch(machine->env);
> > >
> > > - if (address >= etmq->etm->kernel_start) {
> > > + /*
> > > + * Since arm and arm64 specify some memory regions prior to
> > > + * 'kernel_start', kernel addresses can be less than 'kernel_start'.
> > > + *
> > > + * For arm architecture, the 16MB virtual memory space prior to
> > > + * 'kernel_start' is allocated to device modules, a PMD table if
> > > + * CONFIG_HIGHMEM is enabled and a PGD table.
> > > + *
> > > + * For arm64 architecture, the root PGD table, device module memory
> > > + * region and BPF jit region are prior to 'kernel_start'.
> > > + *
> > > + * To reflect the complete kernel address space, compensate these
> > > + * pre-defined regions for kernel start address.
> > > + */
> > > + if (!strcmp(arch, "arm64"))
> > > + fixup_kernel_start = etmq->etm->kernel_start -
> > > + ARM64_PRE_START_SIZE;
> > > + else if (!strcmp(arch, "arm"))
> > > + fixup_kernel_start = etmq->etm->kernel_start -
> > > + ARM_PRE_START_SIZE;
> >
> > I will test your work but from a quick look wouldn't it be better to
> > have a single define name here? From looking at the modifications you
> > did to Makefile.config there doesn't seem to be a reason to have two.
>
> Thanks for suggestion. I changed to use single define
> ARM_PRE_START_SIZE and sent patch v2 [1].
>
> If possible, please test patch v2.
>
> Thanks,
> Leo Yan
So just for the record, I'm waiting for Mathieu on this one, i.e. for
him to test/ack v3.
- Arnaldo
> [1] https://lore.kernel.org/linux-arm-kernel/20190620005428.20883-1-leo.yan@linaro.org/T/#u
>
> > > +
> > > + if (address >= fixup_kernel_start) {
> > > if (machine__is_host(machine))
> > > return PERF_RECORD_MISC_KERNEL;
> > > else
> > > --
> > > 2.17.1
> > >
--
- Arnaldo
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-06-24 19:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 15:00 [PATCH] perf cs-etm: Improve completeness for kernel address space Leo Yan
2019-06-17 15:00 ` Leo Yan
2019-06-19 17:49 ` Mathieu Poirier
2019-06-19 17:49 ` Mathieu Poirier
2019-06-20 0:58 ` Leo Yan
2019-06-20 0:58 ` Leo Yan
2019-06-24 19:00 ` Arnaldo Carvalho de Melo [this message]
2019-06-24 19:00 ` Arnaldo Carvalho de Melo
2019-06-25 4:51 ` Leo Yan
2019-06-25 4:51 ` Leo Yan
2019-06-25 17:14 ` Mathieu Poirier
2019-06-25 17:14 ` Mathieu Poirier
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=20190624190009.GE4181@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bpf@vger.kernel.org \
--cc=coresight@lists.linaro.org \
--cc=jolsa@redhat.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=suzuki.poulose@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.