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: Tue, 2 Jul 2024 16:47:21 -0700 [thread overview]
Message-ID: <ZoSRiW1aVsV-xrur@google.com> (raw)
In-Reply-To: <tylbo22m2koyrcypdykidcuzcwrtfqrzehcwwwmqkcqnbnhz2y@rnsy3gyfmzj4>
On Sun, Jun 30, 2024 at 05:07:10PM +0530, Aditya Gupta wrote:
> Hi Namhyung,
>
> > > +static const char * const check_subcommands[] = { "feature", NULL };
> > > +static struct option check_options[] = {
> > > + OPT_BOOLEAN('q', "quiet", &quiet, "do not show any warnings or messages"),
> > > + OPT_END()
> > > +};
> > > +static struct option check_feature_options[] = { OPT_END() };
> >
> > It should be OPT_PARENT(check_options) instead of OPT_END().
>
> I did not know that. Thank you.
>
> >
> > > +
> > > +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.
Thanks,
Namhyung
next prev parent reply other threads:[~2024-07-02 23:47 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 [this message]
2024-07-03 10:47 ` Aditya Gupta
2024-07-03 21:26 ` Namhyung Kim
2024-07-12 20:22 ` Namhyung Kim
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=ZoSRiW1aVsV-xrur@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).