Linux Trace Kernel
 help / color / mirror / Atom feed
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 3/6] rv: Show the mixed enable state of containers
Date: Sat, 21 Nov 2026 15:43:17 +0100	[thread overview]
Message-ID: <9d23c0a68ae574f0c124da238d8ebf676d152039.camel@redhat.com> (raw)
In-Reply-To: <CY8PR19MB70099F2263C408361053B295B7682@CY8PR19MB7009.namprd19.prod.outlook.com>

On Wed, 2026-11-04 at 17:21 +0800, Wei Li wrote:
...
> +enum rv_monitor_state {
> + RV_MON_DISABLED = 0,
> + RV_MON_ENABLED = 1,
> + RV_MON_MIXED = 2,
> +};
> +
>  struct rv_monitor {
>   const char *name;
>   const char *description;
> - bool enabled;
> + enum rv_monitor_state enabled;
>   int (*enable)(void);
>   void (*disable)(void);
>   void (*reset)(void);
> diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c
> index 4e689d4590ae..7846e4092b9c 100644
> --- a/kernel/trace/rv/rv.c
> +++ b/kernel/trace/rv/rv.c
> @@ -235,12 +235,15 @@ bool rv_is_container_monitor(struct rv_monitor *mon)
>  static ssize_t monitor_enable_read_data(struct file *filp, char __user
> *user_buf, size_t count,
>   loff_t *ppos)
>  {
> + const char set_to_char[3] = { '0', '1', 'X' };

Real nit, but nothing ensures these match the enum fields although they should,
you could use a designated initializer:

  { [RV_MON_DISABLED] = '0', .. [RV_MON_MIXED] = 'X' }

>   struct rv_monitor *mon = filp->private_data;
> - const char *buff;
> + char buff[2];
>  
> - buff = mon->enabled ? "1\n" : "0\n";
> + guard(mutex)(&rv_interface_lock);
> + buff[0] = set_to_char[mon->enabled];
> + buff[1] = '\n';
>  
> - return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff)+1);
> + return simple_read_from_buffer(user_buf, count, ppos, buff, 2);

Why don't you use sizeof(buf) here?

>  }
>  
>  /*
> @@ -269,10 +272,22 @@ static int __rv_disable_monitor(struct rv_monitor *mon,
> bool sync)
>  
>  static void rv_disable_single(struct rv_monitor *mon)
>  {
> + struct rv_monitor *cntr = mon->parent;
> + struct rv_monitor *p = cntr;
> +
>   __rv_disable_monitor(mon, true);
> + if (!cntr)
> + return;
> + cntr->enabled = 0;

Do you mean RV_MON_DISABLED?
You added the enum which is nice, don't rely on magic numbers.

> + list_for_each_entry_continue(p, &rv_monitors_list, list) {
> + if (p->parent != cntr)
> + break;
> + if (p->enabled)
> + cntr->enabled = 2;

Do you mean RV_MON_MIXED?

> + }
>  }
>  
> -static int rv_enable_single(struct rv_monitor *mon)
> +static int __rv_enable_monitor(struct rv_monitor *mon)
>  {
>   int retval;
>  
> @@ -289,6 +304,27 @@ static int rv_enable_single(struct rv_monitor *mon)
>   return retval;
>  }
>  
> +static int rv_enable_single(struct rv_monitor *mon)
> +{
> + struct rv_monitor *cntr = mon->parent;
> + struct rv_monitor *p = cntr;
> + int retval;
> +
> + retval = __rv_enable_monitor(mon);
> +
> + if (!retval && cntr) {
> + cntr->enabled = 1;

Do you mean RV_MON_ENABLED?

> + list_for_each_entry_continue(p, &rv_monitors_list, list) {
> + if (p->parent != cntr)
> + break;
> + if (!p->enabled)
> + cntr->enabled = 2;

Do you mean RV_MON_MIXED?

> + }
> + }
> +
> + return retval;
> +}

I need to test it, but at first it looks good and sounds like a nice addition.

Thanks,
Gabriele


  parent reply	other threads:[~2026-11-21 14:43 UTC|newest]

Thread overview: 15+ 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-04  9:32   ` sashiko-bot
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-04  9:37   ` sashiko-bot
2026-11-21 14:43   ` Gabriele Monaco [this message]
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-04  9:39   ` sashiko-bot
2026-11-23  8:24   ` Gabriele Monaco
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=9d23c0a68ae574f0c124da238d8ebf676d152039.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