From: Crystal Wood <crwood@redhat.com>
To: Ivan Pravdin <ipravdin.official@gmail.com>,
rostedt@goodmis.org, corbet@lwn.net, tglozar@redhat.com,
linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] rtla: fix -C/--cgroup interface
Date: Fri, 29 Aug 2025 14:12:28 -0500 [thread overview]
Message-ID: <3b9bf6e435b2eb85b44557d474a003ec6d2c0c1c.camel@redhat.com> (raw)
In-Reply-To: <9394c039d5c957bd8417669148391e20fa1276ee.1755018581.git.ipravdin.official@gmail.com>
On Tue, 2025-08-12 at 13:21 -0400, Ivan Pravdin wrote:
> Currently, user can only specify cgroup to the tracer's thread the
> following ways:
>
> `-C[cgroup]`
> `-C[=cgroup]`
> `--cgroup[=cgroup]`
>
> If user tries to specify cgroup as `-C [cgroup]` or `--cgroup [cgroup]`,
> the parser silently fails and rtla's cgroup is used for the tracer
> threads.
>
> To make interface more user-friendly, allow user to specify cgroup in
> the aforementioned way, i.e. `-C [cgroup]` and `--cgroup [cgroup]`
>
> Change documentation to reflect this user interface change.
I know these are the semantics that --trace implements, but they're
rather atypical... especially -C=group.
> @@ -559,12 +559,17 @@ static struct osnoise_params
> break;
> case 'C':
> params->cgroup = 1;
> - if (!optarg) {
> - /* will inherit this cgroup */
> + if (optarg) {
> + if (optarg[0] == '=') {
> + /* skip the = */
> + params->cgroup_name = &optarg[1];
> + } else {
> + params->cgroup_name = optarg;
> + }
> + } else if (optind < argc && argv[optind][0] != '-') {
> + params->cgroup_name = argv[optind];
> + } else {
> params->cgroup_name = NULL;
> - } else if (*optarg == '=') {
> - /* skip the = */
> - params->cgroup_name = ++optarg;
If we're going to be consistently using these semantics, we should move
this logic into a utility function rather than open-coding it
everywhere.
Also, theoretically, shouldn't we be advancing optind for the case where
that's consumed? Not that it matters much if we don't have positional
arguments once the options begin, and if we did, then allowing
"--arg optional-thing" would be ambiguous...
-Crystal
next prev parent reply other threads:[~2025-08-29 19:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 17:21 [PATCH v2 0/3] rtla: fix cgroup and trace options parsing Ivan Pravdin
2025-08-12 17:21 ` [PATCH v2 1/3] rtla: fix buffer overflow in actions_parse Ivan Pravdin
2025-08-28 12:17 ` Tomas Glozar
2025-08-12 17:21 ` [PATCH v2 2/3] rtla: fix -C/--cgroup interface Ivan Pravdin
2025-08-29 19:12 ` Crystal Wood [this message]
2025-09-02 18:09 ` Ivan Pravdin
2025-08-12 17:21 ` [PATCH v2 3/3] rtla: fix -a overriding -t argument Ivan Pravdin
2025-09-01 14:23 ` Tomas Glozar
2025-09-02 18:05 ` Ivan Pravdin
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=3b9bf6e435b2eb85b44557d474a003ec6d2c0c1c.camel@redhat.com \
--to=crwood@redhat.com \
--cc=corbet@lwn.net \
--cc=ipravdin.official@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.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).