Re: [PATCH V6 04/16] rv/include: Add deterministic automata monitor definition via C macros

From: Daniel Bristot de Oliveira
Date: Thu Jul 21 2022 - 08:08:55 EST


On 7/20/22 22:06, Steven Rostedt wrote:
>> +/* \
>> + * da_monitor_enabled_##name - checks if the monitor is enabled \
>> + */ \
>> +static inline bool da_monitor_enabled_##name(void) \
>> +{ \
> Should we add a:
>
> smp_rmb();
>
> here? And then a smp_wmb() where these switches get updated?
>

Makes sense.

Should I also add the READ_ONCE/WRITE_ONCE? like

smp_rmb()
READ_ONCE(var)

WRITE_ONCE(var, value)
smp_wmb()

for all these on/off knobs, or just the barriers?

> I guess how critical is it that these turn off immediately after the switch
> is flipped?

It is not critical to continue the execution of those that have already crossed by
the variable. Still, waiting for the tracepoints to finish their execution before
returning to the user-space task that disabled the variable might be a good thing.

IIRC, we can do that via RCU... like, synchronize_rcu()?

>> + /* global switch */ \
>> + if (unlikely(!rv_monitoring_on())) \
>> + return 0; \
>> + \
>> + /* monitor enabled */ \
>> + if (unlikely(!rv_##name.enabled)) \
>> + return 0; \
>> + \
>> + return 1; \
>> +} \
>> + \