Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: James Clark <james.clark@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org,
	linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	John Garry <john.g.garry@oracle.com>,
	Will Deacon <will@kernel.org>, Mike Leach <mike.leach@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	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>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Al Grant <al.grant@arm.com>,
	Paschalis Mpeis <paschalis.mpeis@arm.com>,
	Amir Ayupov <aaupov@fb.com>
Subject: Re: [PATCH v6 3/8] perf cs-etm: Use thread-stack for last branch entries
Date: Mon, 8 Jun 2026 13:38:40 +0100	[thread overview]
Message-ID: <20260608123840.GN101133@e132581.arm.com> (raw)
In-Reply-To: <9d1e0448-27d7-42d3-aaa3-2d09489f18d9@linaro.org>

On Thu, Jun 04, 2026 at 03:09:26PM +0100, James Clark wrote:

[...]

> > @@ -1798,14 +1746,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq,
> >   	tidq->period_instructions += tidq->packet->instr_count;
> > -	/*
> > -	 * Record a branch when the last instruction in
> > -	 * PREV_PACKET is a branch.
> > -	 */
> > -	if (etm->synth_opts.last_branch &&
> > -	    tidq->prev_packet->sample_type == CS_ETM_RANGE &&
> > -	    tidq->prev_packet->last_instr_taken_branch)
> > -		cs_etm__update_last_branch_rb(etmq, tidq);
> > +	cs_etm__add_stack_event(etmq, tidq);
> 
> Would it be cleaner to call this whenever a branch sample is generated?

We should not couple stack event and generating branch samples.

The reason is the stack event can be used separately by instruction
samples, e.g., the option "--itrace=i100il64g16". And the branch stack
and call chain must get ready before synthesing samples.

> Seems like the conditions for calling thread_stack__event() and
> cs_etm__synth_branch_sample() are slightly different (ignoring the fact that
> branches are only generated when the user asks for them).
> 
> Maybe the conditions should be different, but maybe a comment why or if
> they're the same, a shared function for the conditions would help.

I can add a helper to check if a packet is taken branch and it can be
used by cs_etm__add_stack_event() and generating samples.

  bool cs_etm__packet_is_taken_branch(struct cs_etm_packet *packet)
  {
      if (packet->sample_type == CS_ETM_RANGE &&
          packet->last_instr_taken_branch)
          return true;

      return false;
  }

Thanks,
Leo


  reply	other threads:[~2026-06-08 12:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 16:59 [PATCH v6 0/8] perf cs-etm: Support thread stack and callchain Leo Yan
2026-05-26 16:59 ` [PATCH v6 1/8] perf cs-etm: Decode ETE exception packets Leo Yan
2026-06-04 14:10   ` James Clark
2026-05-26 16:59 ` [PATCH v6 2/8] perf cs-etm: Refactor instruction size handling Leo Yan
2026-06-04 14:11   ` James Clark
2026-05-26 16:59 ` [PATCH v6 3/8] perf cs-etm: Use thread-stack for last branch entries Leo Yan
2026-06-04 14:09   ` James Clark
2026-06-08 12:38     ` Leo Yan [this message]
2026-05-26 16:59 ` [PATCH v6 4/8] perf cs-etm: Flush thread stacks after decoder reset Leo Yan
2026-06-04 14:12   ` James Clark
2026-05-26 16:59 ` [PATCH v6 5/8] perf cs-etm: Support call indentation Leo Yan
2026-06-04 14:24   ` James Clark
2026-05-26 16:59 ` [PATCH v6 6/8] perf cs-etm: Filter synthesized branch samples Leo Yan
2026-06-04 14:42   ` James Clark
2026-06-08 11:28     ` Leo Yan
2026-06-08 12:35       ` James Clark
2026-06-08 13:09         ` Leo Yan
2026-05-26 16:59 ` [PATCH v6 7/8] perf cs-etm: Synthesize callchains for instruction samples Leo Yan
2026-06-04 15:07   ` James Clark
2026-05-26 16:59 ` [PATCH v6 8/8] perf test: Add Arm CoreSight callchain test Leo Yan
2026-05-29 14:57 ` [PATCH v6 0/8] perf cs-etm: Support thread stack and callchain Arnaldo Carvalho de Melo
2026-06-01 11:03   ` 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=20260608123840.GN101133@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=aaupov@fb.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=al.grant@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --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=linux-arm-kernel@lists.infradead.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@arm.com \
    --cc=namhyung@kernel.org \
    --cc=paschalis.mpeis@arm.com \
    --cc=suzuki.poulose@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox