From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Collin Funk <collin.funk1@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andi Kleen <ak@linux.intel.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Leo Yan <leo.yan@arm.com>, Yicong Yang <yangyicong@hisilicon.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Haibo Xu <haibo1.xu@intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 09/17] perf c2c: Clean up some defensive gets and make asan clean
Date: Mon, 1 Dec 2025 14:45:15 -0300 [thread overview]
Message-ID: <aS3UK1QYkf5vD7Mp@x1> (raw)
In-Reply-To: <20251122081929.7588-10-irogers@google.com>
On Sat, Nov 22, 2025 at 12:19:21AM -0800, Ian Rogers wrote:
> To deal with histogram code that had missing gets the c2c code had
> some defensive gets. Those other issues were cleaned up by the
> reference count checker, clean them up for the c2c command here.
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
- Arnaldo
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/builtin-c2c.c | 36 ++++++++++++++----------------------
> 1 file changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index 14c3823f8fed..d390ae4e3ec8 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
> @@ -322,7 +322,7 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
> struct c2c_stats stats = { .nr_entries = 0, };
> struct hist_entry *he;
> struct addr_location al;
> - struct mem_info *mi, *mi_dup;
> + struct mem_info *mi = NULL;
> struct callchain_cursor *cursor;
> int ret;
>
> @@ -349,20 +349,15 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
> goto out;
> }
>
> - /*
> - * The mi object is released in hists__add_entry_ops,
> - * if it gets sorted out into existing data, so we need
> - * to take the copy now.
> - */
> - mi_dup = mem_info__get(mi);
> -
> c2c_decode_stats(&stats, mi);
>
> he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
> &al, NULL, NULL, mi, NULL,
> sample, true);
> - if (he == NULL)
> - goto free_mi;
> + if (he == NULL) {
> + ret = -ENOMEM;
> + goto out;
> + }
>
> c2c_he = container_of(he, struct c2c_hist_entry, he);
> c2c_add_stats(&c2c_he->stats, &stats);
> @@ -393,17 +388,19 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
> int cpu = sample->cpu == (unsigned int) -1 ? 0 : sample->cpu;
> int node = c2c.cpu2node[cpu];
>
> - mi = mi_dup;
> -
> c2c_hists = he__get_c2c_hists(he, c2c.cl_sort, 2, machine->env);
> - if (!c2c_hists)
> - goto free_mi;
> + if (!c2c_hists) {
> + ret = -ENOMEM;
> + goto out;
> + }
>
> he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
> &al, NULL, NULL, mi, NULL,
> sample, true);
> - if (he == NULL)
> - goto free_mi;
> + if (he == NULL) {
> + ret = -ENOMEM;
> + goto out;
> + }
>
> c2c_he = container_of(he, struct c2c_hist_entry, he);
> c2c_add_stats(&c2c_he->stats, &stats);
> @@ -421,14 +418,9 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused,
> }
>
> out:
> + mem_info__put(mi);
> addr_location__exit(&al);
> return ret;
> -
> -free_mi:
> - mem_info__put(mi_dup);
> - mem_info__put(mi);
> - ret = -ENOMEM;
> - goto out;
> }
>
> static const char * const c2c_usage[] = {
> --
> 2.52.0.rc2.455.g230fcf2819-goog
next prev parent reply other threads:[~2025-12-01 17:45 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 8:19 [PATCH v1 00/17] perf: Small fixes and new tests Ian Rogers
2025-11-22 8:19 ` [PATCH v1 01/17] perf kvm: Fix debug assertion Ian Rogers
2025-11-26 6:33 ` Namhyung Kim
2025-11-22 8:19 ` [PATCH v1 02/17] perf timechart: Add record support for output perf.data path Ian Rogers
2025-11-26 6:38 ` Namhyung Kim
2025-11-22 8:19 ` [PATCH v1 03/17] perf symbol-elf: Add missing puts on error path Ian Rogers
2025-12-01 18:04 ` Arnaldo Carvalho de Melo
2025-11-22 8:19 ` [PATCH v1 04/17] perf symbol: Add missed dso__put Ian Rogers
2025-11-22 8:19 ` [PATCH v1 05/17] perf probe-event: Ensure probe event nsinfo is always cleared Ian Rogers
2025-11-26 6:58 ` Namhyung Kim
2025-11-22 8:19 ` [PATCH v1 06/17] perf hist: In init, ensure mem_info is put on error paths Ian Rogers
2025-12-01 17:05 ` Arnaldo Carvalho de Melo
2025-12-01 17:14 ` Arnaldo Carvalho de Melo
2025-12-01 17:52 ` Ian Rogers
2025-11-22 8:19 ` [PATCH v1 07/17] perf mem-events: Don't leak online CPU map Ian Rogers
2025-12-01 17:01 ` Arnaldo Carvalho de Melo
2025-11-22 8:19 ` [PATCH v1 08/17] perf jitdump: Fix missed dso__put Ian Rogers
2025-12-01 17:00 ` Arnaldo Carvalho de Melo
2025-11-22 8:19 ` [PATCH v1 09/17] perf c2c: Clean up some defensive gets and make asan clean Ian Rogers
2025-12-01 17:45 ` Arnaldo Carvalho de Melo [this message]
2025-11-22 8:19 ` [PATCH v1 10/17] perf tests c2c: Add a basic c2c Ian Rogers
2025-11-22 8:19 ` [PATCH v1 11/17] perf tests buildid: Add purge and remove testing Ian Rogers
2025-11-22 8:19 ` [PATCH v1 12/17] perf tests top: Add basic perf top coverage test Ian Rogers
2025-11-22 8:19 ` [PATCH v1 13/17] perf tests timechart: Add a perf timechart test Ian Rogers
2025-11-22 8:19 ` [PATCH v1 14/17] perf tests kallsyms: Add basic kallsyms test Ian Rogers
2025-11-22 8:19 ` [PATCH v1 15/17] perf tests script dlfilter: Add a dlfilter test Ian Rogers
2025-11-22 8:19 ` [PATCH v1 16/17] perf tests evlist: Add basic evlist test Ian Rogers
2025-11-26 7:19 ` Namhyung Kim
2025-11-22 8:19 ` [PATCH v1 17/17] perf test kvm: Add some basic perf kvm test coverage Ian Rogers
2025-11-26 7:21 ` Namhyung Kim
2025-11-27 11:53 ` Ian Rogers
2025-11-27 20:55 ` Namhyung Kim
2025-11-28 9:06 ` Ian Rogers
2025-12-03 19:03 ` Namhyung Kim
2025-12-04 19:10 ` [PATCH v1 00/17] perf: Small fixes and new tests 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=aS3UK1QYkf5vD7Mp@x1 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=collin.funk1@gmail.com \
--cc=dvyukov@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=haibo1.xu@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=stephen.s.brennan@oracle.com \
--cc=thomas.falcon@intel.com \
--cc=yangyicong@hisilicon.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).