linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Sandipan Das <sandipan.das@amd.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	acme@kernel.org, peterz@infradead.org, mingo@redhat.com,
	mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
	terrelln@fb.com, ravi.bangoria@amd.com, ananth.narayan@amd.com
Subject: Re: [PATCH 1/2] perf script: Skip aggregation for stat events
Date: Fri, 5 May 2023 16:43:20 -0700	[thread overview]
Message-ID: <CAM9d7cgZLiRmUDnxW3NpN67Jvgj670FPBkwqncXmDEamYM6n3A@mail.gmail.com> (raw)
In-Reply-To: <83d6c6c05c54bf00c5a9df32ac160718efca0c7a.1683280603.git.sandipan.das@amd.com>

Hello,

On Fri, May 5, 2023 at 3:03 AM Sandipan Das <sandipan.das@amd.com> wrote:
>
> The script command does not support aggregation modes by itself although
> that can be achieved using post-processing scripts. Because of this, it
> does not allocate memory for aggregated event values.
>
> Upon running perf stat record, the aggregation mode is set in the perf
> data file. If the mode is AGGR_GLOBAL, the aggregated event values are
> accessed and this leads to a segmentation fault since these were never
> allocated to begin with. Set the mode to AGGR_NONE explicitly to avoid
> this.
>
> E.g.
>
>   $ perf stat record -e cycles true
>   $ perf script
>
> Before:
>   Segmentation fault (core dumped)
>
> After:
>   CPU   THREAD             VAL             ENA             RUN            TIME EVENT
>    -1   231919          162831          362069          362069          935289 cycles:u
>
> Fixes: 8b76a3188b85 ("perf stat: Remove unused perf_counts.aggr field")
> Signed-off-by: Sandipan Das <sandipan.das@amd.com>
> Cc: stable@vger.kernel.org # v6.2+

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/builtin-script.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 006f522d0e7f..c57be48d65bb 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -3647,6 +3647,13 @@ static int process_stat_config_event(struct perf_session *session __maybe_unused
>                                      union perf_event *event)
>  {
>         perf_event__read_stat_config(&stat_config, &event->stat_config);
> +
> +       /*
> +        * Aggregation modes are not used since post-processing scripts are
> +        * supposed to take care of such requirements
> +        */
> +       stat_config.aggr_mode = AGGR_NONE;
> +
>         return 0;
>  }
>
> --
> 2.34.1
>

  parent reply	other threads:[~2023-05-05 23:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 10:02 [PATCH 1/2] perf script: Skip aggregation for stat events Sandipan Das
2023-05-05 10:02 ` [PATCH 2/2] perf test: Add stat test for record and script Sandipan Das
2023-05-05 23:43   ` Namhyung Kim
2023-05-05 23:43 ` Namhyung Kim [this message]
2023-05-10 17:37   ` [PATCH 1/2] perf script: Skip aggregation for stat events Arnaldo Carvalho de Melo

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=CAM9d7cgZLiRmUDnxW3NpN67Jvgj670FPBkwqncXmDEamYM6n3A@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=ananth.narayan@amd.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=sandipan.das@amd.com \
    --cc=terrelln@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;
as well as URLs for NNTP newsgroup(s).