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 2/6] rv: Update monitors through a quiesce helper
Date: Mon, 23 Nov 2026 09:19:09 +0100 [thread overview]
Message-ID: <adf958e52bab320a5568ae5786435979d9a904a1.camel@redhat.com> (raw)
In-Reply-To: <CY8PR19MB7009AD3DA7BC39C8D5419B1EB7682@CY8PR19MB7009.namprd19.prod.outlook.com>
On Wed, 2026-11-04 at 17:21 +0800, Wei Li wrote:
> From: Wei Li <liwei391@huawei.com>
>
> The reactor swap inlines the disable-update-re-enable pattern in
> monitor_swap_reactors_single(). The nested flag splits one helper into
> two behaviors. The container path re-enables every nested monitor,
> including the ones the user left off. This abnormal logic seems to be a
> temporary strategy from the comments.
>
> Add rv_update_monitor() helper with callback for generic update
> processing. A monitor is updated with it quiesced and keeps its enabled
> state, including the children of a container.
>
> Signed-off-by: Wei Li <liwei391@huawei.com>
> ---
> kernel/trace/rv/rv.c | 49 +++++++++++++++++++++++++++++++++++
> kernel/trace/rv/rv.h | 2 ++
> kernel/trace/rv/rv_reactors.c | 34 +++++-------------------
> 3 files changed, 58 insertions(+), 27 deletions(-)
>
> diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c
> index 29f155c6968b..4e689d4590ae 100644
> --- a/kernel/trace/rv/rv.c
> +++ b/kernel/trace/rv/rv.c
> @@ -289,6 +289,19 @@ static int rv_enable_single(struct rv_monitor *mon)
> return retval;
> }
>
> +static int rv_update_single(struct rv_monitor *mon, rvmon_update_fn_t update,
> void *data)
So are you passing a function and a void* only not to export enable/disable
functions?
It's probably simpler if you handle this directly in rv_reactors.c
Kinda like it is right now but with your new logic.
Thanks,
Gabriele
> +{
> + int retval = 0;
> + int enabled;
> +
> + enabled = __rv_disable_monitor(mon, true);
> + update(mon, data);
> + if (enabled)
> + retval = rv_enable_single(mon);
> +
> + return retval;
> +}
> +
> static void rv_disable_container(struct rv_monitor *mon)
> {
> struct rv_monitor *p = mon;
> @@ -321,6 +334,22 @@ static int rv_enable_container(struct rv_monitor *mon)
> return retval;
> }
>
> +static int rv_update_container(struct rv_monitor *mon, rvmon_update_fn_t
> update, void *data)
> +{
> + struct rv_monitor *p = mon;
> + int retval = 0;
> +
> + list_for_each_entry_continue(p, &rv_monitors_list, list) {
> + if (retval || p->parent != mon)
> + break;
> + retval = rv_update_single(p, update, data);
> + }
> + if (retval)
> + rv_disable_container(mon);
> + update(mon, data);
> + return retval;
> +}
> +
> /**
> * rv_disable_monitor - disable a given runtime monitor
> * @mon: Pointer to the monitor definition structure.
> @@ -355,6 +384,26 @@ int rv_enable_monitor(struct rv_monitor *mon)
> return retval;
> }
>
> +/**
> + * rv_update_monitor - update and reenable a given runtime monitor
> + * @mon: Pointer to the monitor definition structure.
> + * @update: Pointer to the monitor update callback.
> + * @data: Context data passed to the update().
> + *
> + * Returns 0 on success, error otherwise.
> + */
> +int rv_update_monitor(struct rv_monitor *mon, rvmon_update_fn_t update, void
> *data)
> +{
> + int retval;
> +
> + if (rv_is_container_monitor(mon))
> + retval = rv_update_container(mon, update, data);
> + else
> + retval = rv_update_single(mon, update, data);
> +
> + return retval;
> +}
> +
> /*
> * interface for enabling/disabling a monitor.
> */
> diff --git a/kernel/trace/rv/rv.h b/kernel/trace/rv/rv.h
> index 2c0f51ff9d5c..d0e89b8a66ac 100644
> --- a/kernel/trace/rv/rv.h
> +++ b/kernel/trace/rv/rv.h
> @@ -26,8 +26,10 @@ extern struct mutex rv_interface_lock;
> extern struct list_head rv_monitors_list;
>
> struct dentry *get_monitors_root(void);
> +typedef void (rvmon_update_fn_t)(struct rv_monitor *mon, void *data);
> int rv_disable_monitor(struct rv_monitor *mon);
> int rv_enable_monitor(struct rv_monitor *mon);
> +int rv_update_monitor(struct rv_monitor *mon, rvmon_update_fn_t update, void
> *data);
> bool rv_is_container_monitor(struct rv_monitor *mon);
> bool rv_is_nested_monitor(struct rv_monitor *mon);
>
> diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c
> index ea52f50e6453..06f21bcdd6cf 100644
> --- a/kernel/trace/rv/rv_reactors.c
> +++ b/kernel/trace/rv/rv_reactors.c
> @@ -177,45 +177,25 @@ static const struct seq_operations
> monitor_reactors_seq_ops = {
> .show = monitor_reactor_show
> };
>
> -static void monitor_swap_reactors_single(struct rv_monitor *mon,
> - struct rv_reactor *reactor,
> - bool nested)
> +static void monitor_update_reactor(struct rv_monitor *mon, void *data)
> {
> - bool monitor_enabled;
> + struct rv_reactor *reactor = data;
>
> - /* nothing to do */
> - if (mon->reactor == reactor)
> + if (mon->reactor == data)
> return;
>
> - monitor_enabled = mon->enabled;
> - if (monitor_enabled)
> - rv_disable_monitor(mon);
> -
> mon->reactor = reactor;
> mon->react = reactor->react;
> -
> - /* enable only once if iterating through a container */
> - if (monitor_enabled && !nested)
> - rv_enable_monitor(mon);
> }
>
> static void monitor_swap_reactors(struct rv_monitor *mon, struct rv_reactor
> *reactor)
> {
> - struct rv_monitor *p = mon;
> -
> - if (rv_is_container_monitor(mon))
> - list_for_each_entry_continue(p, &rv_monitors_list, list) {
> - if (p->parent != mon)
> - break;
> - monitor_swap_reactors_single(p, reactor, true);
> - }
> /*
> - * This call enables and disables the monitor if they were active.
> - * In case of a container, we already disabled all and will enable
> all.
> - * All nested monitors are enabled also if they were off, we may
> refine
> - * this logic in the future.
> + * Update the reactor with the monitor quiesced: enabled monitors are
> + * disabled, updated and re-enabled, disabled ones are only updated.
> + * Children of a container keep their enabled state.
> */
> - monitor_swap_reactors_single(mon, reactor, false);
> + rv_update_monitor(mon, monitor_update_reactor, reactor);
> }
>
> static ssize_t
next prev parent reply other threads:[~2026-11-23 8:19 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 [this message]
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
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=adf958e52bab320a5568ae5786435979d9a904a1.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