Linux Perf Users
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 3/4] perf timechart: Fix memory leaks in draw_wakeups()
Date: Fri, 5 Jun 2026 16:20:19 -0700	[thread overview]
Message-ID: <aiNZs9iy4uhIRsh3@google.com> (raw)
In-Reply-To: <20260605231734.1241B1F00893@smtp.kernel.org>

On Fri, Jun 05, 2026 at 11:17:33PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The modified fallback loop condition `while (c && !from && !to)` prematurely aborts the search for task coordinates if either `from` or `to` has already been found.
> --
> 
> commit 757fad46c9b9ecd50deaba0cc7cc1ec56200ab8e
> Author: Namhyung Kim <namhyung@kernel.org>
> 
> perf timechart: Fix memory leaks in draw_wakeups()
> 
> This commit modifies the fallback coordinate search in draw_wakeups()
> to only run when it doesn't have from and to tasks, and ensures c->Y is
> set before copying the comm string to fix memory leaks.
> 
> > diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
> > index fded4be93de0d..9ac4662ef16e9 100644
> > --- a/tools/perf/builtin-timechart.c
> > +++ b/tools/perf/builtin-timechart.c
> 
> [ ... ]
> 
> > @@ -1071,12 +1071,12 @@ static void draw_wakeups(struct timechart *tchart)
> >  					c = c->next;
> >  				}
> >  				c = p->all;
> > -				while (c) {
> > -					if (p->pid == we->waker && !from) {
> > +				while (c && !from && !to) {
> 
> [Severity: Medium]
> Will this condition prematurely abort the search for the second task's
> coordinates?
> 
> Because the waker and wakee are typically two different PIDs, they are
> processed in different iterations of the outer per_pid loop. When the first
> one is found, either from or to becomes non-zero.
> 
> When the outer loop reaches the second PID, the condition !from && !to
> evaluates to false immediately, which skips the fallback coordinate search
> entirely for that second task.
> 
> Should this condition instead be !from || !to so the loop continues as long
> as either coordinate is still missing?

Oops, right.  I meant it.  Will send v2 soon.

Thanks,
Namhyung


  reply	other threads:[~2026-06-05 23:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 23:11 [PATCH 0/4] perf timechart: Fix memory leaks Namhyung Kim
2026-06-05 23:11 ` [PATCH 1/4] perf timechart: Release event samples at the end Namhyung Kim
2026-06-05 23:21   ` Arnaldo Carvalho de Melo
2026-06-05 23:31     ` Namhyung Kim
2026-06-05 23:23   ` sashiko-bot
2026-06-05 23:32     ` Namhyung Kim
2026-06-05 23:11 ` [PATCH 2/4] perf timechart: Fix memory leaks during record Namhyung Kim
2026-06-05 23:21   ` sashiko-bot
2026-06-05 23:23   ` Arnaldo Carvalho de Melo
2026-06-05 23:11 ` [PATCH 3/4] perf timechart: Fix memory leaks in draw_wakeups() Namhyung Kim
2026-06-05 23:17   ` sashiko-bot
2026-06-05 23:20     ` Namhyung Kim [this message]
2026-06-05 23:11 ` [PATCH 4/4] perf test: Update perf timechart test Namhyung Kim
2026-06-05 23:19 ` [PATCH 0/4] perf timechart: Fix memory leaks Arnaldo Carvalho de Melo
2026-06-05 23:28   ` Namhyung Kim
2026-06-05 23:41     ` Arnaldo Carvalho de Melo

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=aiNZs9iy4uhIRsh3@google.com \
    --to=namhyung@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox