From: Gabriele Monaco <gmonaco@redhat.com>
To: Wei Li <liwei1412@hotmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Nam Cao <namcao@linutronix.de>
Cc: linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
liwei391@huawei.com
Subject: Re: [PATCH 5/6] tools/rv: Parse the mixed enable state of containers
Date: Mon, 23 Nov 2026 09:24:51 +0100 [thread overview]
Message-ID: <7b5bbd08396e7478b68c941f1f20e111a1623869.camel@redhat.com> (raw)
In-Reply-To: <CY8PR19MB700974075298C61A1DB70C3EB7682@CY8PR19MB7009.namprd19.prod.outlook.com>
On Wed, 2026-11-04 at 17:21 +0800, Wei Li wrote:
> From: Wei Li <liwei391@huawei.com>
...
> --- a/tools/verification/rv/src/in_kernel.c
> +++ b/tools/verification/rv/src/in_kernel.c
> @@ -29,21 +29,38 @@ static char *config_reactor;
> *
> * __does not log errors.
> *
> - * Returns the current status, or -1 if the monitor does not exist,
> - * __hence not logging errors.
> + * Returns 0 if disabled, 1 if enabled, 2 if a container with children
> + * in mixed states, or -1 if the monitor does not exist, __hence not
> + * logging errors.
Instead of documenting the meaning of integers, why don't you copy the
enum here too?
It doesn't necessarily need to match (that is, obviously use the same,
but if it ever diverges, nothing is going to happen). I think it gets
more readable.
> */
> static int __ikm_read_enable(char *monitor_name)
> {
> char path[MAX_PATH];
> - long long enabled;
> - int retval;
> + char *buffer;
> + int enabled;
>
> snprintf(path, MAX_PATH, "rv/monitors/%s/enable", monitor_name);
>
> - retval = tracefs_instance_file_read_number(NULL, path, &enabled);
> - if (retval < 0)
> + buffer = tracefs_instance_file_read(NULL, path, NULL);
> + if (!buffer)
> return -1;
>
> + switch (buffer[0]) {
> + case '0':
> + enabled = 0;
> + break;
> + case '1':
> + enabled = 1;
> + break;
> + case 'X':
> + enabled = 2;
> + break;
> + default:
> + enabled = -1;
> + }
> +
> + free(buffer);
> +
> return enabled;
> }
>
> @@ -370,7 +387,8 @@ int ikm_list_monitors(char *container)
> list_monitor = 1;
> printf("%s%-*s %s %s\n", indent ? " - " : "",
> indent ? MAX_DA_NAME_LEN - 3 :
> MAX_DA_NAME_LEN,
> - ikm.name, ikm.desc, ikm.enabled ? "[ON]" :
> "[OFF]");
> + ikm.name, ikm.desc,
> + ikm.enabled == 2 ? "[MIX]" : ikm.enabled ?
> "[ON]" : "[OFF]");
This double ternary operator needs parentheses, otherwise we are relying
on some non-trivial operator precedence rules.
Thanks,
Gabriele
next prev parent reply other threads:[~2026-11-23 8:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 9:21 [PATCH 0/6] rv: Expose and preserve nested monitor states Wei Li
2026-11-04 9:21 ` [PATCH 1/6] rv: Mark diverged child reactors with a star Wei Li
2026-11-23 8:03 ` Gabriele Monaco
2026-11-04 9:21 ` [PATCH 2/6] rv: Update monitors through a quiesce helper Wei Li
2026-11-23 8:19 ` Gabriele Monaco
2026-11-04 9:21 ` [PATCH 3/6] rv: Show the mixed enable state of containers Wei Li
2026-11-21 14:43 ` Gabriele Monaco
2026-11-04 9:21 ` [PATCH 4/6] Documentation/rv: Document the enable and reactor states Wei Li
2026-11-04 9:21 ` [PATCH 5/6] tools/rv: Parse the mixed enable state of containers Wei Li
2026-11-23 8:24 ` Gabriele Monaco [this message]
2026-11-04 9:21 ` [PATCH 6/6] rv: Do not send the trailing NUL to userspace Wei Li
2026-11-23 9:10 ` Gabriele Monaco
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=7b5bbd08396e7478b68c941f1f20e111a1623869.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=liwei1412@hotmail.com \
--cc=liwei391@huawei.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=namcao@linutronix.de \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=skhan@linuxfoundation.org \
/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