[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b9bf6e435b2eb85b44557d474a003ec6d2c0c1c.camel@redhat.com>
Date: Fri, 29 Aug 2025 14:12:28 -0500
From: Crystal Wood <crwood@...hat.com>
To: Ivan Pravdin <ipravdin.official@...il.com>, rostedt@...dmis.org,
corbet@....net, tglozar@...hat.com, linux-trace-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/3] rtla: fix -C/--cgroup interface
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
Powered by blists - more mailing lists