All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiebin Sun" <jiebin.sun@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v6 5/9] perf c2c: add function view stats merge and memory management
Date: Mon, 03 Aug 2026 04:01:31 +0000	[thread overview]
Message-ID: <20260803040131.6BC001F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803035220.172022-6-jiebin.sun@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Pruning level-2 writers leaves dangling pointers in `hroot_in` tree.
--

--- Patch [5]: [PATCH v6 5/9] perf c2c: add function view stats merge and memory management ---
commit 0e7c26167764aee56c787657f5359beaaecb5f75
Author: Jiebin Sun <jiebin.sun@intel.com>

perf c2c: add function view stats merge and memory management

Add the per-entry stats/cstats aggregation helpers and hierarchy teardown.
Child common fields are released through hist_entry__delete(), while the
function-view free callback handles the private child tree and containing
allocation. Also add a helper for pruning writer entries with no stores or
cacheline children.

> diff --git a/tools/perf/ui/browsers/c2c-function.c b/tools/perf/ui/browsers/c2c-function.c
> index 7e26c4d1147f4..fc9a4c4bcb03f 100644
> --- a/tools/perf/ui/browsers/c2c-function.c
> +++ b/tools/perf/ui/browsers/c2c-function.c

[ ... ]

> @@ -683,6 +683,168 @@ c2c_function_hists__reinit(struct c2c_hists *c2c_hists,

[ ... ]

> +static int __maybe_unused c2c_he__prune_empty_writers(struct hist_entry *l1_he)
> +{
> +	struct rb_node *nd;
> +	int surviving = 0;
> +
> +	if (!l1_he->has_children)
> +		return 0;
> +
> +	nd = rb_first_cached(&l1_he->hroot_out);
> +	while (nd) {
> +		struct rb_node *next = rb_next(nd);
> +		struct hist_entry *l2_he = rb_entry(nd, struct hist_entry, rb_node);
> +
> +		if (l2_he->has_children && hist_entry__displayed_stores(l2_he) > 0) {
> +			surviving++;
> +		} else {
> +			rb_erase_cached(&l2_he->rb_node, &l1_he->hroot_out);
> +			hist_entry__delete(l2_he);

[Severity: Medium]
Will this leave a dangling pointer in the parent's hroot_in tree?

When hist_entry__delete() frees l2_he in c2c_he__prune_empty_writers(), it
appears to only be unlinked from l1_he->hroot_out. If l1_he->hroot_in is
subsequently traversed (for example, during a TUI resort operation like
hists__hierarchy_output_resort()), could this lead to a use-after-free
crash when dereferencing the freed l2_he pointer?

> +		}
> +		nd = next;
> +	}
> +
> +	if (!surviving) {
> +		l1_he->hroot_out = RB_ROOT_CACHED;
> +		l1_he->has_children = false;
> +		l1_he->unfolded = false;
> +	}
> +	return surviving;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803035220.172022-1-jiebin.sun@intel.com?part=5

  reply	other threads:[~2026-08-03  4:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  3:52 [PATCH v6 0/9] perf c2c: add a function view Jiebin Sun
2026-08-03  3:52 ` [PATCH v6 1/9] perf c2c: extract shared data structures into c2c.h Jiebin Sun
2026-08-03  3:58   ` sashiko-bot
2026-08-03  3:52 ` [PATCH v6 2/9] perf c2c: add function view browser skeleton Jiebin Sun
2026-08-03  3:55   ` sashiko-bot
2026-08-03  3:52 ` [PATCH v6 3/9] perf c2c: add column rendering for function view Jiebin Sun
2026-08-03  3:52 ` [PATCH v6 4/9] perf c2c: add HPP list parsing for function view columns Jiebin Sun
2026-08-03  3:52 ` [PATCH v6 5/9] perf c2c: add function view stats merge and memory management Jiebin Sun
2026-08-03  4:01   ` sashiko-bot [this message]
2026-08-03  3:52 ` [PATCH v6 6/9] perf c2c: add function view hierarchy entry creation Jiebin Sun
2026-08-03  3:52 ` [PATCH v6 7/9] perf c2c: build and finalize the function view hierarchy Jiebin Sun
2026-08-03  3:52 ` [PATCH v6 8/9] perf c2c: add function view browser UI and cacheline detail Jiebin Sun
2026-08-03  3:52 ` [PATCH v6 9/9] perf c2c: document function view in perf-c2c man page Jiebin Sun
2026-08-04 17:15 ` [PATCH v6 0/9] perf c2c: add a function view Namhyung Kim
2026-08-05  6:12   ` Jiebin Sun
2026-08-05 18:19 ` Namhyung Kim
2026-08-06  7:47   ` Jiebin Sun
2026-08-07  6:19     ` Namhyung Kim
2026-08-10  5:34       ` Jiebin Sun

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=20260803040131.6BC001F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jiebin.sun@intel.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.