On Tue, 2026-05-05 at 08:59 +0200, Nam Cao wrote:
> -static inline bool ha_check_invariant_ns(struct ha_monitor *ha_mon,
> - enum envs env, u64 time_ns)
> +static inline bool ha_check_invariant_ns(struct ha_monitor *ha_mon, enum envs
> env,
> + u64 time_ns, u64 expire_ns)
> {
> - return READ_ONCE(ha_mon->env_store[env]) >= time_ns;
> + return time_ns - READ_ONCE(ha_mon->env_store[env]) <= expire_ns;
> }
This function had the silent assumption that invalid/uninitialised
values (max u64) pass the check.
This is no longer working (see nomiss) but could be restored by doing:
READ_ONCE(ha_mon->env_store[env]) >= time_ns - expire_ns
But.. Yeah, that's a weak assumption. We should probably refactor the
thing to use ha_reset_env() in ha_monitor_reset_all_stored(), then
variables are never going to be uninitialised. It needs a bit of
tinkering but it's definitely better than now.
I'll try and add that to my fixes series.
And I should add some nomiss and stall selftest..
> -static inline bool ha_check_invariant_jiffy(struct ha_monitor *ha_mon,
> - enum envs env, u64 time_ns)
> +static inline bool ha_check_invariant_jiffy(struct ha_monitor *ha_mon, enum
> envs env,
> + u64 time_ns, u64 expire_jiffy)
> {
> - return time_after64(READ_ONCE(ha_mon->env_store[env]),
> get_jiffies_64());
> -
> + return time_after64(READ_ONCE(ha_mon->env_store[env]) + expire_jiffy,
> get_jiffies_64());
> }
I'd prefer if this was consistent with the above as in (now - env <=
expire) or (env >= now - env), whichever you prefer but let's keep it
equivalent.
Or do you have a reason to rearrange it here?
Thanks,
Gabriele