Re: [RFC PATCH 08/17] rv: Add Hybrid Automata monitor type

From: Juri Lelli
Date: Tue Aug 19 2025 - 05:26:12 EST


Hi!

On 14/08/25 17:08, Gabriele Monaco wrote:

...

> +/*
> + * ha_monitor_init_env - setup timer and reset all environment
> + *
> + * Called from a hook in the DA start functions, it supplies the da_mon
> + * corresponding to the current ha_mon.
> + * Not all hybrid automata require the timer, still set it for simplicity.
> + */
> +static inline void ha_monitor_init_env(struct da_monitor *da_mon)
> +{
> + struct ha_monitor *ha_mon = to_ha_monitor(da_mon);
> +
> + ha_monitor_reset_all_stored(ha_mon);
> + if (unlikely(!ha_mon->timer.base))
> + hrtimer_setup(&ha_mon->timer, ha_monitor_timer_callback,
> + CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> +}

...

> +/*
> + * Helper functions to handle the monitor timer.
> + * Not all monitors require a timer, in such case the timer will be set up but
> + * never armed.
> + * Timers start since the last reset of the supplied env or from now if env is
> + * not an environment variable. If env was not initialised no timer starts.
> + * Timers can expire on any CPU unless the monitor is per-cpu,
> + * where we assume every event occurs on the local CPU.
> + */
> +static inline void ha_start_timer_ns(struct ha_monitor *ha_mon, enum envs env,
> + u64 expire)
> +{
> + int mode = HRTIMER_MODE_REL;
> + u64 passed = 0;
> +
> + if (env >= 0 && env < ENV_MAX_STORED) {
> + if (ha_monitor_env_invalid(ha_mon, env))
> + return;
> + passed = ha_get_env(ha_mon, env);
> + }
> + if (RV_MON_TYPE == RV_MON_PER_CPU)
> + mode |= HRTIMER_MODE_PINNED;
> + hrtimer_start(&ha_mon->timer, ns_to_ktime(expire - passed), mode);
> +}

Does this also need to be _HARD on RT for the monitor to work?

Also, my only concern with the usage of per-task timers is that
reprogramming add overhead, so I wonder if this gets noticeable when
running some kind of performance sensitive workload in production (as it
was reported for dl-server). Did you test such a case?

Thanks!
Juri