From: Andrey Zhizhikin <andrey.z@gmail.com>
To: Salvatore Bonaccorso <carnil@debian.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Suzuki Poulouse <suzuki.poulose@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Tor Jeremiassen <tor@ti.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Guenter Roeck <linux@roeck-us.net>, Leo Yan <leo.yan@linaro.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] Revert "perf cs-etm: Move definition of 'traceid_list' global variable from header file"
Date: Fri, 20 Nov 2020 17:31:59 +0100 [thread overview]
Message-ID: <CAHtQpK5Xuui3q6_x2FKQ1DbP-n8zFa_AR-uQFmcCOH2kzMR6fQ@mail.gmail.com> (raw)
In-Reply-To: <20201120155317.GA502412@eldamar.lan>
Hello Salvatore,
On Fri, Nov 20, 2020 at 4:53 PM Salvatore Bonaccorso <carnil@debian.org> wrote:
>
> Hi Andrey,
>
> On Fri, Nov 20, 2020 at 03:29:39PM +0100, Andrey Zhizhikin wrote:
> > Hello Salvatore,
> >
> > On Fri, Nov 20, 2020 at 2:34 PM Salvatore Bonaccorso <carnil@debian.org> wrote:
> > >
> > > Hi Andrey,
> > >
> > > On Fri, Nov 20, 2020 at 10:54:22AM +0100, Andrey Zhizhikin wrote:
> > > > On Fri, Nov 20, 2020 at 8:39 AM Salvatore Bonaccorso <carnil@debian.org> wrote:
> > > > >
> > > > > This reverts commit 168200b6d6ea0cb5765943ec5da5b8149701f36a upstream.
> > > > > (but only from 4.19.y)
> > > >
> > > > This revert would fail the build of 4.19.y with gcc10, I believe the
> > > > original commit was introduced to address exactly this case. If this
> > > > is intended behavior that 4.19.y is not compiled with newer gcc
> > > > versions - then this revert is OK.
> > >
> > > TTBOMK, this would not regress the build for newer gcc (specifically
> > > gcc10) as 4.19.158 is failing perf tool builds there as well (without
> > > the above commit reverted). Just as an example v4.19.y does not have
> > > cff20b3151cc ("perf tests bp_account: Make global variable static")
> > > which is there in v5.6-rc6 to fix build failures with 10.0.1.
> > >
> > > But it did regress builds with older gcc's as for instance used in
> > > Debian buster (gcc 8.3.0) since 4.19.152.
> > >
> > > Do I possibly miss something? If there is a solution to make it build
> > > with newer GCCs and *not* regress previously working GCC versions then
> > > this is surely the best outcome though.
> >
> > I guess (and from what I understand in Leo's reply), porting of
> > 95c6fe970a01 ("perf cs-etm: Change tuple from traceID-CPU# to
> > traceID-metadata") should solve the issue for both older and newer gcc
> > versions.
> >
> > The breakage is now in
> > [tools/perf/util/cs-etm-decoder/cs-etm-decoder.c] file (which uses
> > traceid_list inside). This is solved with the above commit, which
> > concealed traceid_list internally inside [tools/perf/util/cs-etm.c]
> > file and exposed to [tools/perf/util/cs-etm-decoder/cs-etm-decoder.c]
> > via cs_etm__get_cpu() call.
> >
> > Can you try out to port that commit to see if that would solve your
> > regression?
>
> So something like the following will compile as well with the older
> gcc version.
>
> I realize: I mainline the order of the commits was:
>
> 95c6fe970a01 ("perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata")
> 168200b6d6ea ("perf cs-etm: Move definition of 'traceid_list' global variable from header f
> ile")
>
> But to v4.19.y only 168200b6d6ea was backported, and while that was
> done I now realize the comment was also changed including the change
> fom 95c6fe970a01.
>
> Thus the proposed backported patch would drop the change in
> tools/perf/util/cs-etm.c to the comment as this was already done.
> Thecnically currently the comment would be wrong, because it reads:
>
> /* RB tree for quick conversion between traceID and metadata pointers */
>
> but backport of 95c6fe970a01 is not included.
>
> Would the right thing to do thus be:
>
> - Revert b801d568c7d8 "perf cs-etm: Move definition of 'traceid_list' global variable from header file"
> - Backport 95c6fe970a01 ("perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata")
> - Backport 168200b6d6ea ("perf cs-etm: Move definition of 'traceid_list' global variable from header file")
Yes, I believe this would be the correct course of action here; this
should cover the regression you've encountered and should ensure that
perf builds on both the "old" and "new" gcc versions.
>
> ?
>
> Leo ist that what you were proposing?
>
> Regards,
> Salvatore
>
> From 7d6b3668d8ae5d3aea8827670ade8ac43b92db4a Mon Sep 17 00:00:00 2001
> From: Leo Yan <leo.yan@linaro.org>
> Date: Tue, 29 Jan 2019 20:28:39 +0800
> Subject: [PATCH] perf cs-etm: Change tuple from traceID-CPU# to
> traceID-metadata
>
> commit 95c6fe970a0160cb770c5dce9f80311b42d030c0 upstream.
>
> If packet processing wants to know the packet is bound with which ETM
> version, it needs to access metadata to decide that based on metadata
> magic number; but we cannot simply to use CPU logic ID number as index
> to access metadata sequential array, especially when system have
> hotplugged off CPUs, the metadata array are only allocated for online
> CPUs but not offline CPUs, so the CPU logic number doesn't match with
> its index in the array.
>
> This patch is to change tuple from traceID-CPU# to traceID-metadata,
> thus it can use the tuple to retrieve metadata pointer according to
> traceID.
>
> For safe accessing metadata fields, this patch provides helper function
> cs_etm__get_cpu() which is used to return CPU number according to
> traceID; cs_etm_decoder__buffer_packet() is the first consumer for this
> helper function.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Robert Walker <robert.walker@arm.com>
> Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
> Cc: coresight ml <coresight@lists.linaro.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Link: http://lkml.kernel.org/r/20190129122842.32041-6-leo.yan@linaro.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> [Salvatore Bonaccorso: Drop comment change in tools/perf/util/cs-etm.h
> which was already changed with b801d568c7d8 ("perf cs-etm: Move
> definition of 'traceid_list' global variable from header file")]
> Signed-off-by: Salvatore Bonaccorso <carnil@debian.org>
> ---
> .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 8 +++---
> tools/perf/util/cs-etm.c | 26 ++++++++++++++-----
> tools/perf/util/cs-etm.h | 7 +++++
> 3 files changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
> index 938def6d0bb9..f540037eb705 100644
> --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
> +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
> @@ -278,14 +278,12 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder,
> enum cs_etm_sample_type sample_type)
> {
> u32 et = 0;
> - struct int_node *inode = NULL;
> + int cpu;
>
> if (decoder->packet_count >= MAX_BUFFER - 1)
> return OCSD_RESP_FATAL_SYS_ERR;
>
> - /* Search the RB tree for the cpu associated with this traceID */
> - inode = intlist__find(traceid_list, trace_chan_id);
> - if (!inode)
> + if (cs_etm__get_cpu(trace_chan_id, &cpu) < 0)
> return OCSD_RESP_FATAL_SYS_ERR;
>
> et = decoder->tail;
> @@ -296,7 +294,7 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder,
> decoder->packet_buffer[et].sample_type = sample_type;
> decoder->packet_buffer[et].exc = false;
> decoder->packet_buffer[et].exc_ret = false;
> - decoder->packet_buffer[et].cpu = *((int *)inode->priv);
> + decoder->packet_buffer[et].cpu = cpu;
> decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR;
> decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR;
>
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index ad33b99f5d21..3275b8dc9344 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -94,6 +94,20 @@ static int cs_etm__update_queues(struct cs_etm_auxtrace *etm);
> static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm,
> pid_t tid, u64 time_);
>
> +int cs_etm__get_cpu(u8 trace_chan_id, int *cpu)
> +{
> + struct int_node *inode;
> + u64 *metadata;
> +
> + inode = intlist__find(traceid_list, trace_chan_id);
> + if (!inode)
> + return -EINVAL;
> +
> + metadata = inode->priv;
> + *cpu = (int)metadata[CS_ETM_CPU];
> + return 0;
> +}
> +
> static void cs_etm__packet_dump(const char *pkt_string)
> {
> const char *color = PERF_COLOR_BLUE;
> @@ -233,7 +247,7 @@ static void cs_etm__free(struct perf_session *session)
> cs_etm__free_events(session);
> session->auxtrace = NULL;
>
> - /* First remove all traceID/CPU# nodes for the RB tree */
> + /* First remove all traceID/metadata nodes for the RB tree */
> intlist__for_each_entry_safe(inode, tmp, traceid_list)
> intlist__remove(traceid_list, inode);
> /* Then the RB tree itself */
> @@ -1319,9 +1333,9 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
> 0xffffffff);
>
> /*
> - * Create an RB tree for traceID-CPU# tuple. Since the conversion has
> - * to be made for each packet that gets decoded, optimizing access in
> - * anything other than a sequential array is worth doing.
> + * Create an RB tree for traceID-metadata tuple. Since the conversion
> + * has to be made for each packet that gets decoded, optimizing access
> + * in anything other than a sequential array is worth doing.
> */
> traceid_list = intlist__new(NULL);
> if (!traceid_list) {
> @@ -1387,8 +1401,8 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
> err = -EINVAL;
> goto err_free_metadata;
> }
> - /* All good, associate the traceID with the CPU# */
> - inode->priv = &metadata[j][CS_ETM_CPU];
> + /* All good, associate the traceID with the metadata pointer */
> + inode->priv = metadata[j];
> }
>
> /*
> diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h
> index c7ef97b198c7..97c3152f5bfd 100644
> --- a/tools/perf/util/cs-etm.h
> +++ b/tools/perf/util/cs-etm.h
> @@ -66,6 +66,7 @@ static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;
> #ifdef HAVE_CSTRACE_SUPPORT
> int cs_etm__process_auxtrace_info(union perf_event *event,
> struct perf_session *session);
> +int cs_etm__get_cpu(u8 trace_chan_id, int *cpu);
> #else
> static inline int
> cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
> @@ -73,6 +74,12 @@ cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
> {
> return -1;
> }
> +
> +static inline int cs_etm__get_cpu(u8 trace_chan_id __maybe_unused,
> + int *cpu __maybe_unused)
> +{
> + return -1;
> +}
> #endif
>
> #endif
> --
> 2.29.2
>
--
Regards,
Andrey.
_______________________________________________
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:[~2020-11-20 16:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 7:39 [PATCH] Revert "perf cs-etm: Move definition of 'traceid_list' global variable from header file" Salvatore Bonaccorso
2020-11-20 8:34 ` Greg Kroah-Hartman
2020-11-20 8:46 ` Patch "Revert "perf cs-etm: Move definition of 'traceid_list' global variable from header file"" has been added to the 4.19-stable tree gregkh
2020-11-20 9:54 ` [PATCH] Revert "perf cs-etm: Move definition of 'traceid_list' global variable from header file" Andrey Zhizhikin
2020-11-20 11:19 ` Leo Yan
2020-11-20 12:15 ` Andrey Zhizhikin
2020-11-20 13:34 ` Salvatore Bonaccorso
2020-11-20 14:29 ` Andrey Zhizhikin
2020-11-20 15:53 ` Salvatore Bonaccorso
2020-11-20 16:31 ` Andrey Zhizhikin [this message]
2020-11-20 18:30 ` Salvatore Bonaccorso
2020-11-20 19:29 ` Andrey Zhizhikin
2020-11-22 13:43 ` Leo Yan
2020-11-25 20:12 ` [PATCH 1/2] perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata Salvatore Bonaccorso
2020-11-25 20:12 ` [PATCH 2/2] perf cs-etm: Move definition of 'traceid_list' global variable from header file Salvatore Bonaccorso
2020-11-25 20:23 ` [PATCH 1/2] perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata Salvatore Bonaccorso
2020-11-26 1:35 ` Leo Yan
2020-11-26 4:52 ` Salvatore Bonaccorso
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=CAHtQpK5Xuui3q6_x2FKQ1DbP-n8zFa_AR-uQFmcCOH2kzMR6fQ@mail.gmail.com \
--to=andrey.z@gmail.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=carnil@debian.org \
--cc=gregkh@linuxfoundation.org \
--cc=jolsa@redhat.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tor@ti.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).