linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>,
	peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	namhyung@kernel.org, adrian.hunter@intel.com,
	kan.liang@linux.intel.com, sandipan.das@amd.com,
	ravi.bangoria@amd.com, linux-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org
Subject: Re: [RFC v1 01/16] perf kwork: Fix incorrect and missing free atom in work_push_atom()
Date: Wed, 6 Sep 2023 13:43:35 -0300	[thread overview]
Message-ID: <ZPisN7/pZrnQeQmK@kernel.org> (raw)
In-Reply-To: <CAP-5=fUVY9eL-t4Ya5bqHz7gDKDSi9=kvDgMdGmb02Yh8LhVaA@mail.gmail.com>

Em Sun, Sep 03, 2023 at 09:05:06PM -0700, Ian Rogers escreveu:
> On Sat, Aug 12, 2023 at 1:52 AM Yang Jihong <yangjihong1@huawei.com> wrote:
> >
> > 1. Atoms are managed in page mode and should be released using atom_free()
> >    instead of free().
> > 2. When the event does not match, the atom needs to free.
> >
> > Fixes: f98919ec4fcc ("perf kwork: Implement 'report' subcommand")
> > Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>

Thanks, applied locally, will perform some tests and later today
probably push publicly, great work!

- Arnaldo

 
> > ---
> >  tools/perf/builtin-kwork.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c
> > index 14bf7a8429e7..73b5dc099a8a 100644
> > --- a/tools/perf/builtin-kwork.c
> > +++ b/tools/perf/builtin-kwork.c
> > @@ -406,12 +406,14 @@ static int work_push_atom(struct perf_kwork *kwork,
> >
> >         work = work_findnew(&class->work_root, &key, &kwork->cmp_id);
> >         if (work == NULL) {
> > -               free(atom);
> > +               atom_free(atom);
> 
> Presumably this is fixing a memory-leak. It would be nice if kwork had
> perf tests, then our builds with -fsanitize=address would highlight
> this kind of issue. Here is a build command I use for this:
> make -C tools/perf O=/tmp/perf DEBUG=1 EXTRA_CFLAGS="-O0 -g
> -fno-omit-frame-pointer -fsanitize=address" BUILD_BPF_SKEL=1
> NO_LIBTRACEEVENT=1
> 
> Thanks,
> Ian
> 
> >                 return -1;
> >         }
> >
> > -       if (!profile_event_match(kwork, work, sample))
> > +       if (!profile_event_match(kwork, work, sample)) {
> > +               atom_free(atom);
> >                 return 0;
> > +       }
> >
> >         if (dst_type < KWORK_TRACE_MAX) {
> >                 dst_atom = list_last_entry_or_null(&work->atom_list[dst_type],
> > --
> > 2.30.GIT
> >

-- 

- Arnaldo

  parent reply	other threads:[~2023-09-06 16:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-12  8:49 [RFC v1 00/16] perf kwork: Implement perf kwork top Yang Jihong
2023-08-12  8:49 ` [RFC v1 01/16] perf kwork: Fix incorrect and missing free atom in work_push_atom() Yang Jihong
2023-09-04  4:05   ` Ian Rogers
2023-09-04 11:42     ` Yang Jihong
2023-09-06 16:43     ` Arnaldo Carvalho de Melo [this message]
2023-08-12  8:49 ` [RFC v1 02/16] perf kwork: Add the supported subcommands to the document Yang Jihong
2023-08-12  8:49 ` [RFC v1 03/16] perf kwork: Set ordered_events for perf_tool Yang Jihong
2023-08-12  8:49 ` [RFC v1 04/16] perf kwork: Add `kwork` and `src_type` to work_init() for struct kwork_class Yang Jihong
2023-08-12  8:49 ` [RFC v1 05/16] perf kwork: Overwrite original atom in the list when a new atom is pushed Yang Jihong
2023-09-04  4:13   ` Ian Rogers
2023-09-04 11:46     ` Yang Jihong
2023-08-12  8:49 ` [RFC v1 06/16] perf kwork: Set default events list if not specified in setup_event_list() Yang Jihong
2023-08-12  8:49 ` [RFC v1 07/16] perf kwork: Add sched record support Yang Jihong
2023-08-12  8:49 ` [RFC v1 08/16] perf kwork: Add `root` parameter to work_sort() Yang Jihong
2023-08-12  8:49 ` [RFC v1 09/16] perf kwork: Implement perf kwork top Yang Jihong
2023-08-12  8:49 ` [RFC v1 10/16] perf evsel: Add evsel__intval_common() helper Yang Jihong
2023-08-12  8:49 ` [RFC v1 11/16] perf kwork top: Add statistics on hardirq event support Yang Jihong
2023-08-12  8:49 ` [RFC v1 12/16] perf kwork top: Add statistics on softirq " Yang Jihong
2023-08-12  8:49 ` [RFC v1 13/16] perf kwork top: Add -C/--cpu -i/--input -n/--name -s/--sort --time options Yang Jihong
2023-08-12  8:49 ` [RFC v1 14/16] perf kwork top: Implements BPF-based cpu usage statistics Yang Jihong
2023-08-12  8:49 ` [RFC v1 15/16] perf kwork top: Add BPF-based statistics on hardirq event support Yang Jihong
2023-08-12  8:49 ` [RFC v1 16/16] perf kwork top: Add BPF-based statistics on softirq " Yang Jihong
2023-09-04  5:13 ` [RFC v1 00/16] perf kwork: Implement perf kwork top Ian Rogers
2023-09-04 11:59   ` Yang Jihong
2023-09-04 14:54     ` Ian Rogers
2023-09-05  1:01       ` Yang Jihong

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=ZPisN7/pZrnQeQmK@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=sandipan.das@amd.com \
    --cc=yangjihong1@huawei.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).