From: Namhyung Kim <namhyung@kernel.org>
To: Aditya Gupta <adityag@linux.ibm.com>
Cc: acme@kernel.org, jolsa@kernel.org, irogers@google.com,
linux-perf-users@vger.kernel.org, maddy@linux.ibm.com,
atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com,
disgoel@linux.vnet.ibm.com
Subject: Re: [PATCH v12 1/4] perf check: introduce check subcommand
Date: Fri, 12 Jul 2024 15:22:08 -0500 [thread overview]
Message-ID: <ZpGQcN8RBHs6peFL@google.com> (raw)
In-Reply-To: <htq5vhx6piet4nuq2mmhk7fs2bhfykv52dbppwxmo3s7du2odf@styd27tioc6e>
Hello,
On Wed, Jul 03, 2024 at 04:17:09PM +0530, Aditya Gupta wrote:
> Hi Namhyung,
>
> > > <...snip...>
> > >
> > > > > +static const char *check_usage[] = {
> > > > > + "perf check [<subcommand>] [<options>]",
> > > >
> > > > You can leave this NULL and parse_options_subcommand() will fill the
> > > > first element automatically using check_subcommands[].
> > > >
> > > > Please see other commands like 'perf sched' how to handle this.
> > >
> > > It doesn't seem to be working, hence added that check_usage in v12
> > > itself.
> > >
> > > $ ./perf check
> > > Usage: (null)
> > >
> > > -q, --quiet do not show any warnings or messages
> > >
> > > $ ./perf sched
> > > Usage: (null)
> > >
> > > -D, --dump-raw-trace dump raw trace in ASCII
> > > -f, --force don't complain, do it
> > > -i, --input <file> input file name
> > > -v, --verbose be more verbose (show symbol address, etc)
> > >
> > > Debugging it further, this behaviour was changed in
> > >
> > > commit 230a7a71f9221: libsubcmd: Fix parse-options memory leak
> > >
> > > Where the generated usage string is deallocated, and usage[0] string is
> > > reassigned as NULL.
> >
> > Ok, thanks for the investigation. It's a bug then.
> >
> > >
> > > If expected behaviour was allocation of the usage string, it should be
> > > okay for the buffer to not get deallocated for the entirety of the perf
> > > process's lifetime right ?
> >
> > Right, it should not deallocate it in the parse_options_subcommand().
> > I think we need to change the exit path of the commands to free the
> > usage[0] manually.
>
> Sure, I can implement that if you have things in hand, or I am fine with
> you implementing it since you will already have an idea what to do.
>
> Maybe `free(command_usage[0])` or something like
> `parse_options_free_subcommand()` ?
It seems we don't have a place to mark whether it needs to free or not.
Let's go with free(command_usage[0]) for now.
Thanks,
Namhyung
next prev parent reply other threads:[~2024-07-12 20:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 6:42 [PATCH v12 0/4] Introduce perf check subcommand Aditya Gupta
2024-06-28 6:42 ` [PATCH v12 1/4] perf check: introduce " Aditya Gupta
2024-06-28 18:37 ` Namhyung Kim
2024-06-30 11:37 ` Aditya Gupta
2024-07-02 23:47 ` Namhyung Kim
2024-07-03 10:47 ` Aditya Gupta
2024-07-03 21:26 ` Namhyung Kim
2024-07-12 20:22 ` Namhyung Kim [this message]
2024-07-17 6:42 ` Aditya Gupta
2024-06-28 6:42 ` [PATCH v12 2/4] perf version: update --build-options to use 'supported_features' array Aditya Gupta
2024-06-28 6:42 ` [PATCH v12 3/4] perf tests task_analyzer: use perf check for libtraceevent support Aditya Gupta
2024-06-28 6:42 ` [PATCH v12 4/4] tools/perf/tests: Update probe_vfs_getname.sh script to use perf check feature Aditya Gupta
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=ZpGQcN8RBHs6peFL@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adityag@linux.ibm.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=disgoel@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kjain@linux.ibm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=maddy@linux.ibm.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).