From: Jens Remus <jremus@linux.ibm.com>
To: Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Indu Bhagat <indu.bhagat@oracle.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v6 5/6] perf tools: Merge deferred user callchains
Date: Fri, 12 Dec 2025 12:48:38 +0100 [thread overview]
Message-ID: <6e5ff603-95ec-4b2c-b0b6-dd29ed2a2627@linux.ibm.com> (raw)
In-Reply-To: <86593213-8a48-412a-a601-7992cc1660c6@linux.ibm.com>
Hello Namhyung,
sorry for the fuss!
On 12/12/2025 12:16 PM, Jens Remus wrote:
> On 11/21/2025 12:48 AM, Namhyung Kim wrote:
>> Save samples with deferred callchains in a separate list and deliver
>> them after merging the user callchains. If users don't want to merge
>> they can set tool->merge_deferred_callchains to false to prevent the
>> behavior.
>
>> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
>
>> +int sample__merge_deferred_callchain(struct perf_sample *sample_orig,
>> + struct perf_sample *sample_callchain)
>> +{
>> + u64 nr_orig = sample_orig->callchain->nr - 1;
>> + u64 nr_deferred = sample_callchain->callchain->nr;
>> + struct ip_callchain *callchain;
>> +
>> + if (sample_orig->callchain->nr < 2) {
>> + sample_orig->deferred_callchain = false;
>> + return -EINVAL;
>> + }
>> +
>> + callchain = calloc(1 + nr_orig + nr_deferred, sizeof(u64));
>> + if (callchain == NULL) {
>> + sample_orig->deferred_callchain = false;
>> + return -ENOMEM;
>> + }
>> +
>> + callchain->nr = nr_orig + nr_deferred;
>> + /* copy original including PERF_CONTEXT_USER_DEFERRED (but the cookie) */
>> + memcpy(callchain->ips, sample_orig->callchain->ips, nr_orig * sizeof(u64));
>> + /* copy deferred user callchains */
>> + memcpy(&callchain->ips[nr_orig], sample_callchain->callchain->ips,
>> + nr_deferred * sizeof(u64));
>> +
>> + sample_orig->callchain = callchain;
>
> Hope you don't mind my naive question, as I don't have a clue about perf:
>
> Doesn't the sample_orig->callchain storage need to be free'd prior to
> assigning the newly allocated one? Or is that just part of a large
> block that got allocated in one piece? How is then the one allocated
> here ever free'd?
Never mind, I found that it is getting free'd in
evlist__deliver_deferred_callchain().
>
>> + return 0;
>> +}
> Thanks and regards,
> Jens
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
next prev parent reply other threads:[~2025-12-12 11:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 23:47 [PATCHSET v6 0/6] perf tools: Add deferred callchain support Namhyung Kim
2025-11-20 23:47 ` [PATCH v6 1/6] tools headers UAPI: Sync linux/perf_event.h for deferred callchains Namhyung Kim
2025-11-20 23:48 ` [PATCH v6 2/6] perf tools: Minimal DEFERRED_CALLCHAIN support Namhyung Kim
2025-11-20 23:48 ` [PATCH v6 3/6] perf record: Add --call-graph fp,defer option for deferred callchains Namhyung Kim
2025-11-21 6:26 ` Thomas Richter
2025-11-24 20:27 ` Namhyung Kim
2025-12-03 5:49 ` Namhyung Kim
2025-11-20 23:48 ` [PATCH v6 4/6] perf script: Display PERF_RECORD_CALLCHAIN_DEFERRED Namhyung Kim
2025-12-12 12:11 ` Jens Remus
2025-11-20 23:48 ` [PATCH v6 5/6] perf tools: Merge deferred user callchains Namhyung Kim
2025-12-02 23:14 ` Ian Rogers
2025-12-03 0:01 ` Namhyung Kim
2025-12-12 11:16 ` Jens Remus
2025-12-12 11:48 ` Jens Remus [this message]
2025-11-20 23:48 ` [PATCH v6 6/6] perf tools: Flush remaining samples w/o deferred callchains Namhyung Kim
2025-12-02 23:15 ` Ian Rogers
2025-12-03 17:58 ` [PATCHSET v6 0/6] perf tools: Add deferred callchain support Namhyung Kim
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=6e5ff603-95ec-4b2c-b0b6-dd29ed2a2627@linux.ibm.com \
--to=jremus@linux.ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=bpf@vger.kernel.org \
--cc=indu.bhagat@oracle.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).