From: Gabriele Monaco <gmonaco@redhat.com>
To: Tobias Schaffner <tobias.schaffner@siemens.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>,
Randy Dunlap <rdunlap@infradead.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
rpm@xenomai.org, jan.kiszka@siemens.com,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v4 3/4] rv: collect per-edge dwell time for per-cpu DA/HA monitors
Date: Fri, 27 Nov 2026 10:11:42 +0100 [thread overview]
Message-ID: <c28787b366061c55ea1849680703fa0bab1a0fef.camel@redhat.com> (raw)
In-Reply-To: <9a1df2a6-27fb-4029-866d-c115d9f0b5f7@siemens.com>
On Fri, 2026-11-27 at 10:03 +0100, Tobias Schaffner wrote:
>
> Fair. Sorry for not having this on my radar.
>
> Do you agree that 3 is the cleanest option? I would prefer it over
> always having one wrong sample (option 1) and making sure that no event
> slips in between start and reset (option 2).
Yes, good point and agreed. It also compiles exactly to your previous solution.
Feel free to shape it the way you find cleaner and give the new function a
better name if you see it fit, but you got the gist of it.
Thanks,
Gabriele
>
> Best,
> Tobias
>
> > What do you think?
> >
> > Thanks,
> > Gabriele
> >
> > > {
> > > - da_mon->curr_state = model_get_initial_state();
> > > + da_mon->curr_state = state;
> > > da_monitor_init_hook(da_mon);
> > > /* Pairs with smp_load_acquire in da_monitoring(). */
> > > smp_store_release(&da_mon->monitoring, 1);
> > > @@ -276,6 +278,11 @@ static inline void da_monitor_reset_state_all(void)
> > > */
> > > static inline int da_monitor_init(void)
> > > {
> > > + int retval = rv_edge_stats_create(rv_this.root_d);
> > > +
> > > + if (retval)
> > > + return retval;
> > > +
> > > da_monitor_reset_state_all();
> > > return 0;
> > > }
> > > @@ -287,6 +294,7 @@ static inline void da_monitor_destroy(void)
> > > {
> > > da_monitor_reset_all();
> > > da_monitor_sync_hook();
> > > + rv_edge_stats_remove();
> > > }
> > >
> > > #ifndef da_implicit_guard
> > > @@ -689,9 +697,11 @@ static inline void da_trace_error(struct da_monitor
> > > *da_mon,
> > > static inline bool da_event(struct da_monitor *da_mon, enum events
> > > event,
> > > da_id_type id)
> > > {
> > > enum states curr_state, next_state;
> > > + da_state_t old;
> > >
> > > - curr_state = READ_ONCE(da_mon->curr_state);
> > > + old = READ_ONCE(da_mon->curr_state);
> > > for (int i = 0; i < MAX_DA_RETRY_RACING_EVENTS; i++) {
> > > + curr_state = da_state_of(old);
> > > next_state = model_get_next_state(curr_state, event);
> > > if (next_state == INVALID_STATE) {
> > > react(curr_state, event);
> > > @@ -699,7 +709,8 @@ static inline bool da_event(struct da_monitor *da_mon,
> > > enum events event, da_id_
> > > model_get_event_name(event), id);
> > > return false;
> > > }
> > > - if (likely(try_cmpxchg(&da_mon->curr_state, &curr_state,
> > > next_state))) {
> > > + if (likely(da_state_try_commit(&da_mon->curr_state, &old,
> > > + next_state, event))) {
> > > if (!da_monitor_event_hook(da_mon, curr_state,
> > > event,
> > > next_state, id))
> > > return false;
> > > da_trace_event(da_mon,
> > > model_get_state_name(curr_state),
> > > @@ -737,7 +748,7 @@ static inline bool __da_handle_start_event(struct
> > > da_monitor *da_mon,
> > > if (!da_monitor_enabled())
> > > return 0;
> > > if (unlikely(!da_monitoring(da_mon))) {
> > > - da_monitor_start(da_mon);
> > > + da_monitor_start(da_mon,
> > > da_state_entered(model_get_initial_state()));
> > > return 0;
> > > }
> > >
> > > @@ -751,8 +762,9 @@ static inline bool __da_handle_start_run_event(struct
> > > da_monitor *da_mon,
> > > {
> > > if (!da_monitor_enabled())
> > > return 0;
> > > + /* In the initial state since an unknown time: do not time it. */
> > > if (unlikely(!da_monitoring(da_mon)))
> > > - da_monitor_start(da_mon);
> > > + da_monitor_start(da_mon, model_get_initial_state());
> > >
> > > __da_handle_event_common(da_mon, event, id);
> > >
> > > diff --git a/include/rv/edge_stat.h b/include/rv/edge_stat.h
> > > index 8b99e8520e1e..16c28aedabdd 100644
> > > --- a/include/rv/edge_stat.h
> > > +++ b/include/rv/edge_stat.h
> > > @@ -145,7 +145,10 @@ static void rv_edge_stats_remove(void)
> > > rv_this_stats_file = NULL;
> > > }
> > >
> > > -/* A zero timestamp marks resets, which can run on a different CPU. */
> > > +/*
> > > + * A zero timestamp marks an unknown entry time: resets can run on a
> > > different
> > > + * CPU, and da_handle_start_run_event() starts in a state entered
> > > earlier.
> > > + */
> > > #define da_state_entered(s) da_state_pack((s), local_clock())
> > >
> > > static __always_inline void
> > > diff --git a/include/rv/ha_monitor.h b/include/rv/ha_monitor.h
> > > index 6e1c7fe5449a..78d1bb80aefd 100644
> > > --- a/include/rv/ha_monitor.h
> > > +++ b/include/rv/ha_monitor.h
> > > @@ -312,7 +312,7 @@ static inline void __ha_monitor_timer_callback(struct
> > > ha_monitor *ha_mon)
> > > if (unlikely(READ_ONCE(ha_mon_destroying)))
> > > return;
> > > /* Ensure consistent curr_state if we race with da_monitor_reset
> > > */
> > > - curr_state = smp_load_acquire(&ha_mon->da_mon.curr_state);
> > > + curr_state = da_state_of(smp_load_acquire(&ha_mon-
> > > > da_mon.curr_state));
> > > if (unlikely(!da_monitor_handling_event(&ha_mon->da_mon)))
> > > return;
> > >
> >
next prev parent reply other threads:[~2026-11-27 9:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 7:05 [PATCH v4 0/4] rv: per-edge dwell-time statistics for per-cpu monitors Tobias Schaffner
2026-11-27 7:05 ` [PATCH v4 1/4] rv: guard rv.h against double inclusion Tobias Schaffner
2026-11-27 7:05 ` [PATCH v4 2/4] rv: add per-edge dwell-time statistics Tobias Schaffner
2026-11-27 7:05 ` [PATCH v4 3/4] rv: collect per-edge dwell time for per-cpu DA/HA monitors Tobias Schaffner
2026-11-27 8:27 ` Gabriele Monaco
2026-11-27 9:03 ` Tobias Schaffner
2026-11-27 9:11 ` Gabriele Monaco [this message]
2026-11-27 7:05 ` [PATCH v4 4/4] selftests/verification: test per-edge dwell-time statistics Tobias Schaffner
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=c28787b366061c55ea1849680703fa0bab1a0fef.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=corbet@lwn.net \
--cc=jan.kiszka@siemens.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rpm@xenomai.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tobias.schaffner@siemens.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