All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Amir Ayupov <aaupov@fb.com>, <linux-perf-users@vger.kernel.org>,
	<coresight@lists.linaro.org>,
	<linux-arm-kernel@lists.infradead.org>,
	"Suzuki K Poulose" <suzuki.poulose@arm.com>,
	James Clark <james.clark@linaro.org>, "Leo Yan" <leo.yan@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	John Garry <john.g.garry@oracle.com>,
	"Will Deacon" <will@kernel.org>
Cc: <linux-doc@vger.kernel.org>, Mike Leach <mike.leach@arm.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	"Swapnil Sapkal" <swapnil.sapkal@amd.com>
Subject: Re: [PATCH v2 1/5] perf dlfilter: Add non-empty branch stack filter
Date: Mon, 24 Aug 2026 13:10:20 +0300	[thread overview]
Message-ID: <823e897f-13c0-4b07-8833-3bbfe37059ca@intel.com> (raw)
In-Reply-To: <58f96797f94467859fec160320a7b9426be8cce7.1787005265.git.aaupov@fb.com>

On 18/08/2026 01:22, Amir Ayupov wrote:
> --itrace=L adds decoded branch history to existing samples, but a sample
> that was recorded while the decoder had no trace for that thread keeps an
> empty branch stack. Consumers of the resulting perf script output, such
> as profile generators for context-sensitive PGO, have no use for those
> samples.
> 
> Add an opt-in dlfilter that drops samples whose parsed branch stack is
> empty, so users can exclude them without changing default sample
> semantics. Build and install it alongside perf's existing dlfilters.
> 
> Assisted-by: Devmate:GPT-5.6
> Signed-off-by: Amir Ayupov <aaupov@fb.com>
> Reviewed-by: James Clark <james.clark@linaro.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/Makefile.perf                      |  1 +
>  .../dlfilters/dlfilter-nonempty-brstack.c     | 26 +++++++++++++++++++
>  2 files changed, 27 insertions(+)
>  create mode 100644 tools/perf/dlfilters/dlfilter-nonempty-brstack.c
> 
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 29cfd44c427f3..750bd1cce1287 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -425,6 +425,7 @@ PROGRAMS += $(OUTPUT)$(LIBJVMTI)
>  endif
>  
>  DLFILTERS := dlfilter-test-api-v0.so dlfilter-test-api-v2.so dlfilter-show-cycles.so
> +DLFILTERS += dlfilter-nonempty-brstack.so
>  DLFILTERS := $(patsubst %,$(OUTPUT)dlfilters/%,$(DLFILTERS))
>  
>  # what 'all' will build and 'install' will install, in perfexecdir
> diff --git a/tools/perf/dlfilters/dlfilter-nonempty-brstack.c b/tools/perf/dlfilters/dlfilter-nonempty-brstack.c
> new file mode 100644
> index 0000000000000..9e66205b841d5
> --- /dev/null
> +++ b/tools/perf/dlfilters/dlfilter-nonempty-brstack.c
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * dlfilter-nonempty-brstack.c: Filter out samples with no branch stack
> + * Copyright (c) 2026, Meta Platforms, Inc.
> + */
> +#include <stddef.h>
> +
> +#include <perf/perf_dlfilter.h>
> +
> +int filter_event(void *data, const struct perf_dlfilter_sample *sample, void *ctx)
> +{
> +	/* Return 1 to filter out the sample, 0 to keep it */
> +	return !sample->brstack_nr;
> +}
> +
> +const char *filter_description(const char **long_description)
> +{
> +	static char *long_desc =
> +		"Instruction trace decoders can add branch history to existing "
> +		"samples, but samples that were recorded while no trace was "
> +		"being collected get an empty branch stack. Filter those out so "
> +		"that only samples carrying branch history remain.";
> +
> +	*long_description = long_desc;
> +	return "Keep only samples with a non-empty branch stack";
> +}


  parent reply	other threads:[~2026-08-24 10:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 22:22 [PATCH v2 0/5] perf: Add CoreSight branch history to existing samples Amir Ayupov
2026-08-17 22:22 ` [PATCH v2 1/5] perf dlfilter: Add non-empty branch stack filter Amir Ayupov
2026-08-17 22:32   ` sashiko-bot
2026-08-24 10:10   ` Adrian Hunter [this message]
2026-08-17 22:22 ` [PATCH v2 2/5] perf cs-etm: Split up cs_etm__process_timestamped_queues() Amir Ayupov
2026-08-17 22:34   ` sashiko-bot
2026-08-18 14:38   ` James Clark
2026-08-17 22:22 ` [PATCH v2 3/5] perf cs-etm: Add branch history to existing samples Amir Ayupov
2026-08-17 22:41   ` sashiko-bot
2026-08-18 15:09   ` James Clark
2026-08-18 15:13     ` James Clark
2026-08-24 10:02   ` Adrian Hunter
2026-08-17 22:22 ` [PATCH v2 4/5] perf test cs-etm: Test branch history on " Amir Ayupov
2026-08-17 22:33   ` sashiko-bot
2026-08-18 14:24   ` James Clark
2026-08-17 22:22 ` [PATCH v2 5/5] Documentation: coresight: Document context-sensitive PGO workflow Amir Ayupov
2026-08-17 22:26   ` sashiko-bot
2026-08-18 13:56 ` [PATCH v2 0/5] perf: Add CoreSight branch history to existing samples James Clark

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=823e897f-13c0-4b07-8833-3bbfe37059ca@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=aaupov@fb.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=john.g.garry@oracle.com \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suzuki.poulose@arm.com \
    --cc=swapnil.sapkal@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 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.